1
/
5

混合計画の分散分析

混合計画(混合モデルではない)の二元配置分散分析。要するに被験者間、被験者内計画。car packageでMANOVAで実行してみる。詳細は下記の通り。

> dat<-read.delim("clipboard") #データ読み込み
> head(dat) #データの冒頭部だけ見せるとこんな感じ.データの中身はこんな感じ.
  gender  trial1  trial2  trial3
1   male 10.0121 14.0931 15.8768
2   male 16.1474 15.9080 20.8417
3   male 57.0574 47.2407 75.4579
4   male 24.4516 27.1586 28.2324
5   male 24.4516 27.1586 28.2324
6   male 15.5521 16.7581 20.1324
>  #genderはmaleとfemaleがある(ここにはmaleしか出てないけどね…).反復測定したデータがtrial1~3
>  #carパッケージで反復測定するときは横に被験者内データ(反復測定データ),縦に被験者間データが来る.

> dat$factgender<-factor(dat$gender) #今度は読み込んだデータに被験者間要因で使用するデータを追加.これを分散分析のときの要因に使う.genderをそのまま使っちゃだめ.
> contrasts(dat$factgender)<-"contr.Sum" #おまじない(詳細は割愛,要するにカテゴリカルデータの変換のため.やらないとおかしくなっちゃう)
> head(dat)
  gender  trial1  trial2  trial3 factgender
1   male 10.0121 14.0931 15.8768       male
2   male 16.1474 15.9080 20.8417       male
3   male 57.0574 47.2407 75.4579       male
4   male 24.4516 27.1586 28.2324       male
5   male 24.4516 27.1586 28.2324       male
6   male 15.5521 16.7581 20.1324       male
> 
> trial<-factor(c("t1","t2","t3")) #被験者内要因を作成
> trial<-data.frame(trialdata=trial) #これは,carパッケージで分析するときに,被験者内要因との関連付けで使う.
> trial
  trialdata
1        t1
2        t2
3        t3
>
>
> model1<-lm(cbind(trial1,trial2,trial3)~factgender,data = dat) #まずはモデルをつくる.
> 
> 
> library(car) #carパッケージ読み込み
> anovamodel1<-Anova(model1,idata = trial,idesign = ~trialdata,type = "III") #carパッケージ読み込み タイプⅢで計算.
> summary(anovamodel1) #なお,Summaryの中は若干書き換えてあって数字はでたらめです.
Type III Repeated Measures MANOVA Tests:

------------------------------------------
 
Term: (Intercept) 

 Response transformation matrix:
       (Intercept)
trial1           1
trial2           1
trial3           1

Sum of squares and products for the hypothesis:
            (Intercept)
(Intercept)      296953

Multivariate Tests: (Intercept)
                 Df test stat approx F num Df den Df     Pr(>F)    
Pillai            1  0.869420 133.1632      1     20 2.7053e-10 ***
Wilks             1  0.130580 133.1632      1     20 2.7053e-10 ***
Hotelling-Lawley  1  6.658162 133.1632      1     20 2.7053e-10 ***
Roy               1  6.658162 133.1632      1     20 2.7053e-10 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

------------------------------------------
 
Term: factgender 

 Response transformation matrix:
       (Intercept)
trial1           1
trial2           1
trial3           1

Sum of squares and products for the hypothesis:
            (Intercept)
(Intercept)    38965.19

Multivariate Tests: factgender
                 Df test stat approx F num Df den Df     Pr(>F)    
Pillai            1 0.4662858 17.47324      1     20 0.00046171 ***
Wilks             1 0.5337142 17.47324      1     20 0.00046171 ***
Hotelling-Lawley  1 0.8736620 17.47324      1     20 0.00046171 ***
Roy               1 0.8736620 17.47324      1     20 0.00046171 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

------------------------------------------
 
Term: trialdata 

 Response transformation matrix:
       trialdata1 trialdata2
trial1          1          0
trial2          0          1
trial3         -1         -1

Sum of squares and products for the hypothesis:
           trialdata1 trialdata2
trialdata1   484.8   643.5
trialdata2   643.57   854.1

Multivariate Tests: trialdata
                 Df test stat approx F num Df den Df   Pr(>F)  
Pillai            1 0.3691122 5.551122      2     19 0.001125 *
Wilks             1 0.6301122 5.551122      2     19 0.002125 *
Hotelling-Lawley  1 0.5841122 5.551122      2     19 0.003125 *
Roy               1 0.5841122 5.551122      2     19 0.004125 *
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

------------------------------------------
 
Term: factgender:trialdata 

 Response transformation matrix:
       trialdata1 trialdata2
trial1          1          0
trial2          0          1
trial3         -1         -1

Sum of squares and products for the hypothesis:
           trialdata1 trialdata2
trialdata1   194.223   178.047
trialdata2   178.047   163.226

Multivariate Tests: factgender:trialdata
                 Df test stat approx F num Df den Df     Pr(>F)    
Pillai            1 0.615513 14.43363      2     19 0.0001825 ***
Wilks             1 0.382487 14.43363      2     19 0.000825 ***
Hotelling-Lawley  1 1.164298 14.43363      2     19 0.00025 ***
Roy               1 1.617298 14.43363      2     19 0.00025 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Univariate Type III Repeated-Measures ANOVA Assuming Sphericity

                        SS num Df Error SS den Df        F    Pr(>F)    
(Intercept)          98984      1  14866.6     20 123.1632 2.405e-10 ***
factgender           12988      1  14866.6     20  17.4432 0.0004517 ***
trialdata              464      2   2846.3     40   3.2353 0.0448483 *  
factgender:trialdata  1198      2   1866.3     40   8.3509 0.0010251 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


Mauchly Tests for Sphericity

                     Test statistic  p-value
trialdata                   0.76747 0.810921
factgender:trialdata        0.76747 0.809421


Greenhouse-Geisser and Huynh-Feldt Corrections
 for Departure from Sphericity

                      GG eps Pr(>F[GG])   
trialdata            0.81134   0.061742 . 
factgender:trialdata 0.81134   0.002172 **
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

                        HF eps  Pr(>F[HF])
trialdata            0.8727091 0.057594398
factgender:trialdata 0.8727091 0.001644132
> 
合同会社DILIGENCEでは一緒に働く仲間を募集しています
1 いいね!
1 いいね!

今週のランキング

窪田昂さんにいいねを伝えよう
窪田昂さんや会社があなたに興味を持つかも