Skip to content
Prev 165191 / 398506 Next

Akaike weight in R

I'm pretty sure you have to work it out yourself. Here is an example of how 
you would tabulate the AIC weights from three models (check that my 
calculations are correct before using this yourself!).

Basically model.name$aic will cut out the AIC values then write a formula to 
calculate the weights...

m1<-glm(trantot~unimpgrass+impgrass,family=poisson,data=bbs[bbs$species==unique(bbs$species)[1],])
m2<-glm(trantot~marginwidth,family=poisson,data=bbs[bbs$species==unique(bbs$species)[1],])
m3<-glm(trantot~impgrass,family=poisson,data=bbs[bbs$species==unique(bbs$species)[1],])
aics<-data.frame(paste("m",1:3,sep=""),c(m1$aic,m2$aic,m3$aic),row.names=NULL)
colnames(aics)<-c("model","AIC")
aics<-aics[order(-aics$AIC),]
for(i in 1:dim(aics)[1]){
aics$diff[i]<-aics$AIC[1]-aics$AIC[i]}
aics$wi<-2.71828182845904523536^(-0.5*aics$diff)
aics$aic.weights<-aics$wi/sum(aics$wi)

----- Original Message ----- 
From: "Odette Gaston" <odette.gaston at gmail.com>
To: <r-help at r-project.org>
Sent: Friday, December 19, 2008 11:26 AM
Subject: [R] Akaike weight in R