Create (spatial) predictions of species occupancy and species richness from community occupancy models and spatial rasters or covariate data frames.

# S4 method for commOccu
predict(
  object,
  mcmc.list,
  type,
  draws = 1000,
  level = 0.95,
  interval = c("none", "confidence"),
  x,
  aoi = NULL,
  speciesSubset,
  batch = FALSE,
  seed
)

Arguments

object

commOccu object

mcmc.list

mcmc.list. Output of fit called on a commOccu object

type

character. "psi" for species occupancy estimates, "richness" for species richness estimates, "pao" for percentage of area occupied (by species), "psi_array" for raw occupancy probabilities in an array. For Royle-Nichols models, "abundance" for species abundance, or "lambda_array" for raw species abundance estimates in an array.

draws

Number of draws from the posterior to use when generating the plots. If fewer than draws are available, they are all used

level

Probability mass to include in the uncertainty interval

interval

Type of interval calculation. Can be "none" or "confidence" (can be abbreviated). Calculation can be slow for type = "psi" with many cells and posterior samples.

x

SpatRaster or data.frame. Must be scaled with same parameters as site covariates used in model, and have same names.

aoi

SpatRaster with same dimensions as x (if x is a SpatRaster), indicating the area of interest (all cells with values are AOI, all NA cells are ignored). If NULL, predictions are made for all cells.

speciesSubset

species to include in richness estimates. Can be index number or species names.

batch

logical or numeric. If FALSE, all raster cells / data frame rows will be processed at once (can be memory intensive). If TRUE, computation is conducted in batches of 1000. If numeric, it is the desired batch size.

seed

numeric. Seed to use in set.seed for reproducible results (ensures that draws are identical).

Value

A SpatRaster or data.frame, depending on x. If type = "pao", a list. If type = "psi_array" or "lambda_array", a 3D-array [cell, species, draw].

Details

Processing can be very memory-intensive. If memory is insufficient, use the batch parameter. This can enable processing for higher numbers of draws or very large rasters / data frames.