I have a slight conundrum.  I'm attempting to write a scrip that will  
take a number of objects (lm, glm, and lmer) and return AIC scores  
and weights.  I've run into 3 problems, and was wondering if anyone  
had any pointers.

1) is there any convenient way to extract the name of the objects?   
Simply, if I have a vector of objects c(my.lm, my.lmer) and I want to  
get a character vector c("my.lm", "my.lmer"), how would one do this?   
I see this as far simpler than jumping into the ugly details of each  
object type and extracting coefficient lists and such - not to  
mention tidier.

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.

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?

Thanks!

-Jarrett




----------------------------------------
Jarrett Byrnes
Population Biology Graduate Group, UC Davis
Bodega Marine Lab
707-875-1969
http://www-eve.ucdavis.edu/stachowicz/byrnes.shtml


        [[alternative HTML version deleted]]

______________________________________________
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.

Reply via email to