Learn R Programming

MuMIn (version 1.3.6)

model.avg: Model averaging

Description

Model averaging based on an information criterion.

Usage

model.avg(object, ..., beta = FALSE, method = c("0", "NA"),
    rank = NULL, rank.args = NULL, revised.var = TRUE)

Arguments

object
A fitted model object or a list of such objects. Alternatively an object of class model.selection. See Details.
...
more fitted model objects
beta
Logical, should standardized coefficients be returned?
method
The method of averaging parameter estimators that are not common for all the models. Either "0" (default) or "NA". See Details.
rank
Optional, custom rank function (information criterion) to use instead of AICc, e.g. QAIC or BIC, may be omitted if object is a model list returned by get.models or a
rank.args
Optional list of arguments for the rank function. If one is an expression, an x within it is substituted with a current model.
revised.var
Logical, indicating whether to use revised formula for standard errors. See par.avg.

Value

  • An object of class averaging with following elements:
  • summarya data.frame with deviance, AICc, Delta and weights for the component models.
  • coefficients, variancematrices of component models' coefficients and their variances
  • variable.codesnames of the variables with numerical codes used in the summary
  • avg.modelthe averaged model summary, (data.frame containing averaged coefficients, unconditional standard error, adjusted SE, and confidence intervals)
  • importancethe relative importance of the predictor variables: calculated as a sum of the Akaike weights over all of the models in which the parameter of interest appears.
  • beta(logical) were standardized coefficients used?
  • term.namescharacter vector giving names of all terms in the model
  • residualsthe residuals (response minus fitted values).
  • x, formulathe model matrix and formula analogical to those that would be used in a single model.
  • methodhow the missing terms were handled ("NA" or "0").
  • callthe matched call.

encoding

utf-8

Details

model.avg has been tested to work with the following model classes:
  • lm,glm
  • gam(mgcv)
  • lme,gls(nlme)
  • lmer(lme4)
  • rlm,glm.nbpolr(MASS)
  • multinom(nnet)
  • sarlm,spautolm(spdep)
  • glmmML(glmmML)
  • coxph(survival)

model.avg may be used with a list of models, or an object returned by dredge. In the latter case, the models from the model selection table are evaluated (with a call to get.models) prior to averaging. A warning is given if the subset argument is not provided, and the default delta <= 4<="" code=""> will be used.

Other model types are also likely to be supported, in particular those inheriting from one of the above classes. See Details section of the Miscellaneous page to see how to provide support for other types of models.

With method = "0" (default) all predictors are averaged as if they were present in all models in the set, and the value of parameter estimate is taken to be 0 if it is not present in a particular model. If method = "NA", the predictors are averaged only over the models in which they appear.

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.

Some generic methods such as predict.averaging, coef, formula, residuals and vcov are supported. logLik method 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.

See Also

See par.avg for details of averaged model calculation.

dredge, get.models. QAIC has examples of using custom rank function and prediction with confidence intervals. 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
require(graphics)

# Example from Burnham and Anderson (2002), page 100:
data(Cement)
lm1 <- lm(y ~ ., data = Cement)
dd <- dredge(lm1)
dd

#models with delta.aicc < 4
model.avg(get.models(dd, subset = delta < 4)) # get averaged coefficients

#or as a 95\% confidence set:
top.models <- get.models(dd, cumsum(weight) <= .95)

model.avg(top.models) # get averaged coefficients
# The same result
model.avg(dd, cumsum(weight) <= .95)

# using BIC (Schwarz's Bayesian criterion) to rank the models
BIC <- function(x) AIC(x, k=log(length(residuals(x))))
mav <- model.avg(top.models, rank=BIC)

Run the code above in your browser using DataLab