Learn R Programming

MuMIn (version 1.7.0)

model.avg: Model averaging

Description

Model averaging based on an information criterion.

Usage

model.avg(object, ..., revised.var = TRUE)

## S3 method for class 'default': model.avg(object, ..., beta = FALSE, rank = NULL, rank.args = NULL, revised.var = TRUE, dispersion = NULL)

## S3 method for class 'model.selection': model.avg(object, subset, fit = FALSE, ..., revised.var = TRUE)

Arguments

Value

  • An object of class averaging is a list with components:
  • summarya data.frame with log-likelihood, IC, Delta(IC) and Akaike weights for the component models.
  • coef.shrinkagea vector of full model-averaged coefficients, see Note.
  • coefArrayan array of component models' coefficients, their standard errors, and degrees of freedom.
  • term.codesnames of the terms with numerical codes used in the summary.
  • avg.modelthe model averaged parameters. A data.frame containing averaged coefficients, unconditional standard error, adjusted SE (if dfs are available) and z-values (coefficient and SE) and significance (assuming a normal error distribution).
  • importancerelative importance of the predictor variables (including interactions), calculated as a sum of the Akaike weights over all of the models in which the parameter of interest appears.
  • term.namescharacter vector giving names of all terms in the model.
  • x, formulathe model matrix and formula corresponding to the one that would be used in a single model. formula contains only the averaged coefficients.
  • residualsmodel averaged residuals (response minus fitted values).
  • callthe matched call.
  • In addition, the object has following attributes:
  • modelLista list of component model objects.
  • betalogical, were standardized coefficients used?
  • revised.varif TRUE, the standard errors were calculated with the revised formula (See par.avg).

encoding

utf-8

Details

model.avg is knowns to work with the fitted objects produced by the following modelling functions: lm, glm; gam, gamm (mgcv); gamm4 (gamm4); lme, gls (nlme); lmer (lme4); rlm, glm.nb, polr (MASS); multinom (nnet); sarlm, spautolm (spdep); glmmML (glmmML); coxph, survreg (survival); coxme, lmekin (coxme); and models within the class unmarkedFit (unmarked). Other classes are also likely to be supported, in particular those inheriting from one of the above classes.

model.avg may be used either with a list of models, or directly with a model.selection object (e.g. returned by dredge). In the latter case, the models from the model selection table are not evaluated unless the argument fit is set to TRUE or some additional arguments are present (such as rank or dispersion). This results in much faster calculation, but has certain drawbacks, because the fitted component model objects are not stored, and some methods (e.g. predict, fitted, model.matrix or vcov) would not be available with the returned object. Otherwise, get.models is called prior to averaging, and ...are passed to it.

rank is found by a call to match.fun and typically is specified as a function or a symbol (e.g. a back-quoted name) or a character string specifying a function to be searched for from the environment of the call to lapply. rank must be a function able to accept model as a first argument and must always return a scalar.

Several standard methods for fitted model objects exist for class averaging, including summary, predict, coef, confint, formula, residuals, vcov. The coef method a accepts argument full, if set to TRUE the full model-averaged coefficients are returned, rather than subset-averaged ones. logLik returns a list of logLik objects for the component models.

References

Burnham, K. P. and Anderson, D. R (2002) Model selection and multimodel inference: a practical information-theoretic approach. 2nd ed. New York, Springer-Verlag.

See Also

See par.avg for more details of model averaged parameter calculation.

Vignette Extending MuMIn's functionality demonstrates how to provide support for other types of models.

dredge, get.models AICc has examples of averaging models fitted by REML.

modavg in package AICcmodavg, and coef.glmulti in package glmulti also perform model averaging.

Examples

Run this code
# Example from Burnham and Anderson (2002), page 100:
library(MuMIn)
data(Cement)
fm1 <- lm(y ~ ., data = Cement)
(ms1 <- dredge(fm1))

#models with delta.aicc < 4
summary(model.avg(ms1, subset = delta < 4))

#or as a 95\% confidence set:
avgmod.95p <- model.avg(ms1, cumsum(weight) <= .95)
confint(avgmod.95p)

# The same result, but re-fitting the models via 'get.models'
confset.95p <- get.models(ms1, cumsum(weight) <= .95)
model.avg(confset.95p)

# Force re-fitting the component models
model.avg(ms1, cumsum(weight) <= .95, fit = TRUE)
# Models are also fitted if additional arguments are given
model.avg(ms1, cumsum(weight) <= .95, rank = "AIC")

# using BIC (Schwarz's Bayesian criterion) to rank the models
BIC <- function(x) AIC(x, k = log(length(residuals(x))))
model.avg(confset.95p, rank = BIC)
# the same result, using AIC directly, with argument k
# 'x' in a quoted 'rank' argument is substituted with a model object
# (in this case it does not make much sense as the number of observations is
# common to all models)
model.avg(confset.95p, rank = AIC, rank.args = alist(k = log(length(residuals(x)))))

Run the code above in your browser using DataLab