HmscRandomLevel {Hmsc}R Documentation

Create an Hmsc random level

Description

Specifies the structure of a random factor, including whether the random factor is assumed to be spatially explicit or not, the spatial coordinates and the potential structure of covariate-dependent random factors.

Usage

HmscRandomLevel(
  sData = NULL,
  sMethod = "Full",
  distMat = NULL,
  xData = NULL,
  units = NULL,
  N = NULL,
  nNeighbours = 10,
  sKnot = NULL,
  longlat = FALSE
)

Arguments

sData

a matrix or a dataframe containing spatial or temporal coordinates of units of the random level, or a similar SpatialPoints structure of the sp package. If spatial coordinates are unprojected longitude and latitude, great circle distances will be calculated internally. All spatial locations should be unique. If you have several observations in the same point, they should be identified by the random levels.

sMethod

a string specifying which spatial method to be used. Possible values are "Full", "GPP" and "NNGP"

distMat

a distance matrix containing the distances between units of the random level, with unit names as rownames, or a dist structure with location Labels. distMat cannot be used with "GPP" spatial model.

xData

a dataframe containing the covariates measured at the units of the random level for covariate-dependent associations

units

a vector, specifying the names of the units of a non-structured level

N

number of unique units on this level

nNeighbours

a scalar specifying the number of neighbours to be used in case the spatial method is set to NNGP. Only positive values smaller than the total number of plots are allowed.

sKnot

a dataframe containing the knot locations to be used for the Gaussian predictive process if sMethod is set to "GPP". Suitable data can be produced with constructKnots. The knot locations shall not duplicate sData.

longlat

Interpret coordinate data sData as longitude and latitude in decimal degrees. If this is TRUE, great circle distances will be used instead of Euclidean distances.

Details

Only one of sData, distMat, xData, units and N arguments can be provided.

As a good practice, we recommend to specify all available units for a random level, even if some of those are not used for training the model.

Value

a HmscRandomLevel-class object that can be used for Hmsc-class object construction

See Also

setPriors.Hmsc to change the default priors of an existing HmscRandomLevel object.

Examples

# Setting a random level with 50 units
rL = HmscRandomLevel(units=TD$studyDesign$sample)

# Setting a spatial random level
rL = HmscRandomLevel(sData=TD$xycoords)

# Setting a covariate-dependent random level.
rL = HmscRandomLevel(xData=data.frame(x1=rep(1,length(TD$X$x1)),x2=TD$X$x2))


[Package Hmsc version 3.0-13 Index]