doserjef / spOccupancy

Single-species, Multi-species, and Integrated Spatial Occupancy Models
https://www.jeffdoser.com/files/spoccupancy-web/
GNU General Public License v3.0
51 stars 7 forks source link

Memory error while calling predict function for single species spatial occupancy model #38

Closed rahulkgour closed 7 months ago

rahulkgour commented 7 months ago

Hi,

I am getting the below error while calling the predict function. This I have tried with only two site level covariates, I have yet to add four more occurrence covariates.

> out.sp.pred <- predict(out.sp, X.0, coords.0, verbose = TRUE)
----------------------------------------
    Prediction description
----------------------------------------
NNGP Occupancy model with Polya-Gamma latent
variable fit with 70 observations.

Number of covariates 3 (including intercept if specified).

Using the exponential spatial correlation model.

Using 5 nearest neighbors.

Number of MCMC samples 1200.

Predicting at 1048575 non-sampled locations.

Source not compiled with OpenMP support.
**Error: vector memory exhausted (limit reached?)**

Data

Screenshot 2024-02-19 at 21 52 10

I am running this on MacOS with a 32gb physical RAM.

Thanks, Rahul

doserjef commented 7 months ago

Hi Rahul,

Thanks for the note. It looks like you are trying to predict at over 1 million locations. When using predict(), that will generate a full posterior distribution of samples for the occupancy probability (and occupancy state) at each of those locations, which will be a massive object (i.e., each of the locations will have 1200 values associated with it), and your computer doesn't have enough memory for that. What you will need to do instead is predict at a smaller number of those locations at a time, save some of the output from those predictions, and then continue with more locations. I would suggest doing this by breaking up the 1048575 locations into much smaller chunks.

Hope that helps! Because this is not related to an error with the package itself, I am going to close this issue. Feel free to email me (doserjef@msu.edu) if you continue to run into problems.

Jeff

rahulkgour commented 7 months ago

Thank you Jeff for such a quick response, and I apologies for raising it as an issue over here. I will email you the couple of questions for the solution you mentioned.

Regards, Rahul