Here is the problem I have (the figure below tries to depict the problem):

  1. There are two groups of patients - the BURN_GRP and the TVC_GRP, and all the patients are different (i.e. no patients in the BURN_GRP appear in the TVC_GRP and vice versa).
  2. The number of patients in each group is different, 125 vs. 219 (but I can randomly discard patients from the TVC_GRP in order to have the same number of patients in each group).
  3. Each patient has four measures of their SA_VAL taken over time (6 hours apart).
  4. I would like to test the hypothesis that the average SA_VAL of the patients in the BURN_GRP is statistically significantly different than the average SA_VAL of the patients in the TVC_GRP.

If there were no repeated measures I would perform a standard (non-paired) t-test. However, now that there are four (non-independent) measures for each patient I am unsure about how to proceed. I think it might be a repeated measure ANOVA. Is it? If so, how would I go about modeling it in R?

Drawing of the setup


1 Answer 1


There are two solutions here:

1.) If systematic differences between the four time-points are not expected or not of interest (simple replications): Just calculate the average SA_VAL for each subject and compare the resulting MEAN_SA_VALs between both groups using an unpaired t.test or wilcox.test (aka Mann-Whitney U). If you suspect/observe that variances differ between groups , use the var.equal = FALSE option of t.test. Simple as that.

2.) If there is the possibility that SA_VALs can change systematically over the course of the four measurements then you should definitely use a model that takes a potential main effects with time and more importantly interaction effects between time and group into account. This is a little complicated because R's aov function usually used for repeated-measures ANOVA is designed for balanced designs. But you should not discard data, since this only means a loss of valuable information and statistical power.

What you can do is to create a mixed model with functions lme (nlme package), or lmer (lme4 package) and then run an ANOVA. The model should look like this:

model1 <- lmer(SA_VAL ~ time+group+time:group+(1+time|subject),data=df)

If the effects of time on SA_VAL are linear in both groups, you may use time as a continuous regressor (0,6,12,18). If you expect other effects of time, define time as a factor (factor(time)).

Bonus: The mixed model will even be able to handle subjects with missing data-points (missing at random). Malus: Working with mixed models can become quite involved, so you may require some reading. Btw: here you can find a lme/lmer example that matches your design very closely.

  • $\begingroup$ If there are systematic differences between the four time points, then what hypothesis is being tested? $\endgroup$ Dec 22, 2016 at 2:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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