Fits a mixed model, typically a spatial GLMM.
This was the first function for fitting all spatial models in spaMM, and is still fully functional, but it is recommended to use fitme
which has different defaults and generally selects more efficient fitting methods, and will handle all classes of models that spaMM can fit, including non-spatial ones. corrHLfit
performs the joint estimation of correlation parameters, fixed effect and dispersion parameters.
corrHLfit(formula, data, init.corrHLfit = list(), init.HLfit = list(), ranFix = list(), lower = list(), upper = list(), objective = NULL, resid.model = ~1, control.dist = list(), control.corrHLfit = list(), processed = NULL, family = gaussian(), method="REML", nb_cores = NULL, ...)
formula |
Either a linear model |
data |
A data frame containing the variables in the response and the model formula. |
init.corrHLfit |
An optional list of initial values for correlation and/or dispersion parameters, e.g.
|
init.HLfit |
See identically named |
ranFix |
A list similar to |
lower |
An optional (sub)list of values of the parameters specified through |
upper |
Same as |
objective |
For development purpose, not documented (this had a distinct use in the first version of spaMM, but has been deprecated as such). |
resid.model |
See identically named |
control.dist |
See |
control.corrHLfit |
This may be used control the optimizer. See |
for default values.
processed |
For programming purposes, not documented. |
family |
|
method |
Character: the fitting method to be used, such as |
nb_cores |
Not yet operative, only for development purposes. Number of cores to use for parallel computations. |
... |
Optional arguments passed to |
For approximations of likelihood, see method
. For the possible structures of random effects, see random-effects
,
By default corrHLfit
will estimate correlation parameters by maximizing the objective
value returned by HLCor
calls wherein the dispersion parameters are estimated jointly with fixed effects for given correlation parameters. If dispersion parameters are specified in init.corrHLfit
, they will also be estimated by maximizing the objective
value, and HLCor calls
will not estimate them jointly with fixed effects. This means that in general the fixed effect estimates may vary depending on init.corrHLfit
when any form of REML correction is applied.
Correctly using corrHLfit
for likelihood ratio tests of fixed effects may then be tricky. It is safe to perform full ML fits of all parameters (using method="ML"
) for such tests (see Examples). The higher level function fixedLRT
is a safe interface for likelihood ratio tests using some form of REML estimation in corrHLfit
.
attr(<fitted object>,"optimInfo")$lower
and ...$upper
gives the lower and upper bounds for optimization of correlation parameters. These are the default values if the user did not provide explicit values. For the adjacency model, the default values are the inverse of the maximum and minimum eigenvalues of the adjMatrix
. For the Matérn model, the default values are not so easily summarized: they are intended to cover the range of values for which there is statistical information to distinguish among them.
The return value of an HLCor
call, with additional attributes. The HLCor
call is evaluated at the estimated correlation parameter values. These values are included in the return object as its $corrPars
member. The attributes added by corrHLfit
include the original call of the function (which can be retrived by getCall
(<fitted object>), and information about the optimization call within corrHLfit
.
# Example with an adjacency matrix (autoregressive model): if (spaMM.getOption("example_maxtime")>0.7) { corrHLfit(cases~I(prop.ag/10) +adjacency(1|gridcode)+offset(log(expec)), adjMatrix=Nmatrix,family=poisson(),data=scotlip,method="ML") } #### Examples with Matern correlations ## A likelihood ratio test based on the ML fits of a full and of a null model. if (spaMM.getOption("example_maxtime")>1.4) { data("blackcap") (fullfit <- corrHLfit(migStatus ~ means+ Matern(1|longitude+latitude),data=blackcap, method="ML") ) (nullfit <- corrHLfit(migStatus ~ 1 + Matern(1|longitude+latitude),data=blackcap, method="ML",init.corrHLfit=list(phi=1e-6))) ## p-value: 1-pchisq(2*(logLik(fullfit)-logLik(nullfit)),df=1) }
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.