[R-sig-ME] anova
Douglas Bates
bates at stat.wisc.edu
Wed Jun 6 22:35:36 CEST 2007
On 6/6/07, Cougar <Cougar_711 at msn.com> wrote:
> I wonder if it is possible to nest a generalized least squares model within
> an lmer model for the purpose of testing the hypothesis that sigma.sq_beta_0
> = 0.
>
> Example: R 2.5.0, WinXP
>
> >library(lme4)
> >data(sleepstudy)
> >library(nlme)
> >m0 <- gls(Reaction ~ Days, sleepstudy)
> >m1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy)
> >anova(m0,m1)
It is supposed to work is you use lm, not gls. However, it doesn't.
I am reminded of one of my favorite quotes that "In theory, theory and
practice are the same. In practice they're not.".
> library(lme4)
Loading required package: Matrix
Loading required package: lattice
> fm1 <- lm(Reaction ~ Days, sleepstudy)
> fm2 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy)
> anova(fm2, fm1)
Error in FUN(X[[1L]], ...) :
no slot of name "call" for this object of class "lm"
I need to be a bit more careful in the code to get this to work but I
will do so.
>
> I do not get any result from the anova. I assume it is because the model
> objects are of different classes. Is that correct?
>
> Respectfully,
>
> Frank Lawrence
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
More information about the R-sig-mixed-models
mailing list