I am having troubles making the figures of the results of a model that looks like this:
mod_unprotIBA2 <- glmmTMB(LogAbu ~ Anomaly_std + NEnessSpp_std + Unprotected_IBA + Winter_std
+ Unprotected_IBA * Winter_std + NEnessSpp_std * Unprotected_IBA + Winter_std * NEnessSpp_std + Anomaly_std * NEnessSpp_std
+ Winter_std * NEnessSpp_std * Unprotected_IBA
+ (1|site) + (1|species),
family = gaussian,
control = glmmTMBControl(optCtrl = list(iter.max = 2000000, eval.max = 2000000), profile = TRUE, collect = FALSE),
data = UnprotIBA)
I have a code to sketch the model results but I do not seem to be able to calculate the predicted values from that model. I first create an X matrix:
X <- model.matrix(~ Anomaly_std + NEnessSpp_std + Unprotected_IBA + Winter_std
+ Unprotected_IBA * Winter_std + NEnessSpp_std * Unprotected_IBA + Winter_std * NEnessSpp_std + Anomaly_std * NEnessSpp_std
+ Winter_std * NEnessSpp_std * Unprotected_IBA, data = NewData)
And then I calculate the predicted values:
NewData$Pred <- predict(mod_unprotIBA2, NewData, level = 0) # this does NOT work
or
NewData$Pred <- X %*% fixef(mod_unprotIBA2)
and I get the error:
Error in X %*% fixef(mod_unprotIBA2) :
requires numeric/complex matrix/vector arguments
Do you have an idea how to calculate the predicted values from a glmmTMB object so that I can draw the figures?
I acknowledge that I have not provided any data. I thought it is a technical question which does not require data. But if you do need, I can provide the model as .rds