Try this:

1)
anova(myModels[[1]],myModels[[2]])

2)
do.call(anova, myModels)

On Sat, Sep 5, 2009 at 5:18 PM, Jeroen Ooms <j.c.l.ooms@uu.nl> wrote:

>
> I have a list object, in which I have stored n lme4-models. For example:
>
> library(lme4);
> myModels <- list();
> myModels[1] <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy)
> myModels[2] <- lmer(Reaction ~ Days + (1|Subject) + (0+Days|Subject),
> sleepstudy)
>
> Now I would like to perform an anova over all models in the list. However,
> the anova function requires that every model is inserted as a seperate
> argument, i.e. anova(model1,model2). I run into two problems:
> 1) anova(myModels[1],myModels[2]) returns an error.
> 2) if n, the number of models, is unknown, how do I add all models as a
> seperate argument?
>
>
>
> -----
> Jeroen Ooms * Dept. of Methodology and Statistics * Utrecht University
>
> Visit  http://www.jeroenooms.com www.jeroenooms.com  to explore some of my
> current projects.
>
>
>
>
>
>
> --
> View this message in context:
> http://www.nabble.com/Anova-over-a-list-of-models-tp25311985p25311985.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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

	[[alternative HTML version deleted]]


