Plotting modavgPred() for single season occupancy models with random effects

25 views
Skip to first unread message

Christopher Dennison

unread,
May 21, 2024, 6:39:34 PMMay 21
to unmarked
Good evening!

I am seeking guidance on how to plot the model average effect of a covariate (vl_100m) on occupancy probability of a species using ggplot and modavgPred().

I have a list of single-season occupancy models with random effects (INBU_mods_full), and have tried to use the following code to create :

occu_vl100_newdata <- data.frame(vl_100m = seq(min(INBU_stat.site_cov$vl_100m),
                                               max(INBU_stat.site_cov$vl_100m), by = 0.5),
                                 vl_50m = mean(INBU_stat.site_cov$vl_50m),
                                 ndvi_50m = mean(INBU_stat.site_cov$ndvi_50m),
                                 ndvi_100m = mean(INBU_stat.site_cov$ndvi_100m),
                                 build_50m = mean(INBU_stat.site_cov$build_50m),
                                 build_100m = mean(INBU_stat.site_cov$build_100m),
                                 roads_50m = mean(INBU_stat.site_cov$roads_50m),
                                 roads_100m = mean(INBU_stat.site_cov$roads_100m),
                                 imperv_50m = mean(INBU_stat.site_cov$imperv_50m),
                                 imperv_100m = mean(INBU_stat.site_cov$imperv_100m))

# Model-averaged prediction of occupancy and confidence interval

occu_vl100m_pred <- modavgPred(INBU_mods_full,
                               # c.hat =    # to change variance inflation factor, default = 1)
                               parm.type = "psi", # psi = occupancy
                               newdata = occu_vl100_newdata)[c("mod.avg.pred",
                                                               "lower.CL",
                                                               "upper.CL")]

However, since the models in 'INBU_mods_full' contain random effects, I get an error message asking to include the random effects in ' occu_vl100_newdata'.

I can certainly include my code and any .csv(s) necessary, but I am wondering the best way of plotting the model average estimate of a covariate when my unmarked models have random effects.

I hope this makes some sense. Thank you so much for your time and support.

- Chris

Marc J. Mazerolle

unread,
May 27, 2024, 9:18:45 PMMay 27
to unma...@googlegroups.com
Hi Chris,

Thanks for sending me the code and data offlist. The newdata argument
in modavgPred( ) requires values for each explanatory variable
appearing in your models for a given parameter (e.g., occupancy,
detection probability). In your case, some explanatory variables were
missing in the newdata data.frame. To see quickly all the variables
appearing in your models on a given parameter, you can use extractX( ).
For example, extractX(cand.set, parm.type = "psi"), will show you the
variables appearing on occupancy in the list of candidate models
(cand.set).

Once you fix this issue with the newdata data.frame, you will be able
to get model-averaged predictions for an average site, i.e., marginal
predictions. These are usually the predictions you want to display when
using random effects. If you want to get predictions for a specific
level of a random effect, then you will have to wait for the next
release of AICcmodavg this summer.

Best,
--
____________________________________
Marc J. Mazerolle
Professeur agrégé et directeur du bac. en environnements naturels et
aménagés
Département des sciences du bois et de la forêt
2405 rue de la Terrasse
Université Laval
Québec, Québec G1V 0A6, Canada
Tel: (418) 656-2131 ext. 407120
Email: marc.ma...@sbf.ulaval.ca

-------- Message initial --------
De: Christopher Dennison <christophe...@gmail.com>
Répondre à: unma...@googlegroups.com
À: unmarked <unma...@googlegroups.com>
Objet: [unmarked] Plotting modavgPred() for single season occupancy
models with random effects
Date: Tue, 21 May 2024 15:39:34 -0700
Reply all
Reply to author
Forward
0 new messages