HLCor {spaMM} | R Documentation |
Fits a (spatially) correlated mixed model, for given correlation parameters
Description
A fitting function acting as a convenient interface for HLfit
, constructing the correlation matrix of random effects from the arguments, then estimating fixed effects and dispersion parameters using HLfit
. Various arguments are available to constrain the correlation structure, covStruct
and distMatrix
being the more general ones (for any number of random effects), and adjMatrix
and corrMatrix
being alternatives to covStruct
for a single correlated random effect. uniqueGeo
is deprecated.
Usage
HLCor(formula, data, family = gaussian(), fixed=NULL, ranPars, distMatrix,
adjMatrix, corrMatrix, covStruct=NULL,
method = "REML", verbose = c(inner=FALSE),
control.dist = list(), weights.form = NULL, ...)
Arguments
formula |
A |
fixed , ranPars |
A list of given values for correlation parameters (some of which are mandatory), and possibly also dispersion parameters
(optional, but passed to HLfit if present). |
data |
The data frame to be analyzed. |
family |
A |
distMatrix |
Either a distance matrix between geographic locations, forwarded to |
adjMatrix |
An single adjacency matrix, used if a random effect of the form |
corrMatrix |
A matrix C used if a random effect term of the form |
covStruct |
An interface for specifying correlation structures for different types of random effect ( |
method |
Character: the fitting method to be used, such as |
weights.form |
Specification of prior weights by a one-sided formula: use |
verbose |
A vector of booleans. |
control.dist |
A list of arguments that control the computation of the distance argument of the correlation functions. Possible elements are
|
... |
Further parameters passed to |
Details
For approximations of likelihood, see method
. For the possible structures of random effects, see random-effects
, but note that HLCor
cannot adjust parameters of correlation models (with the exception of conditional autoregressive ones). Any such parameter must be specified by the ranPars
argument. More generally, the correlation matrix for random effects can be specified by various combinations of formula terms and other arguments (see Examples):
- Basic Matérn model
Matern(1|<...>)
, using the spatial coordinates in<...>
. This will construct a correlation matrix according to the Matérn correlation function (seeMaternCorr
);- Basic Cauchy model
Cauchy(1|<...>)
, as for Matern (seeCauchyCorr
);- Same models with given distance matrix
as provided by
distMatrix
(see Examples);- Given correlation matrix
corrMatrix(1|<...>)
withcorrMatrix
argument. SeecorrMatrix
for further details.- CAR model with given adjacency matrix
adjacency(1|<...>)
withadjMatrix
. Seeadjacency
for further details;- AR1 model
AR1(1|<...>)
SeeAR1
for further details.
Value
The return value of an HLfit
call, with the following additional attributes:
HLCorcall |
the HLCor call |
info.uniqueGeo |
Unique geographic locations. |
See Also
autoregressive
for additional examples, MaternCorr
, HLfit
, and corrHLfit
Examples
# Example with an adjacency matrix (autoregressive model):
# see 'adjacency' documentation page
#### Matern correlation using only the Matern() syntax
data("blackcap")
(fitM <- HLCor(migStatus ~ means+ Matern(1|longitude+latitude),data=blackcap,
method="ML", ranPars=list(nu=0.6285603,rho=0.0544659)))
#### Using the 'distMatrix' argument
data("blackcap")
#
# Build distance matrix (here equivalent to the default one for a Matern() term)
MLdistMat <- as.matrix(proxy::dist(blackcap[,c("latitude","longitude")]))
#
(fitD <- HLCor(migStatus ~ means+ Matern(1|longitude+latitude),data=blackcap,
distMatrix=MLdistMat, method="ML", ranPars=list(nu=0.6285603,rho=0.0544659)))
# : result here must be equivalent to the one without the distMatrix.
diff(c(logLik(fitM),logLik(fitD)))