How to make 'visreg' plot when 'glmmTMB' gives error of object weights not found?

38 views Asked by At

Experiencing an error: Error in eval(extras, data, env) : object 'total' not found where object total is my weights category. Set as a column in my dataset and specified as weights= total in my model.

Per the 'visreg' package creator I tried remote installing the lastest version from github and specifying 'cond=list(total=25)' in my visreg code, whereas total is the weights. I am still getting the error. For whatever reason too the version that downloads is 2.7.0.8 not 2.7.1.

My example model:

m4 <- glmmTMB(propgerm ~ sdm + cage + logsoil + gapcat + rh_diff + temp_diff + 
       cage:logsoil + gapcat:logsoil + (1|plotID),
         weights = total, data = data, family=binomial) 

visreg script: visreg(m4, 'sdm', scale='response', type='conditional', 
   rug=FALSE, partial=TRUE, cond=list(total=25))

--------------receiving error-----------------

Github solution not working:

[[https://github.com/pbreheny/visreg/issues/67]

You can directly set the weights for the new predictions to be 1 (or something else, I guess):

visreg(gm.1_rand_slopeELEV_wt, scale="response", cond=list(weight=1))

This should now function as you want it to (keep in mind that you need to run remotes::install_github("pbreheny/visreg") first).

This functionality will appear in visreg 2.7.1.

0

There are 0 answers