Created
August 20, 2021 17:28
-
-
Save evu/370e2322f5e32913ea49a4de7bfea0ec to your computer and use it in GitHub Desktop.
Poisson regression in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import statsmodels.api as sm | |
from patsy import dmatrices | |
import numpy as np | |
y, X = dmatrices("time_s ~ cloud + model + sensor", data=df) | |
# Note that offset is in 100s of square miles | |
offset = np.asarray(df["sq_mi"]) / 100 | |
m = sm.Poisson(y, X, offset=offset) | |
fitted = m.fit() | |
fitted.summary() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment