ppSpace: Spatial point process model

Description Usage Arguments Details Value References

View source: R/ppSpace.R

Description

Spatial point process model using INLA. This function is essentially a specialized wrapper over inla

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
ppSpace(
  formula,
  sPoints,
  ppWeight,
  explanaMesh,
  smooth = 2,
  prior.range = c(0.05, 0.01),
  prior.sigma = c(1, 0.01),
  many = FALSE,
  fix = NULL,
  sboffset = NULL,
  orthoCons = FALSE,
  ...
)

Arguments

formula

A formula that only relates the response y and some (or all) of the explanatory variables X. A paricularity of the is formula is that the response has to be defined as y.

sPoints

A SpatialPoint* object that includes the sample location of the modelled species.

ppWeight

An object of class ppWeight

explanaMesh

An object of class explanaMesh

smooth

A single value ranging between 0 and 2 passed to inla.spde2.pcmatern. It defines the smoothness of the Matern SPDE model. Default is set at 2.

prior.range

A vector of length 2, with (range0, Prange) specifying that P(ρ < ρ_0) = p_ρ, where ρ is the spatial range of the random field. If Prange is NA, then range0 is used as a fixed range value. Default is c(0.05, 0.01).

prior.sigma

A vector of length 2, with (sigma0, Psigma) specifying that P(σ > σ_0) = p_σ, where σ is the marginal standard deviation of the field. If Psigma is NA, then sigma0 is used as a fixed range value. Default is c(1, 0.01).

many

Logical. Whether the data in sPoints is large or not. See details. Default is FALSE.

fix

A vector with the name of variables in the model that should be fixed to a given value when doing predictions. These values are used to map the intensities across the study area for a given value. Currently, the maximum of each variable is used as the fixed value, but it should be made more flexible in the future for example for playing more easily with climate change scenarios. Default is NULL, meaning no variables are fixed.

sboffset

A character string with the name of the variable in the raster stack that should be used as an offset to scaled down the integration weights according to the level of effort across the study region. See details for further explanations. Default is NULL.

orthoCons

Set to TRUE to force all the variance to go into the fixed effects. Sets constraints to have spatial field orthogonal to predictors. Experimental and currently not working...

...

Arguments passed to inla

Details

If the argument many = TRUE, the estimation and the prediction will be carried out solely at the mesh edges, whereas when many = FALSE the estimation will be carried out at the mesh edges and at the sampled location. When the number of samples is very large (e.g. tens of thousands of samples or more) using many = TRUE can be much more computationally efficient. However, there is a precision trade-off. When many = TRUE, each sample is associated to an edge and the model is constructed using the number of samples associated to an edge as an importance value. In doing so, some spatial precision is lost at the expense of speed.

It is possible to build a model without any explanatory variables by defining the formula as:

y ~ -1 or y ~ 0

Using this formulation, it is not necessary to rerun the explanaMesh function. However, define a model with the formula y ~ 1 will return an error because the model implemented always includes an intercept.

The sampling bias offset argument sboffset is used to scaled down the weights (w) obtained from the dual mesh using a variable representing effort. This variable has to be a layer in the raster stack given for the predictors. Specifically, values in the raster layer given will be summed for each polygon in the dual mesh to summarize the effort for each polygon. The extraction is made exact by using the exactextractr package. Once summed, values for each polygon (e) are 1) scaled with the weights, 2) rescaled between 0 and 1 and 3) multiplied with the original weights ((e/w) / max(e/w)) * w to adjust the weights in the integration mesh. This is an adaptation from Simpson et al. (2016). Note that polygons from the dual mesh that are partially overlapping the region of interest will get the weight associated with their area overlapping the study region and the effort considered is the effort associated with this overlapping area.

Value

An object of class ppSpace that includes a model output, which is the model output of INLA.

In addition, it includes a series of attributes:

formula

The formula used to construct the model

sPoints

A SpatialPointDataFrame object that includes the sample location and associated data of the modelled species.

XEst

A matrix with all the explanatory variables used to construct the model. If there were factors in the original set of explanatory variables X, in XEst, they were decomposed into dummy variables. The values in XEst are the one from the sampled location.

XPred

A matrix with all the explanatory variables used to construct the model. If there were factors in the original set of explanatory variables X, in XPred, they were decomposed into dummy variables. The values in XPred were gathered at the mesh edges. When many = TRUE, the values in XPred are exactly the same as the values in XEst

mesh

An object of class inla.mesh. It is the mesh used to construct the model.

Stack

An object of class inla.data.stack. It is a stack object constructed internally.

References

Simpson, D. Illian, J. B., Lindgren, F. Sørbye, S. H. and Rue, H. 2016. Going off grid: computationally efficient inference for log-Gaussian Cox processes. Biometrika, 103(1): 49-70 https://doi.org/10.1093/biomet/asv064


ReseauBiodiversiteQuebec/mapSpecies documentation built on Dec. 18, 2021, 9:57 a.m.