| HLfit | R Documentation |
Fits GL(M)Ms as well as some hierarchical generalized linear models (HGLM; Lee and Nelder 2001). It may be called on its own but is now better seen as a backend for the main fitting function fitme (or fitmv for multivariate-response models),
On its own, 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). The residual dispersion may follow a “structured-dispersion model” modeling heteroscedasticity.
Models are fitted by an iterative algorithm alternating estimation of fixed effects and of dispersion parameters. Fitting structured-dispersion model is performed by a form of fit of corrected residuals (Smyth et al. 2001). These corrected residuals are also used to estimate a single \phi value. However, evaluation of the corrected residuals can be slow in particular for large datasets. Then, for model without structured dispersion, fitme should be faster.
HLfit(formula, data, family = gaussian(), rand.family = gaussian(),
resid.model = ~1, REMLformula = NULL, verbose = c(inner = FALSE),
HLmethod = "HL(1,1)", method="REML", control.HLfit = list(),
control.glm = list(), init.HLfit = list(), fixed=list(), ranFix,
etaFix = list(), prior.weights = NULL, weights.form = NULL,
processed = NULL)
formula |
A |
data |
A data frame containing the variables named in the model formula. |
family |
A |
rand.family |
A |
resid.model |
Used to specify a model for the dispersion parameter of the mean-response distribution family. See the |
REMLformula |
A model |
verbose |
A vector of booleans or integers. The |
method |
Character: the fitting method.
allowed values include The default is REML (standard REML for LMMs,
an extended definition for other models) but is overridden when called by |
HLmethod |
Alternative specification of |
control.HLfit |
A list of parameters controlling the fitting algorithms, which should mostly be ignored in routine use.
See |
control.glm |
List of parameters controlling calls to |
init.HLfit |
A list of initial values for the iterative algorithm, with possible elements of the list are
|
fixed, ranFix |
A list of fixed values of random effect parameters. |
etaFix |
A list of given values of the coefficients of the linear predictor. See |
prior.weights |
An optional vector of prior weights as in |
weights.form |
Specification of prior weights by a one-sided formula: use |
processed |
A list of preprocessed arguments, for programming purposes only. |
I. Approximations of likelihood: see method.
II. The standard errors reported may sometimes be misleading. For each set of parameters among \beta, \lambda, and \phi 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 \lambda and \phi are not separately estimable parameters. Further, the SEs for \lambda and \phi are rough approximations as discussed in particular by Smyth et al. (2001; V_1 method).
III. 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). Further, post-fit functions (in particular those extracting various forms of residuals) may be inconsistent in their handling of prior weights.
An object of class HLfit, which is a list with many elements, not all of which are documented.
Various extractor functions are available (see extractors, vcov, get_fittedPars, get_matrix, and so on). They should be used as far as possible as they should be backward-compatible from version 2.0.0 onwards, while the structure of the return object may still evolve. The following information may 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 ( |
fixef |
The fixed effects coefficients, |
v_h |
The random effects on the linear scale, |
phi |
The residual variance |
phi.object |
A possibly more complex object describing |
lambda |
The random-effect ( |
lambda.object |
A possibly more complex object describing |
ranef_info |
environment where information about the structure of random effects is stored (see |
corrPars |
Agglomerates information on correlation parameters, either fixed, or estimated ((see |
APHLs |
A list whose elements are various likelihood components, including conditional likelihood, h-likelihood, and the Laplace approximations: the (approximate) marginal likelihood |
The covariance matrix of \beta estimates is not included as such, but can be extracted by vcov.
Information about the input is contained in output elements named as arguments of the fitting function calls (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 (returned by the |
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 |
HL |
A set of indices that characterize the approximations used for likelihood; |
lev_phi, lev_lambda |
Leverages (see |
dfs |
list (possibly structured): some information about degrees of freedom for different components of the model. But its details may be difficult to interpret and the |
how |
A list containing the information properly extracted by the |
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 an environment envir that may contain whatever may be needed in some post-fit operations..
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.
Smyth GK, Huele AF, Verbyla AP (2001). Exact and approximate REML for heteroscedastic regression. Statistical Modelling 1, 161-175.
HLCor for estimation with given spatial correlation parameters;
corrHLfit for joint estimation with spatial correlation parameters;
fitme as a preferred alternative to all these functions.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.