Created
December 6, 2014 12:09
-
-
Save fdabl/7e363168a79b2fd87a28 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# models from p. 146 of | |
# http://www.uni-tuebingen.de//uni/sii/pw/heller/statistics_III_ws14/stat5www.pdf | |
# c(model1, model2, model3) | |
aic <- c(8128.519, 8249.935, 8163.826) | |
llh <- c(-4039.260, -4118.967, -4074.913) | |
params <- c(25, 6, 7) | |
# compute the relative distance of each model AIC to the | |
# model with the minimum AIC | |
rel <- sapply(aic, function(i) i - min(aic)) | |
fn <- function(r) exp(-r / 2) | |
normalizer <- sum(sapply(rel, fn)) | |
# compute the AIC weights for each model | |
weights <- sapply(rel, function(r) fn(r) / normalizer) | |
# evidence ratio of model 1 compared to model 3 is | |
comp1 <- weights[1] / weights[3] | |
# direct computation of the evidence ratio of AIC weights | |
# comparison of model 1 and 3 | |
comp2 <- exp(llh[1] - llh[3] + params[3] - params[1]) | |
# this is a little contrived, since model 1 is just sooo much better than model 3 | |
# in general, AIC weights provide a continuous measure of strength of evidence! | |
# for more, see http://ejwagenmakers.com/2004/aic.pdf and | |
# http://www.ejwagenmakers.com/inpress/VandekerckhoveEtAlinpress.pdf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment