[R] Some questions on repeated measures (M)ANOVA & mixed models with lme4
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Sun May 13 18:26:51 CEST 2007
Marco B wrote:
> Dear R Masters,
>
> I'm an anesthesiology resident trying to make his way through basic
> statistics. Recently I have been confronted with longitudinal data in
> a treatment vs. control analysis. My dataframe is in the form of:
>
> subj | group | baseline | time | outcome (long)
> or
> subj | group | baseline | time1 |...| time6 | (wide)
>
> The measured variable is a continuous one. The null hypothesis in this
> analysis is that the Group factor does not significantly influence the
> outcome variable. A secondary null hypothesis is that the Group x Time
> interaction is not significant, either. Visual of the group means
> indicates the outcome measure decreases linearly (more or less) over
> time from baseline values. The time==1...time==6 intervals are
> equally-spaced and we have equal sample sizes for the groups.
>
> I've done a little reading around and found (at least) four possible approaches:
>
> A. Linear mixed model using lme4 with random intercept and slope with
> lmer() or lme()
>
> B. Repeated measures ANOVA using aov() with Error() stratification
> (found in Baron & Li, 2006), something along the lines of:
> aov(outcome ~ group * time + baseline + Error(subj+subj:time))
>
> (from: http://cran.r-project.org/doc/contrib/Baron-rpsych.pdf, p. 41)
>
> C. "Repeated measures" MANOVA as follows (using data in wide format):
> response <- cbind(time1,time2,time3,time4,time5,time6)
> mlmfit <- lm(response ~ group)
> mlmfit1 <- lm(response ~ 1)
> mlmfit0 <- lm(response ~ 0)
> # Test time*group effect
> anova.mlm(mlmfit, mlmfit1, X=~1, test="Spherical")
> # Test overall group effect
> anova.mlm(mlmfit, mlmfit1, M=~1)
> # Test overall time effect
> anova.mlm(mlmfit1, mlmfit0, X=~1, test="Spherical")
>
> (taken from http://tolstoy.newcastle.edu.au/R/help/05/11/15744.html)
>
> Now, on with the questions:
>
> 1. This is really a curiosity. I find lmer() easier to use than lme(),
> but the former does not allow the user to model the correlation
> structure of the data. I figure lmer() is presently assuming no
> within-group correlation for the data, which I guess is unlikely in my
> example. Is there a way to compare directly (maybe in terms of
> log-likelihood?) similar models fitted in lme() and lmer()?
>
> 2. Baron & Li suggest a painful (at least for me) procedure to obtain
> Greenhouse-Geisser or Huyn-Feldt correction for the ANOVA analysis
> they propose. Is there a package or function which simplifies the
> procedure?
>
They're also computed as part of the anova.mlm(...test="Spherical") route.
> 3. I must admit that I don't understand solution C. I can "hack" it to
> fit my model, and it seems to work, but I can't seem to grasp the
> overall concept, especially regarding the outer and/or inner
> projection matrices (M & X). Could anyone point me to a basic
> explanation of the procedure?
>
Something is en route to R News, I hope....
> 4. Provided the assumptions for ANOVA hold, or that deviations from
> them are not horrible, am I correct in saying that this procedure
> would be the most powerful one? How would you choose solution A over
> solution B (or viceversa)?
>
>
Aov, lmer, and anova.mlm with the Spherical option all fit essentially
the same model, but lmer has less fine control over small-sample
properties and the effect of departures from the assumptions (partly
because it needs to deal with unbalanced data).
Lme with an estimated covariance matrix is similar to anova.mlm without
assuming sphericity. They are often less powerful than the
sphericity-with-correction alternative, because of the larger number of
estimated parameters. The balance should shift in "large N, small p" cases.
> My sincerest gratitude to anyone who will take the time to answer my questions!
>
> Best Regards,
>
> Marco
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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