3
$\begingroup$

Suppose I wish to assess reaction time of individuals before and after treatment, using R code.

Now to analyse the results if I had additional treatments, I could use repeated measurements ANOVA in R, using the aov() function. These approaches however assume that there is only one measurement of reaction time per person, per treatment.

However suppose that for each individual, we measure their reaction time 5 times before treatment and 5 times after treatment. How should I adjust the t-test or repeated measurements ANOVA to account for this?

I know I could simply average prior to analysis, but is it also possible to include all the 5 trials in the analysis in R and if so how ?

Note the data might look something like this:

Subject Treatment Time     Result
Subj1   Coke      Morning  15 
Subj1   Coke      Morning  14
Subj1   Water     Morning  17
Subj1   Water     Morning  20
Subj2   Coke      Morning  45
Subj2   Coke      Morning  46
Subj2   Water     Morning  58
Subj2   Water     Morning  75
$\endgroup$
3
  • $\begingroup$ I am thinking of possibly doing a randomized block design, and treating each of the 5 trials as blocks. Is this approach statistically sound? $\endgroup$
    – Kenshin
    Commented Apr 7, 2014 at 2:07
  • $\begingroup$ Or can I simply have multiple rows in R with the same subject-treatment combination. Will this be handled correctly with the aov() or lm() function? $\endgroup$
    – Kenshin
    Commented Apr 8, 2014 at 7:08
  • $\begingroup$ Hey Mew, what is the problem with my answer? It answers your questions. The thing is it is not working with just aov, you need something else. $\endgroup$
    – Henrik
    Commented Apr 15, 2014 at 8:13

1 Answer 1

7
+50
$\begingroup$

Time to shine for afex (full disclosure: I am the author).

There are two options on what to do:

  1. As you said, use standard repeated measures ANOVA and aggregate over the measurements. afex offers a bunch of convenience functions automatically aggregating the data, e.g.,
    aov.car(Result ~ 1 + Error(Subj/Treatment*Time), data)
  2. Alternatively, you can use a linear mixed model which use all data points (i.e., data will not be aggregated) and use mixed which fits those via lme4::lmer and obtains p-values via pbkrtest::KRmodcomp:
    mixed(Result ~ Treatment*Time + (Treatment*Time|Subj), data

Note, both examples assume that Time has more than one level. IN case you use mixed models, it is a good idea to read something on them, see ?mixed for good starting points or search on CrossValidated.

$\endgroup$
1
  • $\begingroup$ Congratulations, I have awarded you the bounty. Thanks for your help Henrik. $\endgroup$
    – Kenshin
    Commented Apr 15, 2014 at 12:37

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.