Learn R Programming

spaMM (version 3.2.0)

HLCor: Fits a (spatially) correlated mixed model, for given correlation parameters

Description

A convenient interface for HLfit, constructing the correlation matrix of random effects from the arguments, then estimating fixed effects and dispersion parameters using HLfit.

Usage

HLCor(formula, data, family = gaussian(), ranPars = NULL, distMatrix,
      uniqueGeo = NULL, adjMatrix, corrMatrix, covStruct=NULL,
      verbose = c(trace=FALSE),
      control.dist = list(), ...)

Arguments

formula

A predictor, i.e. a formula with attributes (see Predictor), or possibly simply a simple formula if an offset is not required.

ranPars

A list of values for correlation parameters (some of which are mandatory), and possibly also dispersion parameters (optional, but passed to HLfit if present). See ranPars for further information.

data

The data frame to be analyzed.

family

A family object describing the distribution of the response variable. See HLfit for further information.

distMatrix

A distance matrix between geographic locations, forwarded to MaternCorr

uniqueGeo

A matrix of non-redundant geographic locations. Such a matrix is typically constructed automatically from the data and the model formula, but otherwise could be useful if further the rho parameter is a vector with different values for different coordinates, in which case a scaled distance matrix has to be reconstructed from uniqueGeo and rho.

adjMatrix

An adjacency matrix, used if a random effect of the form y ~ adjacency(1|<location index>) is present. See adjacency for further details.

corrMatrix

A matrix C used if a random effect term of the form corrMatrix(1|<stuff>) is present. This allows to analyze non-spatial model by giving for example a matrix of genetic correlations. Each row corresponds to levels of a variable <stuff>. The covariance matrix of the random effects for each level is then \(\lambda\)C, where as usual \(\lambda\) denotes a variance factor for the random effects (if C is a correlation matrix, then \(\lambda\) is the variance, but other cases are possible). See corrMatrix for further details.

covStruct

An interface for specifying correlation structures for different types of random effect (corrMatrix or adjacency). See covStruct for details.

verbose

A vector of booleans. trace controls various diagnostic (possibly messy) messages about the iterations.

control.dist

A list of arguments that control the computation of the distance argument of the correlation functions. Possible elements are

rho.mapping

a set of indices controlling which elements of the rho scale vector scales which dimension(s) of the space in which (spatial) correlation matrices of random effects are computed. See same argument in make_scaled_dist for details and examples.

dist.method

method argument of proxy::dist function (by default, "Euclidean", but see make_scaled_dist for other distances such as spherical ones.)

Further parameters passed to HLfit or to mat_sqrt.

Value

The return value of an HLfit call, with the following additional attributes:

HLCorcall

the HLCor call

info.uniqueGeo

Unique geographic locations.

Details

The correlation matrix for random effects can be specified by various combination of formula terms and other arguments (see Examples):

Basic Mat<U+00E9>rn model

Matern(1|<...>), using the spatial coordinates in <...>. This will construct a correlation matrix according to the Mat<U+00E9>rn correlation function (see MaternCorr);

Mat<U+00E9>rn model with given distance matrix

Matern(1|<...>) with distMatrix;

Given correlation matrix

corrMatrix(1|<...>) with corrMatrix argument. See corrMatrix for further details.

CAR model with given adjacency matrix

adjacency(1|<...>) with adjMatrix. See adjacency for further details;

AR1 model

AR1(1|<...>) See AR1 for forther details.

All these models except corrMatrix have additional parameters that must be specified by the ranPars argument.

See Also

autoregressive for additional examples, MaternCorr, HLfit, and corrHLfit

Examples

Run this code
# NOT RUN {
# Example with an adjacency matrix (autoregressive model):
# see 'adjacency' documentation page

#### Matern correlation using only the Matern() syntax
if (spaMM.getOption("example_maxtime")>0.8) {
 data("Loaloa")
 HLCor(cbind(npos,ntot-npos)~elev1+elev2+elev3+elev4+maxNDVI1+seNDVI
              +Matern(1|longitude+latitude),data=Loaloa,
      family=binomial(),ranPars=list(nu=0.5,rho=1/0.7)) 
}
# }
# NOT RUN {
<!-- %- : tested in simulate.HLCor.Rd -->
# }
# NOT RUN {
#### Matern correlation using a distMatrix
data("blackcap")
MLdistMat <- as.matrix(proxy::dist(blackcap[,c("latitude","longitude")]))
HLCor(migStatus ~ means+ Matern(1|latitude+longitude),data=blackcap,
      distMatrix=MLdistMat,HLmethod="ML",ranPars=list(nu=0.6285603,rho=0.0544659))

# }

Run the code above in your browser using DataLab