[R] indexing model names for AICc table

Kingsford Jones kingsfordjones at gmail.com
Thu Feb 26 06:03:53 CET 2009


Aslo note there are a number of packages with functions producing
Burnham and Anderson style AIC tables: pgirmess, bbmle,
dRedging(off-CRAN), PKtools, ...


On Wed, Feb 25, 2009 at 4:58 PM, Mark Drever <mdrever at interchange.ubc.ca> wrote:
> hi folks,
>
> I'm trying to build a table that contains information about a series of
> General Linear Models in order to calculate Akaike weights and other
> measures to compare all models in the series.
>
> i have an issue with indexing models and extracting the information
> (loglikehood, AIC's, etc.) that I need to compile them into the table. Below
> is some sample code that illustrates my approach so far and my problem. I
> realize that somehow i need to provide actual object for the AIC or LogLik
> call, and I've tried a couple of different ideas (e.g., as.name,
> expression), but have come up empty.
>
> Thanks so much. Any help much appreciated.
> Mark.
>
> Sample code begins here....
>
> x1 <- rnorm(10,1,1)
> x2 <- rnorm(10,2,2)
> x3 <- rnorm(10,3,3)
> y <- x1*2 + x2*3 + x3*4 + rnorm(10,0,0.4)
>
> model1 <- lm(y ~ x1)
> model2 <- lm(y ~ x2)
> model3 <- lm(y ~ x3)
>
> aic.table <- data.frame(model.number = 1:3,  Log.lik = NA)
>
> for (i in 1:3)
> {
> aic.table$Log.lik[i] <- Loglik(paste("model",i,sep=""))[1]
> }
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>




More information about the R-help mailing list