Major confusion/discrepancy in modelled + predicted occupancy values

49 views
Skip to first unread message

王英龍

unread,
Oct 28, 2024, 4:57:10 AMOct 28
to spOccupancy and spAbundance users
Hi all,

I've found a recurring issue that has left me stumped - I need your help!
I've been modelling occupancy and then using the predict() function using 600 randomly generated points with the corresponding occurrence covariate data used in my models. 
I have done this for multiple seasons with single season models, and am now trying a multi-season model.

I have around 35 camera trap sites for the input data, with the occurrence covariate info extracted from my environmental rasters. I have then been using the predict() function as I want to generated a map of what the modelled occupancy for a given season looks like for our camera trap grids. To avoid patches in the raster from just using the 25 camera trap locations, I have randomly generated 600 points within the grid and extracted the occurrence covariate info for each of these points, which is used as the x.0 file for the predict() function. The prediction occurrence covariates fed into the predict function are exactly the same for each season, the only difference is the occupancy model (which then has some difference camera trapping sites (not all are present in every single dataset - some didn't work etc), different detection histories, etc). 

My issue is that when modelled occupancy is modelled as be the lowest (e.g. 0.47 for Spring 2024, compared with 0.65 for Summer 2024), when I then put these models into the predict() function, the resulting prediction raster I get indicates the highest occupancy (e.g. 0.8) for the season that was modelled as having the lowest occupancy, and predicts lower occupancy for the seasons that were modelled as having a higher average occupancy. This has happened with 2 separate camera trap grids now, and I am totally stumped.

Why might this be? Has anyone else had this issue?

I am happy to provide code if needed - just let me know what specifically you might want to see.

All the best,

Jamie

Jeffrey Doser

unread,
Oct 29, 2024, 10:14:46 AMOct 29
to 王英龍, spOccupancy and spAbundance users
Hi Jamie, 

Thanks for the note. The model estimated values of psi and z takeinto account the observed data values at those locations (i.e., since the models assume no false positives, if a species is ever detected at a site then that site is known to be occupied). When using the predict() function, no such information is available, and so depending on how well the model is able to predict occupancy probability, there may be some differences between values of psi/z at locations used to fit the model versus psi/z values predicted at locations near by. It of course also depends on the covariates as well, and in general how well the model fits and how reliable predictions in new parts of the study area may or may not be. It's not super clear to me where the problem might lie in your examples based on your description, so If you could send me the code/data needed to fit the model and do the prediction (i.e., to generate the contrasting results you are finding) then I can try and take a look to see what is going on. 

Cheers,

Jeff

Jeffrey W. Doser, Ph.D.
Assistant Professor
Department of Forestry and Environmental Resources
North Carolina State University
Pronouns: he/him/his


--
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/317ee04b-475e-4a92-82a2-9f920dc2b4a1n%40googlegroups.com.
Message has been deleted

王英龍

unread,
Nov 1, 2024, 9:44:31 AMNov 1
to spOccupancy and spAbundance users
Hi Jeff,

Thanks for the offer to help. I've just emailed you some example data and code that should show what my problem is.

In the meantime, I realised today that I can make a map of the modelled psi (not values from predict() but the original spOccupancy models), which was what I really wanted all along. I thought the only way I could do that was via the prediction function. Since I was following the walkthroughs on the spOccupancy website and only saw maps in the prediction section, I did not realise I could make maps by putting the modelled psi values for each site in a data frame with the x and y coordinates.

I imagine others may not realise this as well, so I would definitely recommend highlighting in the walkthrough examples on the spOccupancy website that maps of modelled occupancy at each sampling site can be made by making a dataframe with the mean psi for each site (apply(model$psi.samples, 2, mean)) along with one's x and y coordinates. 
Otherwise, I imagine others will, like me, think that the only way to make a map showing occupancy is by using the predict() function and workflows on the website, when this may not be exactly what we want to show.

All the best and looking forward to hearing your thoughts on why I'm seeing such differences between modelled and predicted psi,

Jamie

Jeffrey Doser

unread,
Nov 16, 2024, 6:05:38 AMNov 16
to spOccupancy and spAbundance users
Just to circle back to this in case someone else encounters this problem, I believe the issue here was a result of the covariates not be standardized when doing prediction. If standardizing covariates when fitting the model, the covariates supplied to "X.0" in the predict() functions will need to be standardized by the same values used when fitting the model. An example of how to do this is in the intro spOccupancy vignette.

Also thanks Jamie for the useful suggestion on highlighting how one can use "psi.samples" in a vignette. That's a great idea!

Jeff
Reply all
Reply to author
Forward
0 new messages