We have previously discussed continuous outcomes:
This week, we will consider count outcomes:
\ln\left( y \right) = \beta_0 + \beta_1 x_1 + ... + \beta_k x_k
This is similar to Poisson regression.
Negative binomial regression is used specifically for count response variables.
Examples:
How is this different than Poisson regression?
How is this different than Poisson regression?
Poisson regression assumes that the mean and variance of the count variable are equal (equidispersion).
Negative binomial regression includes an additional parameter, \theta, to account for overdispersion.
How do I determine which to use?
Easy check: mean and variance.
mean() and var().Another way to eyeball: histogram.
Wait – why do we care?
When data is overdispersed, we know that the standard error for \beta_i is underestimated in Poisson regression.
When we apply the negative binomial instead, the overdispersion parameter remedies this issue.
Pluto spends his days at Mickey’s park chasing squirrels and interacting with guests. Disney researchers are interested in understanding what factors influence the number of squirrels Pluto chases per hour.
For 300 observation periods, researchers recorded:
[1] 41.36333
[1] 345.6903
To perform negative binomial regression, we need the glm.nb() function from the MASS package.
MASS is another package I will not load in, personally. I call the function directly from the package,tidy(), (Intercept) temperature crowd temperature:crowd
0.1857624458 0.0363002481 0.0393306623 -0.0003112087
(Intercept) temperature crowd temperature:crowd
0.2049441484 0.0358999533 0.0387828971 -0.0003010588
(Intercept) temperature crowd temperature:crowd
5.708977e-01 3.935022e-17 1.245243e-10 1.117731e-04
(Intercept) temperature crowd temperature:crowd
7.515065e-01 3.335648e-05 2.051211e-03 7.333480e-02
Our approach to determining significance remains the same.
For continuous and binary predictors, we can use the Wald test (z-test from tidy()).
For omnibus tests, we can use the likelihood ratio test (LRT).
car::Anova(type = 3) or full/reduced LRT).car::Anova(type = 3) or full/reduced LRT).m1_full <- MASS::glm.nb(squirrels_chased ~ temperature + crowd + temperature:crowd, data = pluto)
m1_reduced <- MASS::glm.nb(squirrels_chased ~ 1, data = pluto)
anova(m1_reduced, m1_full, test = "Chisq")\ln\left( y \right) = 1.32 + 0.02 \text{ temp} + 0.02 \text{ crowd}
\ln\left( y \right) = \beta_0 + \beta_1 x_1 + ... + \beta_k x_k
We are modeling the log of the count.
Interpreting \hat{\beta}_i is an additive effect on the count.
Interpreting e^{\hat{\beta}_i} is a multiplicative effect on the count.
Thus, when interpreting the slope for x_i, we will look at the Incident Rate Ratio, e^{\hat{\beta}_i}.
tidy(),| Predictor | IRR (95% CI for IRR) | p-value |
|---|---|---|
| Temperature | 1.021 (1.017, 1.026) | < 0.001 |
| Crowd | 1.017 (1.014, 1.019) | < 0.001 |
| Predictor | IRR (95% CI for IRR) | p-value |
|---|---|---|
| Temperature | 1.021 (1.017, 1.026) | < 0.001 |
| Crowd | 1.017 (1.014, 1.019) | < 0.001 |
For every 1°F increase in temperature, the expected number of squirrels chased increases by a factor of 1.021, holding crowd constant. This is a 2.1% increase.
For every 100 additional guests in the park, the expected number of squirrels chased increases by a factor of 1.017, holding temperature constant. This is a 1.7% increase.
In this lecture, we have introduced negative binomial regression.
We again saw the log link function.
We interpret coefficients as multiplicative effects on the count of the outcome.
These are called the incident rate ratios (IRR).
In the next lecture, we will review visualization of Poisson and negative binomial models.
Next week, we will bring all topics together and review choosing the appropriate regression model for your data.