# Mixed Factor Anova in R

Given is the following problem setting:

We split our subjects into two groups, where each group undergoes another kind of treatment (blocked or random). There are three measurements (Stages) for each subject of the dependent variable called "RE", at pretest, posttest and at retention. The treatment is given to the subjects after pretest and before posttest.

So some part of the data would look like:

Stage    Treatment   Radial Error
1   1   192.5538007
1   2   179.3135849
3   2   163.4928798
1   2   172.1848789
3   2   186.4486723
1   2   190.9450916
2   1   296.8551904
2   2   216.1953759
1   1   294.7580782


Now we want to test the following two hypothesis:

1. H1: After the treatment, the RE is bigger for the “randomized” group than for the “blocked” group

2. In the retentiontest the RE is smaller for the “randomized” group then for the “blocked” group

For 1. we first did the following: using anova to check that the RE values for pretest for the both groups are not significantly different.Then we simply used anova to compare the posttest RE values of the two groups and got a p-value of 0.043.

We are not sure if this approach is correct, also the supervisor has suggested a 2x3 factorial design (blocked, random)x(pretest,posttest, retentiontest) which we coded now as follows:

ret = aov(Radial.Error ~ Treatment*Stage, entire.data)

output:

Df Sum Sq Mean Sq F value   Pr(>F)
Treatment         1  10290   10290   3.699   0.0567 .
Stage             2  63363   31682  11.390 2.86e-05 ***
Treatment:Stage   2   1658     829   0.298   0.7428
Residuals       125 347705    2782
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
[1] "P Value: 0.0567154315196806"
> #post_ret = perform_aov(Avg.RE ~ TR, posttest)
> #combined = perform_aov(Avg.RE ~ TR, merged_data)
>
> TukeyHSD(anova_ret, which=c('Treatment', 'Stage'), conf.level=.95)
Tukey multiple comparisons of means
95% family-wise confidence level

Fit: aov(formula = formula, data = data_)

$Treatment diff lwr upr p adj 2-1 -17.84265 -36.20311 0.5178059 0.0567154$Stage
2-1 -43.6189874 -70.14635 -17.09163 0.0004557
3-1 -44.1817458 -70.70911 -17.65439 0.0003789
3-2  -0.5627584 -30.46738  29.34186 0.9989021


However, we are not sure if this suited for answering H1 or H2. Also, when we solely check for aov(Radial.Error ~ Treatment:Stage, entire.data), the result is very different than in the line above. Why is that so?

 Df Sum Sq Mean Sq F value   Pr(>F)
Treatment:Stage   5  75311   15062   5.415 0.000153 ***
Residuals       125 347705    2782
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
[1] "P Value: 0.000152626028849265"


## migrated from stackoverflow.comFeb 5 '15 at 16:18

This question came from our site for professional and enthusiast programmers.