Learn R Programming

spaMM (version 1.1)

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,ranPars,data,distMatrix,uniqueGeo,adjMatrix,
      corrMatrix,verbose=rep(FALSE,3),...)

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). By default, the Matern.corr model i
data
The data frame to be analyzed.
distMatrix
A distance matrix between geographic locations, forwarded to Matern.corr
uniqueGeo
A matrix of non-redundant geographic locations. This is useful if the rho parameter is a vector with different values for different geographic coordinates, in which case a scaled distance matrix has to be reconstructed from uniqueG
adjMatrix
An adjacency matrix, used if the spatial random effects are of the form y ~ adjacency(1|). Its rows and columns must be ordered as increasing values of the levels of the geographic location index specifying the spa
corrMatrix
A arbitrary (valid) correlation matrix, which each row correspond to levels of a variable for the random effect (1|) given in the model formula. This allows to analyze non-spatial model by giving for example a matrix of genetic correla
verbose
A vector of up to three booleans, the first of which controls printed output from HLCor (currently not very useful), the other ones being used as the 'verbose' argument of the HLfit call.
...
Further parameters passed to HLfit or to designL.from.corr.

Value

  • A list with elements
  • hlfitThe return value of the HLfit call
  • callthe HLCor call
  • HLCor.infoA list with optional additional information. May include the names of the coordinates used to compute the spatial correlation matrix between unique geographic locations.

Details

The correlation matrix for random effects can be specified using either the formula terms (not functions!) Matern(1|<...>) or adjacency(1|<...>) using the spatial coordinates in <...> (see Examples), or a user-provided distance matrix distMatrix to which the Matérn function is applied, or a user-provided correlation matrix corrMatrix. Matern will construct a correlation matrix according to the Matérn correlation function (see Matern.corr). adjacency will construct a correlation matrix according to a conditional autoregressive (CAR) model, using the adjMatrix. In the latter case the correlation matrix has the form (I$-\rho$adjMatrix)$^{-1}$. This was implemented for comparison purposes as it is widely used, but is not really recommended for irregular lattices (see Wall, 2004 and Martellosio, 2012 for some insights on the implications of autoregressive models).

References

Wall M.M. (2004) A close look at the spatial structure implied by the CAR and SAR models: Journal of Statistical Planning and Inference 121: 311-324. Martellosio, F. (2012) The correlation structure of spatial autoregressions, Econometric Theory 28, 1373-1391.

See Also

Matern.corr, HLfit, corrHLfit

Examples

Run this code
#### Examples with Matérn correlations
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)) ## takes ~ 6s

#### example with an adjacency matrix (autoregressive model)
data(scotlip) 
HLCor(cases~I(prop.ag/10) +adjacency(1|gridcode)+offset(log(scotlip$expec)),
      ranPars=list(rho=0.174),
      adjMatrix=Nmatrix,family=poisson(),data=scotlip)

Run the code above in your browser using DataLab