| HLCor | R Documentation |
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. The uniqueGeo argument is deprecated.
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, ...)
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 |
This argument allows estimation of Matern or Cauchy correlation parameters to be combined with use of an ad hoc distance matrix. When there is a single spatial random effect, it may be a distance matrix between geographic locations, internally used as argument to More generally, it may be a list of such matrices. The list format may be necessary when there are several Matern/Cauchy terms, to avoid that all of them are affected by the same |
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 arguments passed to |
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):
Matern(1|<...>), using the spatial coordinates in <...>. This will construct a correlation matrix according to the Matérn correlation function (see MaternCorr);
Cauchy(1|<...>), as for Matern (see CauchyCorr);
as provided by distMatrix (see Examples);
corrMatrix(1|<...>) with corrMatrix argument. See corrMatrix for further details.
adjacency(1|<...>) with adjMatrix. See adjacency for further details;
AR1(1|<...>) See AR1 for further details.
The return value of an HLfit call, with the following additional attributes:
HLCorcall |
the HLCor call |
info.uniqueGeo |
Unique geographic locations. |
Additional example using an adjacency term in autoregressive;
Additional examples using corrMatrix or distMatrix argument in corrMatrix;
MaternCorr, which may be used to specify corrMatrix values.
# 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)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.