Learn R Programming

MuMIn (version 1.7.0)

subset.model.selection: Subsetting model selection table

Description

Return subsets of a model selection table returned by dredge.

Usage

## S3 method for class 'model.selection':
subset(x, subset, select, recalc.weights = TRUE, ...)
## S3 method for class 'model.selection':
[(x, i, j, recalc.weights = TRUE, ...)

Arguments

Value

  • A model.selection object containing only the selected models (rows). When columns are selected (arguments select or j are provided), a plain data.frame is returned.

encoding

utf-8

See Also

dredge, subset and [.data.frame for subsetting and extracting from data.frames.

Examples

Run this code
data(Cement)
fm1 <- lm(formula = y ~ X1 + X2 + X3 + X4, data = Cement)

# generate models where each variable is included only if the previous
# are included too, e.g. X2 only if X1 is there, and X3 only if X2 and X1
dredge(fm1, subset = (!X2 | X1) & (!X3 | X2) & (!X4 | X3))

# alternatively, generate "all possible" combinations
ms0 <- dredge(fm1)
# ...and afterwards select the subset of models
subset(ms0, (has(!X2) | has(X1)) & (has(!X3) | has(X2)) & (has(!X4) | has(X3)))
# this way the expression may be more clear
subset(ms0, has(X1, X2, X3, X4) | has(X1, X2, X3) | has(X1, X2) | has(X1)
    | (df == 2))

# Different ways of finding a confidence set of models:
# delta(AIC) cutoff
subset(ms0, delta <= 4, recalc.weights = FALSE)
# cumulative sum of Akaike weights
subset(ms0, cumsum(weight) <= .95, recalc.weights = FALSE)
# relative likelihood
subset(ms0, (weight / weight[1]) > (1/8), recalc.weights = FALSE)

Run the code above in your browser using DataLab