- 今、検出したいのは、個人のばらばらを考慮した上で、groupごとに時間経過での違いがあること(Withinのgroup:time項が有意であること)
> demo3 <- read.csv("http://www.ats.ucla.edu/stat/data/demo3.csv")
>
> demo3 <- within(demo3, {
+ group <- factor(group)
+ time <- factor(time)
+ id <- factor(id)
+ })
>
> par(cex = .6)
>
> with(demo3, interaction.plot(time, group, pulse,
+ ylim = c(10, 60), lty = c(1, 12), lwd = 3,
+ ylab = "mean of pulse", xlab = "time", trace.label = "group"))
>
> demo3.aov <- aov(pulse ~ group * time + Error(id), data = demo3)
> summary(demo3.aov)
Error: id
Df Sum Sq Mean Sq F value Pr(>F)
group 1 2035.0 2035.0 343.1 1.6e-06 ***
Residuals 6 35.6 5.9
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Error: Within
Df Sum Sq Mean Sq F value Pr(>F)
time 2 2830.3 1415.2 553.8 1.52e-12 ***
group:time 2 200.3 100.2 39.2 5.47e-06 ***
Residuals 12 30.7 2.6
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1
> demo4 <- read.csv("http://www.ats.ucla.edu/stat/data/demo4.csv")
>
> demo4 <- within(demo4, {
+ group <- factor(group)
+ time <- factor(time)
+ id <- factor(id)
+ })
> par(cex = .6)
>
> with(demo4, interaction.plot(time, group, pulse,
+ ylim = c(10, 60), lty = c(1, 12), lwd = 3,
+ ylab = "mean of pulse", xlab = "time", trace.label = "group"))
>
> demo4.aov <- aov(pulse ~ group * time + Error(id), data = demo4)
> summary(demo4.aov)
Error: id
Df Sum Sq Mean Sq F value Pr(>F)
group 1 2542.0 2542 629 2.65e-07 ***
Residuals 6 24.3 4
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Error: Within
Df Sum Sq Mean Sq F value Pr(>F)
time 2 1 0.5 0.079 0.925
group:time 2 1736 868.2 137.079 5.44e-09 ***
Residuals 12 76 6.3
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1