Sum of model weights over all models including each explanatory variable.

sw(x)
importance(x)

Arguments

x

either a list of fitted model objects, or a "model.selection" or "averaging" object.

Value

a named numeric vector of so called relative importance values, for each predictor variable.

Author

Kamil Bartoń

See also

Weights

dredge, model.avg, model.sel

Examples


# Generate some models
fm1 <- lm(y ~ ., data = Cement, na.action = na.fail)
ms1 <- dredge(fm1)
#> Fixed term is "(Intercept)"

# Sum of weights can be calculated/extracted from various objects:
sw(ms1)
#>                      X1   X2   X4   X3  
#> Sum of weights:      0.99 0.81 0.32 0.21
#> N containing models:    8    8    8    8
if (FALSE) { # \dontrun{
sw(subset(model.sel(ms1), delta <= 4))
sw(model.avg(ms1, subset = delta <= 4))
sw(subset(ms1, delta <= 4))
sw(get.models(ms1, delta <= 4))
} # }

# Re-evaluate SW according to BIC
# note that re-ranking involves fitting the models again

# 'nobs' is not used here for backwards compatibility
lognobs <- log(length(resid(fm1)))

sw(subset(model.sel(ms1, rank = AIC, rank.args = list(k = lognobs)),
    cumsum(weight) <= .95))
#> Re-fitting models...
#>                      X1   X2   X4   X3  
#> Sum of weights:      1.00 0.83 0.49 0.49
#> N containing models:    5    4    3    3

# This gives a different result than previous command, because 'subset' is
# applied to the original selection table that is ranked with 'AICc'
sw(model.avg(ms1, rank = AIC, rank.args = list(k = lognobs),
    subset = cumsum(weight) <= .95))
#>                      X1   X2   X4   X3  
#> Sum of weights:      1.00 0.94 0.37 0.30
#> N containing models:    4    3    2    1