predicting from abund() fit with family = 'zi-Gaussian"

13 views
Skip to first unread message

Jonathan Farr

unread,
May 1, 2025, 3:03:56 PMMay 1
to spOccupancy and spAbundance users
Hi folks, a bit new to these packages but hoping to learn lots! 

Has anyone made predictions from a zero-inflated gaussian model? When I tried to use predict(model, covars) I got an error saying:

"Error in predict.abund(out, X.0) : z.0.samples must be supplied for a zi-Gaussian model"

Note that predictions worked for a gaussian model, so I'm guessing that it is not an issue with the covariate matrix or the model itself. I think this means I need to use spOccupancy to build that binomial presence/absence model, use that to create the z.0.samples object that has binary predictions across my prediction dataset, and then predict() on that? But I'm unclear on how best to do that (fit a detection only spOccupancy object with same covars and use that to predict?). Or is there a way to predict the binary response from my abund() object itself without fitting a separate model? 

If anyone has insight to share I would super appreciate it, thank you! 

Jonathan 

Jeffrey Doser

unread,
May 3, 2025, 6:42:23 AMMay 3
to Jonathan Farr, spOccupancy and spAbundance users
Hi Jonathan,

Apologies for the delay, and thanks for the question. You are correct in that since you got the predictions to work with a Gaussian model that there is likely nothing wrong with the covariate matrix itself. The zi-Gaussian model (particularly this single-species non-spatial version) is probably the least well-documented/developed of all the functions in the package, so apologies for that. The zi-Gaussian model is really a hurdle model in which you predict whether or not the species exists at a given location (0 or 1), then at the sites it does exist, you predict how much of the species it does exist. Oftentimes it's useful to do some sort of transformation on the response variable (e.g., log or square root transformation) for the Gaussian part of the model to ensure positive support, but that depends on what you're modeling. Anyways, all that to say that when predicting from this model, you will need to first predict the presence/absence of the species using some sort of logistic regression type model, then take the predictions from that model and supply them to the z.0.samples.

In this specific case (single-species non-spatial logistic regression), there is no function in spOccupancy that can fit that model for you, so what you would need to do is fit that model using some other Bayesian software (brms would probably be easiest), predict presence/absence values for the new prediction sites using that model in the other software, and then you could supply those predicted values to the "z.0.samples" object in predict() for the second part of the hurdle model when predicting in spAbundance. If you wanted to fit a spatial model for the presence/absence stage, then you could do this directly in spOccupancy using the svcPGBinom function (setting svc.cols = 1 to get just a spatial intercept model). For muli-species models, there are also options to do both spatial (sfJSDM) and non-spatial versions (lfJSDM) in spOccupancy for the first stage, but that doesn't help you here. So, all that to say that you could use brms to get the predicted "z.0.samples", then use spAbundance::abund() and the predict functionality as you were attempting, or I think there is also functionality all directly in brms for fitting non-spatial hurdle models of this type, so that may actually be your best bet.

Apologies for the probably somewhat confusing answer, but let me know if there's anything I can clarify.

Jeff

--
You received this message because you are subscribed to the Google Groups "spOccupancy and spAbundance users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spocc-spabund-u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/spocc-spabund-users/658001fa-f8d4-40cd-9bb1-630d63a0a727n%40googlegroups.com.


--
Jeffrey W. Doser, Ph.D.
Assistant Professor
Department of Forestry and Environmental Resources
North Carolina State University
Pronouns: he/him/his
Reply all
Reply to author
Forward
0 new messages