explanaMesh: Prepare data for model construction

Description Usage Arguments Details Value

View source: R/explanaMesh.R

Description

Prepare and organise the data for model prediction. This function is meant to be used as a starting point for all spatial and spatiotemporal model in this package. This function also gathers explanatory variables values associated to the edges within and outside the area of interest.

Usage

1
explanaMesh(sPoly, meshSpace, meshTime, X = NULL, verbose = TRUE)

Arguments

sPoly

A SpatialPolygons or a SpatialPolygonsDataFrame defining the sampling region.

meshSpace

An inla.mesh object for the spatial part of the model.

meshTime

An inla.mesh object for the temporal part of the model. Default is NULL

X

A raster that includes the explanatory variables to consider for the analysis. This could also be a stack or a brick. Default is NULL.

verbose

Logical. Whether or not to print on the screen (five times) the number of edges that have been assigned values.

Details

The time it takes to run this function is directly related to the number of vertex (points) in the mesh; more specifically the ones outside the region of interest.

Also, this function checks the projections of sPoly, meshSpace and X to make sure they match. Note that if all projections are NAs, the function will run but warnings messages will be printed on screen related to this.

For spatiotemporal models, meshTime needs to be defined. However, it is not a necessary argument because explanaMesh is also meant to be used to build spatial model without any temporal components.

When building spatiotemporal models, it is possible that explanatory variables change through time. For this reason, X should be a stack or a brick where layers associated to a particular environment variable that changes through time have the same name but are differentiated by sequential numbers separated by a point. For example, they could have the following names : "env.1", "env.2", "env.3", etc. Time associated to the environment is defined as a z-value in the raster, using setZ. For all analyses to work properly, it is essential that time be formatted in a POSIXct class, otherwise the function will send an error.

If there are no explanatory variable available, it is still possible to estimate the hyper-parameters of a spatial or a spatio-temporal model through the function in the mapSpecies R package.

Value

An object of class explanaMesh that includes a list of all the objects used as arguments (except for the verbose call) and Xmesh the values of the explanatory variables for all edges of the mesh.


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