Working with lists of models gets stranger. I've actually found that, with lmer objects in a list, as long as I use them such as in the following example
all.models<-c(my.lmer, my.lmer2) summary(all.models[[1]]) Everything is fine. However, if, instead, I had lm objects or glm objects, the same summary command would merely give me the summary of a list of coefficients, not a lm or glm summary. I'm guessing this is an S3 versus S4 problem, and, honestly, I haven't had to deal with such issues before. If you have any advice, it would be much appreciated, as this could be quite a useful function. Also, I see your issue on the AIC for multilevel models. Indeed, effective number of parameters is rather vexing. I'm guessing that this measure could be computer for lmer objects fairly easily (he says with the anticipation of egg on his face) - perhaps checking for the object type and then selectively using one AIC or the other might be the way to go. > > 2) I'm repeatedly getting the error > > Error in UseMethod("logLik") : no applicable method for "logLik" > > in a variety of different contexts. The first is if I have to get > an AIC for an lmer object. AIC(my.lmer) give me the error above. > However, I can circumvent this with a very silly solution - > > myAIC<-function(object) {a<-logLik(object) > return(-2*a[1] +2*attr(a, 'df'))} > > I use this, and I do not get an error. > This may (?) be related to the NEWS item for R 2.6.2 RC: o The AIC() S4 generic in package stats4 no longer disables dispatch of S3 methods for AIC(). > 3) I do, however, get the above error if I have a vector of model > objects. So, again, if I have something like model.list<-c(my.lm, > my.lmer) or even just c(my.lm, my.lm2) and then call the following on > the vector of models > > aiclist<-vector > for(index in 1:length(model.list)){ > aiclist<-c(aiclist, myAIC(model.list[index])) > } > > it again yields the Error in UseMethod("logLik"). Given that this is > true either for lm, glm, or lmer objects, I'm guessing there's a more > general issue here that I'm missing. Any pointers? > -- View this message in context: http://www.nabble.com/extracting-AIC-scores-from-lmer-and-other-objects-tp15280858p15306183.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@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.