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
|
sMethod |
a string specifying which spatial method to be
used. Possible values are |
distMat |
a distance matrix containing the distances between
units of the random level, with unit names as rownames, or a
|
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 |
sKnot |
a dataframe containing the knot locations to be used
for the Gaussian predictive process if |
longlat |
Interpret coordinate data |
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))