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

Ben Bolker bbo|ker @end|ng |rom gm@||@com
Fri Oct 20 02:16:11 CEST 2023


   It would probably be harmless to specify weight = 1 for the 
prediction.  I suspect this is just a side effect of the way that the 
prediction machinery works (I haven't looked). If you have a 
reproducible example, could you post this as an issue at the glmmTMB 
issues list?

On 2023-10-19 6:53 a.m., Werner Poschenrieder wrote:
> 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]]
> 
> _______________________________________________
> R-sig-mixed-models using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models



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