##### Citations
Title Text Both

## Repeated measures ANOVA

In some experiments the measurements are made a number of times on same subjects. Different subjects are likely to have similar measurements on repeat testing. Hence, subject factor has to be taken into account. This is done by mixed effect analysis of variance.

If in an experiment, subjects are fed with 3 different diets and blood levels of a chemical are checked at 3 times after each diet, the data can be tabulated as follows:

Code:

> mydata
animal diet     time value
1    1       t1     5
2    1       t1     6
3    1       t1     5
4    2       t1     6
5    2       t1     5
6    2       t1     4
7    3       t1     5
8    3       t1     5
9    3       t1     4
1    1       t2     6
2    1       t2     8
3    1       t2     7
4    2       t2     9
5    2       t2     6
6    2       t2     4
7    3       t2     8
8    3       t2     5
9    3       t2     6
1    1       t3     9
2    1       t3     6
3    1       t3     8
4    2       t3     7
5    2       t3     8
6    2       t3     9
7    3       t3     6
8    3       t3     5
9    3       t3     8

The analysis can be done using packages lme4 and lmerTest :

Code:

> library(lme4)
> library(lmerTest)
> summary(lmer(value~diet*time+(1|animal), data=mydata))
Linear mixed model fit by REML
t-tests use  Satterthwaite approximations to degrees of freedom ['merModLmerTest']
Formula: value ~ diet * time + (1 | animal)
Data: mm

REML criterion at convergence: 83

Scaled residuals:
Min      1Q  Median      3Q     Max
-1.9458 -0.5076  0.0000  0.6345  1.8612

Random effects:
Groups   Name        Variance Std.Dev.
animal   (Intercept) 0.000    0.000
Residual             1.725    1.313
Number of obs: 27, groups:  animal, 9

Fixed effects:
Estimate  Std. Error   df  t value   Pr(>|t|)
(Intercept)  5.667  1.158 21.000   4.892    0.000 ***
diet        -0.333  0.536 21.000  -0.622    0.5408
timet2       1.555  1.638 21.000   0.950    0.3531
timet3       2.999  1.638 21.000   1.831    0.0813 .
diet:timet2  0.000  0.758 21.000   0.000    1.0000
diet:timet3 -0.333  0.758 21.000  -0.440    0.6647
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Correlation of Fixed Effects:
(Intr) diet   timet2 timet3 dt:tm2
diet        -0.926
timet2      -0.707  0.655
timet3      -0.707  0.655  0.500
diet:timet2  0.655 -0.707 -0.926 -0.463
diet:timet3  0.655 -0.707 -0.463 -0.926  0.500