Learn R Programming

MuMIn (version 0.13.3)

dredge: Evaluate "all possible" models

Description

Runs models with all possible combinations of the explanatory variables in the supplied model.

Usage

dredge(global.model, beta = FALSE, eval = TRUE, rank = "AICc",
	fixed = NULL, m.max = NA, subset, ...)

Arguments

global.model
a fitted global model object. Currently, it can be a lm, glm, gam, lme, lmer, sarlm or spautolm, but also other types are likely to work (unt
beta
logical should standardized coefficients be returned rather than normal ones?
eval
whether to evaluate and rank the models. If FALSE, a list of all possible model formulas is returned
rank
optional custom rank function (information criterion) to be used instead AICc, e.g. QAIC or BIC, See Details
fixed
optional, either a single sided formula or a character vector giving names of terms to be included in all models
m.max
optional, maximum number of terms to be included in single model, defaults to the number of terms in global.model
subset
logical expression to put additional constraints for the set of models. Can contain any of the global.model terms. Run getAllTerms(global.model) to list all the terms. Complex expressions (e.g smooth functions in
...
optional arguments for the rank function. Any can be an expression (of mode call), in which case any x within it will be substituted with a current model.

Value

  • dredge returns an object of class model.selection, being a a data.frame with models' coefficients, k, deviance/RSS, R-squared, AIC, AICc, delta and weight. This depends on a type of model. Models are ordered according to AICc (lowest on top), or by rank function if specified. The attribute "formulas" is a list containing model formulas.

encoding

utf-8

Details

Models are run one by one by calling update with modified formula argument. This method, while robust in that it can be applied to a variety of different models, is not very efficient, so may be time (and memory) consuming. Handling interactions, dredge respects marginality constraints, so all possible combinations do not include models containing interactions without their respective main effects. rank is found by a call to match.fun and typically is specified as a function or a symbol (e.g. a backquoted name) or a character string specifying a function to be searched for from the environment of the call to lapply. Function rank must be able to accept model as a first argument and must always return a scalar.

References

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

See Also

get.models, model.avg. QAIC has examples of using custom rank function. There is also subset.model.selection method.

Examples

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

#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

#topmost model:
top.models[[1]]

# Examples of using 'subset':
# exclude models with with both X1 and X2
dredge(lm1, subset = !X1 | !X2)
# keep only models with X3
dredge(lm1, subset = X3)
# the same, but more effective:
dredge(lm1, fixed = ~ X3)

Run the code above in your browser using DataLab