I am trying to look at how the number of events X is affected by the three factors A (4 levels), B (2 levels) and C (2 levels) using a negative binomial model as follows:
model.count.nb<-glm.nb(X.total ~ A*B*C, link = "log", data = count.X)
summary(model.count.nb)
Call:
glm.nb(formula = X.total ~ A * B * C,
data = count.X, link = "log", init.theta = 4.864199324)
Deviance Residuals:
Min 1Q Median 3Q Max
-3.7430 -0.5601 0.0705 0.4939 2.0461
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 5.529870 0.152589 36.240 <2e-16 ***
A2 -0.011079 0.193019 -0.057 0.954
A3 0.060288 0.215733 0.279 0.780
A4 -0.270010 0.206022 -1.311 0.190
B2 0.098550 0.215697 0.457 0.648
C2 -0.249439 0.205999 -1.211 0.226
A2:B2 0.095448 0.300565 0.318 0.751
A3:B2 -0.001116 0.281570 -0.004 0.997
A4:B2 0.330682 0.302998 1.091 0.275
A2:C2 0.244077 0.282310 0.865 0.387
A3:C2 -0.215565 0.294696 -0.731 0.464
A4:C2 0.172165 0.276917 0.622 0.534
B2:C2 -0.137896 0.303376 -0.455 0.649
A2:B2:C2 -0.025005 0.440519 -0.057 0.955
A3:B2:C2 0.401948 0.396986 1.012 0.311
A4:B2:C2 0.027745 0.403595 0.069 0.945
Signif. codes: 0 ‘*’ 0.001 ‘’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for Negative Binomial(4.8642) family taken to be 1)
Null deviance: 221.54 on 185 degrees of freedom
Residual deviance: 193.99 on 170 degrees of freedom
(1 observation deleted due to missingness)
AIC: 2280.9
Number of Fisher Scoring iterations: 1
Theta: 4.864
Std. Err.: 0.505
2 x log-likelihood: -2246.898
In order to determine significance of each term in the model I remove each term from the model and then perform a likelihood ratio test to obtain a p-value for each term. For example:
#To determine significance of the 3-way interaction
model.count.nb.no3way<-glm.nb(X.total ~A+B+C+A:B+A:C+B:C, link = "log", data = count.X)
lrtest(model.count.nb, model.count.nb.no3way)#Interaction insignificant
Likelihood ratio test
Model 1: X.total ~ A * B * C
Model 2: X.total ~ A + B + C + A:B + A:C + B:C
#Df LogLik Df Chisq Pr(>Chisq)
1 17 -1123.5
2 14 -1124.3 -3 1.6887 0.6394
#To determine significance of interaction between A and B
model.count.nb.noAB<-glm.nb(X.total ~ A+B+C+A:C+B:C, link = "log", data = count.X)
summary(model.count.nb.noAB)
lrtest(model.count.nb.no3way, model.count.nb.noAB)#Interaction insignificant
Likelihood ratio test
Model 1: X.total ~ A + B + C + A:B + A:C + B:C
Model 2: X.total ~ A + B + C + A:C + B:C
#Df LogLik Df Chisq Pr(>Chisq)
1 14 -1124.3
2 11 -1125.8 -3 3.0111 0.3899
When determining the significance of either the 2-way or 3-way interactions only one term needs to be dropped from the model in order to use a likelihood ratio test however I am not sure which terms to drop if looking for the significance of the main effects and which model to compare this to. My first thought was to compare the model with no-3way interaction with the model without any terms involving a particular main effect i.e.:
model.count.nb.noC<-glm.nb(X.total ~ A+B+A:B, link = "log", data = count.X)
summary(model.count.nb.noC)
lrtest(model.count.nb.no3way, model.count.nb.noC)
The likelihood ratio test does work however, would this not represent the significance of C+A:C+B:C rather than just the main effect C.
Any help anyone can provide with my query would be greatly appreciated.
Cwith outcome, considering all its interactions?" – EdM Mar 14 '24 at 16:31