poisson
Explains a count — how many times something happened.
What we have
- the same factor notation as
regress
Coming later
irr, to print incidence rate ratiosexposure()andoffset()predictandmarginsafterwards
How you write it
poisson depvar indepvars [if]
Square brackets mean optional. A vertical bar means choose one.
What it does
For outcomes that are whole numbers starting at zero: household size, hospital visits, accidents per month. Coefficients are on a multiplying scale, so exponentiating one gives the factor by which the count changes (an incidence rate ratio).
It rests on one strong assumption: that the spread of the counts equals their average. Real counts are usually more spread out than that, which is what nbreg is for.
Try it
Every example below was run after sysuse vira.sample02, clear.
. poisson hhsize age
Poisson regression Number of obs = 6,000
LR chi2 = 0.09
Prob > chi2 = 0.7626
Pseudo R2 = 0.0000
------------------------------------------------------------------------------
hhsize | Coefficient Std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
age | 9.752e-05 .00032286 0.30 0.763 -.0005353 .00073031
_cons | 1.508891 .01635485 92.26 0.000 1.476836 1.540946
------------------------------------------------------------------------------
The same thing in pandas and in R
pandas
import statsmodels.formula.api as smf
model = smf.poisson("hhsize ~ age", data=df).fit()
R
model <- glm(hhsize ~ age, family = poisson(link = "log"), data = df) summary(model) # This R was run in a real R (4.6.1) and gave the same numbers.