Skip to contents

Calculate weighted Akaike Information Criterion scores

Usage

weighted.AIC(x);

Arguments

x

A vector of AIC values, must have greater than 2 elements

Value

A vector of weighted AIC values corresponding to the input.

Details

Weighted AIC values can be interpreted as the probability of each model being the best given the data and thet set of models being compared.

References

More information including formula for weighted AIC can be found in: Eric-Jan Wagenmakers and Simon Farrell. AIC model selection using Akaike weights. Psychonomic Bulletin and Review, 11(1):192-6, Feb 2004.

Author

Denise Mak

See also

Examples

set.seed(123456789);

# creating sample non-linear data
temp <- data.frame(x = 1:100);
temp$y <- temp$x^2-rnorm(100, 0, 500);

# fitting with different models
# linear model
fit1 <- lm(y~x, data = temp);
# quadratic model
fit2 <- lm(y~x + I(x^2), data = temp);
# logistic model
fit3 <- nls(y~SSlogis(x, Asym, xmid, scal), data = temp);

if (FALSE) {
# Example to visualize different fits
plot(temp);
lines(temp$x, predict(fit1), col = "blue")
lines(temp$x, predict(fit2), col = "red")
lines(temp$x, predict(fit3), col = "green")
}

# calculate AIC values (see stats::AIC for more information)
x <- AIC(fit1, fit2, fit3);

# quadratic model has the highest probability and the best fit
weighted.AIC(x$AIC);
#> [1] 3.008714e-27 9.819502e-01 1.804976e-02