Fit mixed models with given correlation matrix
This function fits GLMMs as well as some hierarchical generalized linear models (HGLM; Lee and Nelder 2001).
HLfit
fits both fixed effects parameters, and dispersion parameters i.e. the variance of the random effects (full covariance for random-coefficient models), and the variance of the residual error. The linear predictor is of the standard form offset+ X beta + Z b
, where X is the design matrix of fixed effects and Z is a design matrix of random effects (typically an incidence matrix with 0s and 1s, but not necessarily). Models are fitted by an iterative algorithm alternating estimation of fixed effects and of dispersion parameters. The residual dispersion may follow a “structured-dispersion model” modeling heteroscedasticity.
Estimation of the latter parameters is performed by a form of fit of debiased residuals, which allows fitting a structured-dispersion model (Smyth et al. 2001). However, evaluation of the debiased residuals can be slow in particular for large datasets. For models without structured dispersion, it is then worth using the fitme
function (or the corrHLfit
function with non-default arguments). These functions can optimize the likelihood of HLfit
fits for different given values of the dispersion parameters (“outer optimization”), thereby avoiding the need to estimate debiased residuals.
HLfit(formula, data, family = gaussian(), rand.family = gaussian(), resid.model = ~1, REMLformula = NULL, verbose = c(trace = FALSE), HLmethod = "HL(1,1)", method="REML", control.HLfit = list(), control.glm = list(), init.HLfit = list(), ranFix = list(), etaFix = list(), prior.weights = NULL, processed = NULL) ## see 'rand.family' argument for inverse.Gamma
formula |
A |
data |
A data frame containing the variables named in the model formula. |
family |
A |
rand.family |
A |
resid.model |
Either a formula (without left-hand side) for the dispersion parameter
and additional possible elements (all named as |
REMLformula |
A model |
verbose |
A vector of booleans. The |
method |
Character: the fitting method.
allowed values are |
HLmethod |
Same as |
control.HLfit |
A list of parameters controlling the fitting algorithms, which should be ignored in routine use. Suche a parameter, Possible parameters are:
|
control.glm |
List of parameters controlling GLM fits, passed to |
init.HLfit |
A list of initial values for the iterative algorithm, with possible elements of the list are
|
ranFix |
A list of fixed values of random effect parameters. See |
etaFix |
A list of given values of the coefficients of the linear predictor. See |
prior.weights |
An optional vector of prior weights as in |
processed |
A list of preprocessed arguments, for programming purposes only (as in |
I. Approximations of likelihood: see method
.
II. Possible structure of Random effects: see random-effects
, but note that HLfit
does not fit models with autocorrelated random effects).
III. The standard errors reported may sometimes be misleading. For each set of parameters among β, λ, and φ parameters these are computed assuming that the other parameters are known without error. This is why they are labelled Cond. SE
(conditional standard error). This is most uninformative in the unusual case where λ and φ are not separately estimable parameters. Further, the SEs for λ and φ are rough approximations as discussed in particular by Smyth et al. (2001; V_1 method).
IV. prior weights. This controls the likelihood analysis of heteroscedastic models. In particular, changing the weights by a constant factor f should, and will, yield a fit with unchanged likelihood and (Intercept) estimates of phi
also increased by f (except if a non-trivial resid.formula
with log link is used). This is consistent with what glm
does, but other packages may not follow this logic (whatever their documentation may say: check by yourself by changing the weights by a constant factor).
An object of class HLfit
, which is a list with many elements, not all of which are documented.
A few extractor functions are available (see extractors
),
and should be used as far as possible as they should be backward-compatible from version 1.4 onwards, while the structure of the return object may still evolve. The following information will be useful for extracting further elements of the object.
Elements include descriptors of the fit:
eta |
Fitted values on the linear scale (including the predicted random effects); |
fv |
Fitted values (μ=<inverse-link>(η)) of the response variable (returned by the |
fixef |
The fixed effects coefficients, β (returned by the |
v_h |
The random effects on the linear scale, v, with atttribute the random effects u (returned by |
phi |
The residual variance φ; |
phi.object |
A possibly more complex object describing φ; |
lambda |
The random-effect (u) variance(s) λ in compact form; |
lambda.object |
A possibly more complex object describing λ; |
corrPars |
Agglomerates information on correlation parameters, either fixed, or estimated by |
APHLs |
A list which elements are various likelihood components, include conditional likelihood, h-likelihood, and the two adjusted profile h-likelihoods: the (approximate) marginal likelihood |
|
The covariance matrix of β estimates is not included as such, but can be extracted by |
Information about the input is contained in output elements named as HLfit
or corrHLfit
arguments (data,family,resid.family,ranFix,prior.weights
), with the following notable exceptions or modifications:
predictor |
The |
resid.predictor |
Analogous to |
rand.families |
corresponding to the |
Further miscellaneous diagnostics and descriptors of model structure:
X.pv |
The design matrix for fixed effects; |
ZAlist,strucList |
Two lists of matrices, respectively the design matrices “Z”, and the “L” matrices, for the different random-effect terms. The extractor |
BinomialDen |
(binomial data only) the binomial denominators; |
y |
the response vector; for binomial data, the frequency response. |
models |
Additional information on model structure for η, λ and φ; |
HL |
A set of indices that characterize the approximations used for likelihood; |
leve_phi,lev_lambda |
Leverages; |
dfs |
degrees of freedom for different components of the model; |
warnings |
A list of warnings for events that may have occurred during the fit. |
Finally, the object includes programming tools: call, spaMM.version, fit_time
and envir
.
Lee, Y., Nelder, J. A. (2001) Hierarchical generalised linear models: A synthesis of generalised linear models, random-effect models and structured dispersions. Biometrika 88, 987-1006.
Lee, Y., Nelder, J. A. and Pawitan, Y. (2006). Generalized linear models with random effects: unified analysis via h-likelihood. Chapman & Hall: London.
Smyth GK, Huele AF, Verbyla AP (2001). Exact and approximate REML for heteroscedastic regression. Statistical Modelling 1, 161-175.
data("wafers") ## Gamma GLMM with log link HLfit(y ~ X1+X2+X1*X3+X2*X3+I(X2^2)+(1|batch), family=Gamma(log), resid.model = ~ X3+I(X3^2) ,data=wafers) ## Gamma - inverseGamma HGLM with log link HLfit(y ~ X1+X2+X1*X3+X2*X3+I(X2^2)+(1|batch), family=Gamma(log), rand.family=inverse.Gamma(log), resid.model = ~ X3+I(X3^2) , data=wafers)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.