[R-sig-ME] glmmTMB model requires weights in prediction - what to supply

Werner Poschenrieder w|wp@31 @end|ng |rom gm@||@com
Thu Oct 19 12:53:06 CEST 2023


Dear Mixed-Models Community,



I have to predict from a model of class glmmTMB that has been calibrated as
follows



the_formula = as.formula("used_avail ~ SHA_DI_cat +
scale(forest_dist_raster) + scale(resid_dist_raster) +
scale(woody_dist_raster) + scale(road_dist_raster) +
scale(I(road_dist_raster^2)) + grassland + (1|study.area) + (1|IDyear)")



tmbmod = glmmTMB::glmmTMB(the_formula , data = group_df, weights = weight,
family = binomial(link = "logit"), na.action = na.omit)



I am surprised that prediction from that model using newdata does complain:



predict(tmbmod, newdata = df_newdata, type = type, re.form = "~0", se.fit =
T, allow.new.levels=TRUE)

Error in eval(extras, data, env) : object 'weight' not found



where df_newdata includes any of the predictors, i.e. fixed and random
effects. However, it does not include the column weight, as to my
understanding weights are for giving the residual a particular weight in
the course of fitting the model.

Such a weight thus results in an according value of the resulting effects.



What are weights for in prediction with glmmTMB, and thus, what value to
set them to?



Thanks in advance, best



Werner

	[[alternative HTML version deleted]]



More information about the R-sig-mixed-models mailing list