I have a mixed model where I'm trying to find the significance of my random effect. The model is a mixed model with zero-inflated beta distribution which I built using the R package glmmTMB, with the following function:
model<-glmmTMB(Overlap~Diff.Long Diff.Bkp DiffSeason (1|Xnumber),ziformula=~1,data=data,family=beta_family())
I'm trying to find the significance of the variable "Xnumber". I've read that what I need to do is a likelihood ratio test, but don't know how to do this with a glmmTMB object. I've tried using the Anova() function but I don't think the output is giving me what I want:
Anova(model,type="II")
Analysis of Deviance Table (Type II Wald chisquare tests)
Response: Overlap
Chisq Df Pr(>Chisq)
Diff.Long 5.0217 1 0.02503 *
Diff.Bkp 1.4717 1 0.22507
DiffSeason 7.5487 2 0.02295 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Any suggestions?
CodePudding user response:
Since Xnumber
is the grouping variable for which random effects are generated, it won't show up in the Anova table, because it doesn't have a coefficient that is being tested. To test this term, you could just leave it out (i.e., estimate a pooled model) and then use lrtest()
from the lmtest
package to calculate the LR-test. The null hypothesis is that the pooled model is sufficient. Here's the example from the glmmTMB()
function:
library(glmmTMB)
library(lmtest)
m1 <- glmmTMB(count ~ mined (1|site),
zi=~mined,
family=poisson, data=Salamanders)
m2 <- glmmTMB(count ~ mined,
zi=~mined,
family=poisson, data=Salamanders)
lrtest(m1, m2)
#> Likelihood ratio test
#>
#> Model 1: count ~ mined (1 | site)
#> Model 2: count ~ mined
#> #Df LogLik Df Chisq Pr(>Chisq)
#> 1 5 -949.23
#> 2 4 -958.96 -1 19.456 1.03e-05 ***
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Created on 2022-11-25 by the reprex package (v2.0.1)
Note, that in this case, since the test is significant, the pooled model is insufficient and the random effects model is preferred.