I'd like opinions on two differing GLM outputs in RStudio.
I model count data (dung pellets) over 21 sites, using quadrats counted as an area offset. I started with a GLM Poisson regression for the definition of the model structure, which was strongly overdispersed & zero inflated. I moved to Negative Binomial, which fixed both issues, but I have differing results according to the package used (MASS:glm.nb and glmmTMB nbinom2). They give the same theta estimation, same AIC, but different SE & z-values, in particular for one predictor, which appears as significant in one but not the other package. This is prior to model selection.
Thus, I'd like to know what are the differences in parameterization between the two packages used? From what I've read, they seem to use the same variance formulas, both estimated through Maximum Likelihood:
- glmmTMB : variance = µ(1 + µ/k)
- MASS: variance = μ+μ²/θ so that θ=1/k
I am suspecting that it is related to MASS::glm.nb dropping constants from the log-likelihood calculations while glmmTMB is not, but I cannot confirm it.
I'm inclined to stick with MASS as I don't use any RE here, but I'd like to know what is happening.
code output:
> # MASS package
> mod.nbmass <- glm.nb(pellets ~ RS1+RS2+RS4+RS5+RS6+offset(log(quadrats)), link = "log", data=data_site)
> summary(mod.nbmass)
Call:
glm.nb(formula = pellets ~ RS1 + RS2 + RS4 + RS5 + RS6 + offset(log(quadrats)),
data = data_site, link = "log", init.theta = 0.9808088892)
Deviance Residuals:
Min 1Q Median 3Q Max
-2.6923 -0.9313 -0.1119 0.2173 1.5372
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.17109 0.22170 0.772 0.4403
RS1 -0.04392 0.34372 -0.128 0.8983
RS2 0.21905 0.31118 0.704 0.4815
RS4 -0.04524 0.31740 -0.143 0.8866
RS5 0.21135 0.34775 0.608 0.5433
RS6 -0.67892 0.33963 -1.999 0.0456 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for Negative Binomial(0.9808) family taken to be 1)
Null deviance: 29.252 on 20 degrees of freedom
Residual deviance: 24.854 on 15 degrees of freedom
AIC: 246.43
Number of Fisher Scoring iterations: 1
Theta: 0.981
Std. Err.: 0.290
2 x log-likelihood: -232.429
> # glmmTMB package
> mod.nbTMB<-glmmTMB(pellets ~ RS1+RS2+RS4+RS5+RS6+offset(log(quadrats)), family="nbinom2", data=data_site)
> summary(mod.nbTMB)
Family: nbinom2 ( log )
Formula: pellets ~ RS1 + RS2 + RS4 + RS5 + RS6 + offset(log(quadrats))
Data: data_site
AIC BIC logLik deviance df.resid
246.4 253.7 -116.2 232.4 14
Dispersion parameter for nbinom2 family (): 0.981
Conditional model:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.17109 0.22163 0.772 0.440
RS1 -0.04393 0.39138 -0.112 0.911
RS2 0.21905 0.26685 0.821 0.412
RS4 -0.04525 0.30701 -0.147 0.883
RS5 0.21135 0.40676 0.520 0.603
RS6 -0.67892 0.48995 -1.386 0.166
Thank you!