spaMM (version 2.1.6)

extractors: Functions to extract various components of a fit

Description

logLik extracts the log-likelihood (exact or approximated). get_any_IC and AIC.HLfit compute model selection/information criteria such as AIC. See AIC for more information about these criteria. dev_resids returns a vector of squared (unscaled) deviance residuals (the summands in McCullagh and Nelder 1989, p. 34). deviance returns the sum of squares of these (unscaled) deviance residuals, that is (consistently with stats::deviance) the unscaled deviance. fitted extracts fitted values (see fitted.values). residuals extracts residuals of the fit. fixef extracts the fixed effects coefficients, \(\beta\). ranef extracts the predicted random effects, Lv (default since version 1.12.0), or u (see Details in HLfit for definitions). vcov returns the variance-covariance matrix of the fixed-effects coefficients. Corr returns a correlation matrix of random effects. getDistMat extracts a distance matrix for a Mat<U+00E9>rn correlation model. get_ZALMatrix extracts the design matrix for the random effects \(v\). get_RLRTSim_args extracts a list of arguments suitable for calls to LRTSim::RLRTSim()

Usage

# S3 method for HLfit
logLik(object,which,...)
# S3 method for HLfit
fitted(object,...)
# S3 method for HLfit
fixef(object,...)
# S3 method for HLfit
ranef(object, type="correlated", ...)
# S3 method for HLfit
vcov(object,...)
# S3 method for HLfit
deviance(object,...)
# S3 method for HLfit
residuals(object, type = c("deviance", "pearson", "response"), ...)
getDistMat(object,scaled=FALSE)
Corr(object,...)
dev_resids(object,...)
get_any_IC(object, ..., verbose=interactive())
get_RLRTSim_args(object,...)
get_ZALMatrix(object,as_matrix)
# S3 method for HLfit
AIC(object, ..., k, verbose=interactive())

Arguments

object

The return object of an HLfit or similar function.

type

For ranef, use type="correlated" (default) to display the correlated random effects (Lv), whether in a spatial model, or a random- coefficient model. Use type="uncorrelated" to pretty-print the elements of the <object>$ranef vector (u). For residuals, the type of residuals which should be returned. The alternatives are: "deviance" (default), "pearson", and "response".

which

Which element of the APHLs list to return. The default depends on the fitting method.In particular, if it was REML or one of its variants, the function returns the log restricted likelihood (exact or approximated).

scaled

If FALSE, the function ignores the scale parameter \(rho\) and returns unscaled distance.

as_matrix

Boolean: whether to always return a matrix; otherwise as Matrix may be returned.

verbose

Whether to print the model selection criteria or not.

k

For AIC, unused by HLfit method, but included to conform to the generic.

Other arguments that may be needed by some method.

Value

Return values are numeric (for logLik), vectors (most cases), matrices (for vcov), matrices or dist objects (for getDistMat). ranef returns a vector with attributes, which inherits from class ranef which has its own (undocumented) print method.

Corr returns a list, for the different random effect terms, of unconditional correlation matrix of the random effects “v” (see Details of HLfit for definitions).

get_any_IC computes, optionally prints, and returns invisibly the following quantities. The conditional AIC (Vaida and Blanchard 2005) is a relative measure of quality of prediction of new realizations of a mixed model, conditional on the realized values of the random effects. It involves the conditional likelihood, and degrees of freedom for (i) estimated residual error parameters and (ii) the overall linear predictor characterized by the Effective degrees of freedom already discussed by previous authors including Lee and Nelder (2001), which gave a general formula for it in HGLMs. Both a plug-in “asymptotic” estimate of the conditional AIC and of this effective df are returned by get_any_IC. Note that these may be biased estimates of conditional AIC and effective df, and that more refined formulas are discussed in the literature (e.g. Overholser and Xu 2014), some of which may be implemented in future versions of get_any_IC. Lee et al. (2006) and Ha et al (2007) defined a corrected AIC [i.e., AIC(D*) in their eq. 7] which is here interpreted as the conditional AIC. Also returned are the marginal AIC (Akaike's classical AIC), and a focussed AIC for dispersion parameters (dispersion AIC) discussed by Ha et al (2007; eq.10). This diversity of criteria should encourage users to think twice before applying model selection automatically, which is no better although more fashionable than misuses of simple null hypothesis testing. Also, alternative procedures for model choice can be considered (e.g. Cox and Donnelly, 2011, p. 130-131).

get_RLRTSim_args extracts a list of arguments suitable for a call to LRTSim::RLRTSim() for a small-sample test of the presence of a random effect by an efficient simulation procedure. The test can be run by do.call("RLRTSim",<get_RLRTSim_args return value>).

Details

See residuals.glm for more information about the types of residuals.

References

Cox, D. R. and Donnelly C. A. (2011) Principles of Applied Statistics. Cambridge Univ. Press.

McCullagh, P. and Nelder J. A. (1989) Generalized linear models. Second ed. Chapman & Hall: London.

Ha, I. D., Lee, Y. and MacKenzie, G. (2007) Model selection for multi-component frailty models. Statistics in Medicine 26: 4790-4807.

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.

Overholser R., and Xu R. (2104) Effective degrees of freedom and its application to conditional AIC for linear mixed-effects models with correlated error structures. J. Multivariate Anal. 132: 160-170.

Vaida, F., and Blanchard, S. (2005) Conditional Akaike information for mixed-effects models. Biometrika 92, 351-370.

Examples

Run this code
# NOT RUN {
data(wafers)
m1 <- HLfit(y ~X1+X2+(1|batch),
          resid.model = ~ 1 ,data=wafers,HLmethod="ML")
get_any_IC(m1)          
fixef(m1)
vcov(m1)
ranef(m1)
# }

Run the code above in your browser using DataCamp Workspace