Reputation: 25
I'm trying to get an AICc table for a few of my models which were constructed using package glmmTMB. The model gives a logLik value but no AICc. When I put the model into AICc():
a <- print(AICc(model, trace = TRUE,
rank = "AICc", REML = FALSE))
I get this error:
Error in UseMethod("logLik") :
no applicable method for 'logLik' applied to an object of class "logical"
I have used other functions like AICtab() and have gotten the same error, so I believe it is in the model itself. If anyone is able to interpret this error here please let me know, thank you.
Edit:
Minimal dataset and model used:
ID <- c("A","B","C","A","B","C","A","B","C","A","B","C")
#random effect
Sesh <- c("A1","B1","C1","A2","B2","C2","A3","B3","C3","A4","B4","C4")
#nested random effect
Stim <- c("Old","New","Old","New","Old","New","Old","New","Old","New","Old","New")
Temp <- c(75, 76, 72, 80, 71, 65, 69, 60, 76, 80, 81, 60)
Total <- c(0,1,5,6,3,10,2,1,0,0,4,6)
z <- data.frame(ID, Sesh, Stim, Temp, Total)
m <- glmmTMB(
Total ~ Stim + Temp + (1|ID/Sesh),
ziformula = ~1,
data = z,
family = nbinom2)
Upvotes: 1
Views: 2412
Reputation: 1562
Your model does not have likelihood (logLik(m)
is NA
), so it is impossible to calculate any likelihood-based criterion from it. This is presumably due to small sample size for a model with zero-inflation (the same model without ziformula
gives logLik
).
Also note that AICc
(I assume it is MuMIn::AICc
) does not have arguments trace
, rank
nor REML
, hence the error. I believe you confused the command with dredge
.
Upvotes: 1
Reputation: 13319
We can extract it manually(see NOTE):
summary(m)$AICtab
AIC BIC logLik deviance df.resid
NA NA NA NA 5
To directly get the AIC:
summary(m)$AICtab[[1]]
[1] NA
To get the AICc(I have not encountered this criteria in my studies at the time of writing):
MuMIn::AICc(m)
[1] NA
It is however the same output as above.
NOTE
It seems the developer(s) did not implement an AIC
method for glmmTMB
models so using AIC
fails.
The above AIC is NA likely due to insufficient data. This answer is just to show how to extract the AIC manually.
From the docs of AICc
:
Calculate Second-order Akaike Information Criterion for one or several fitted model objects (AICc, AIC for small samples).
Upvotes: 0