反復測定一元配置分散分析をRでやってみる.
球面性の検定,MANOVA(多変量分散分析),自由度調整に対応.
被験者12人に3つの異なる課題を行った時の心拍数のデータ
課題の違いが心拍数に影響するかを検討した.
#元データ
> hr
A B C
1 68.40091 61.26944 69.14174
2 66.47348 67.87263 63.69999
3 58.74087 69.42453 67.74671
4 61.75985 62.73467 60.55499
5 68.97954 58.57950 64.70531
6 79.49035 74.09208 78.25809
7 76.98589 69.97854 67.97938
8 63.32686 60.01100 65.60218
9 52.84034 55.29806 50.57370
10 55.48193 58.09929 54.38332
11 66.81270 60.35373 65.01257
12 72.95453 69.15551 65.85730
>
#元データを並べる.
> hrBind<-cbind(hr[,1],hr[,2],hr[,3])
> hrBind
[,1] [,2] [,3]
[1,] 68.40091 61.26944 69.14174
[2,] 66.47348 67.87263 63.69999
[3,] 58.74087 69.42453 67.74671
[4,] 61.75985 62.73467 60.55499
[5,] 68.97954 58.57950 64.70531
[6,] 79.49035 74.09208 78.25809
[7,] 76.98589 69.97854 67.97938
[8,] 63.32686 60.01100 65.60218
[9,] 52.84034 55.29806 50.57370
[10,] 55.48193 58.09929 54.38332
[11,] 66.81270 60.35373 65.01257
[12,] 72.95453 69.15551 65.85730
#要因を作る
> taskFactor<-factor(c(1,2,3))
> taskFrame<-data.frame(taskFactor)
> taskFrame
taskFactor
1 1
2 2
3 3
#一般化線形モデルの適用
> hrModel<-lm(hrBind~1)
#パッケージcarの呼び出し
> library(car)
#ANOVA実行
> hrAnova<-Anova(hrModel,idata=taskFrame,idesign=~taskFactor)
Note: model has only an intercept; equivalent type-III tests substituted.
#結果の参照
> summary(hrAnova)
Type III Repeated Measures MANOVA Tests:
------------------------------------------
Term: (Intercept)
Response transformation matrix:
(Intercept)
[1,] 1
[2,] 1
[3,] 1
Sum of squares and products for the hypothesis:
(Intercept)
(Intercept) 453430.8
Sum of squares and products for error:
(Intercept)
(Intercept) 4142.154
Multivariate Tests: (Intercept)
Df test stat approx F num Df den Df Pr(>F)
Pillai 1 0.99095 1204.141 1 11 1.3654e-12 ***
Wilks 1 0.00905 1204.141 1 11 1.3654e-12 ***
Hotelling-Lawley 1 109.46740 1204.141 1 11 1.3654e-12 ***
Roy 1 109.46740 1204.141 1 11 1.3654e-12 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
------------------------------------------
Term: taskFactor
Response transformation matrix:
taskFactor1 taskFactor2
[1,] 1 0
[2,] 0 1
[3,] -1 -1
Sum of squares and products for the hypothesis:
taskFactor1 taskFactor2
taskFactor1 29.24055 -10.374834
taskFactor2 -10.37483 3.681093
Sum of squares and products for error:
taskFactor1 taskFactor2
taskFactor1 227.59494 44.51865
taskFactor2 44.51865 242.11934
Multivariate Tests: taskFactor
Df test stat approx F num Df den Df Pr(>F)
Pillai 1 0.1426825 0.8321452 2 10 0.46314
Wilks 1 0.8573175 0.8321452 2 10 0.46314
Hotelling-Lawley 1 0.1664290 0.8321452 2 10 0.46314
Roy 1 0.1664290 0.8321452 2 10 0.46314
Univariate Type III Repeated-Measures ANOVA Assuming Sphericity
SS num Df Error SS den Df F Pr(>F)
(Intercept) 151144 1 1380.72 11 1204.1414 1.365e-12 ***
taskFactor 29 2 283.46 22 1.1201 0.3442
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Mauchly Tests for Sphericity
Test statistic p-value
taskFactor 0.88151 0.53228
Greenhouse-Geisser and Huynh-Feldt Corrections
for Departure from Sphericity
GG eps Pr(>F[GG])
taskFactor 0.89406 0.3401
HF eps Pr(>F[HF])
taskFactor 1.0561 0.3442
警告メッセージ:
In summary.Anova.mlm(hrAnova) : HF eps > 1 treated as 1
>
コメント