# Example from Burnham and Anderson (2002), page 100:
data(Cement)
fm1 <- lm(y ~ ., data = Cement)
(ms1 <- dredge(fm1))
#models with delta.aicc < 4
summary(model.avg(get.models(ms1, subset = delta < 4))) # get averaged coefficients
#or as a 95\% confidence set:
confset.95p <- get.models(ms1, cumsum(weight) <= .95)
avgmod.95p <- model.avg(confset.95p) # get averaged coefficients
confint(avgmod.95p)
# The same result
model.avg(ms1, cumsum(weight) <= .95)
# 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