9
$\begingroup$

I have been asked to analyse some data from a clinical trial looking a two methods of measuring blood pressure. I have data from 50 subjects, each with between 2 and 57 measures using each method.

I'm wondering how best to proceed.

Obviously I need a solution that will account for the fact the measure of blood pressure is paired (two methods measured contemporaneously) and also a time varying covariate (with a varying number of observations per patient) as well as account for intra- and inter-patient variablility.

I was thinking of somehow shoe-horning this into repeated measures ANOVA, but I'm thinking it might need to be a mixed model approch.

I'd appreciate any helpful advice you could offer.

I'm a complete R newbie but very excited to develop skills and I have a moderate experience in Stata so could always fall back on that.

$\endgroup$

2 Answers 2

12
$\begingroup$

I don't think you can easily do what you want to do with RM-ANOVA since number of the repetitions are not the same for all subjects. Running mixed-effects models is very easy in R. In fact, by investing a little time to learn the fundamentals and the commands, it will open a lot of possibilities to you. I also find mixed-modeling much simpler to use and more flexible and almost never need to do RM-ANOVA directly. Finally, consider that with mixed modeling you can also account for the covariance structure of the residuals (RM-ANOVA simply assumes a diagonal structure) which can be important for many applications.

There are two main packages for linear mixed modeling in R: nlme and lme4. The lme4 packages is the more modern one which is great for large datasets and also for the cases you deal with clustered data. Nlme is the older package and is mostly deprecated in favor of lme4. However, for repeated measures designs it is still better than lme4 since only nlme allows you to model the covariance structure of the residuals. The basic syntax of nlme is very simple. For example:

fit.1 <- lme(dv ~ x + t, random=~1|subject, cor=corCompSymm())

Here I'm modeling the relationship between a dependent variable dv and a factor x and time-related covariate t. Subject is a random effect and I have used a compound symmetry structure for the covariance of the residuals. Now you can easily get the infamous p-values by:

anova(fit.1)

Finally, I can suggest you to read more about nlme using its definitive reference guide, Mixed Effects Models in S and S-Plus. Another good reference for beginners is Linear Mixed Models - a Practical Guide Using Statistical Software which compiles lots of examples of different applications of mixed modeling with code in R, SAS, SPSS, etc.

$\endgroup$
4
  • 1
    $\begingroup$ another good introductory reference is Gelman and Hill, Data Analysis Using Regression and Multilevel/Hierarchical Models $\endgroup$
    – wolf.rauch
    Jul 7, 2011 at 18:52
  • $\begingroup$ Thanks Alef - those two references are awesome - as is Wolf's above. I'm wondering if I can extend my question slightly in terms of how to structure the model. I can't seem to identify the dv!! I have two sets of BP measurement (two methods) as well as patient id and time of observation. How can I model the difference between the two BP measurements (analogous to a one sample t-test that difference = 0)?? Sorry to hound you - I'll get on with my reading now! $\endgroup$
    – Sam
    Jul 8, 2011 at 4:38
  • $\begingroup$ Don't worry everyone - I think I've figured it out!!! I had my data in the wrong format. When I finally figured out and manipulated it into long format, all of these posts made much more sense!! Thanks again all. $\endgroup$
    – Sam
    Jul 8, 2011 at 6:44
  • $\begingroup$ Glad you figured it out. It seems that as a general rule, most packages in R work with data in long format. $\endgroup$
    – AlefSin
    Jul 8, 2011 at 8:00
1
$\begingroup$

If you are looking for RM-ANOVA with mixed model by using R. You might want to check this out http://blog.gribblelab.org/2009/03/09/repeated-measures-anova-using-r/ There are great examples to demonstrate how to use mixed model to accomplish the RM-ANOVA.

Based on my experience, SAS is a better tool to deal with the mixed model. If you are using SAS, you could check the SAS help "Proc Mixed" for RM-ANOVA.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.