Eric's color bar icon

このページは、令和2年4月日に一部更新しました。
under construction icon

1.6.7節  SAS/IML による反復測度 RBF-pq デザインの GMANOVA 分析

Eric's eye-bar icon

 ここでは、2要因反復測度 RBF-p デザインデータの SAS/IML による GMANOVA 及び対比検定等を以下の2つのセクションに分けて示す:

1.6.7.1  IML による反復測度 RBF-pq デザインの GMANOVA 分析用プログラム
1.6.7.2  IML による反復測度 RBF-pq デザインの GMANOVA 出力結果の概要

 この節には、つぎの2つの SAS プログラムのダウンロードコーナーを用意して あります:

IML による反復測度 RBF-pq デザインの GMANOVA 分析用プログラムの例

Eric's eye-bar icon

1.6.7.1 IML による反復測度 RBF-pq デザイン の GMANOVA 分析用プログラム

  この節では、前節と同一のデータを用いて 1.6.5 節で述べた MANOVA 方式 (正確には、GMANOVA)で、SAS/IML による反復測度 RBF-pq デザインデータの 分析プログラムを示す。もっとも、前節のデータはサンプル数が9と小さいので、 本来 MANOVA 方式は勧められない。したがって、以下のプログラムはあくまでも サンプル数が大の場合に2要因反復測定デザインの GMANOVA 分析を行うための IML プログラムである、という点に注意されたい

  このプログラムでは、データと反復測定要因の2つの対比行列をプログラム中 に指定すると、1.6.5 節の (1.208) 式で与えられるクロネッカー積 M を自 動的に計算し、まず反復測度2要因の全体的交互作用の検定と Roy-Bose 方式の同 時検定結果を出力する。ここでもし全体的交互作用が統計的に有意な場合には、各 要因の主効果や同時検定は行わない。一方、もし全体的交互作用が統計的に有意で ない場合、すなわち平行性仮説が採択される場合には、さらに各反復測度要因の主 効果と対比の同時検定を出力する。

プログラムは、以下に示すように5項から成る:

1.冒頭のコメント
2.(1) データインプット
3. 変数や変換行列の定義とクロネッカー積のプリント
4. 2要因反復測定デザインの交互作用の検定とその出力
5. 交互作用が有意の場合の、主効果の検定とそれらの出力

冒頭のコメント

*----------------------------------------------------------------------*
|                                                    December 1, 1998  |
|                                                                      |
|  file name:  $HOME/sasprog/multivar/imlrole.sas                      |
|                                                                      |
|   SAS/IML program for executing simultaneous contrast tests using a  |
| Roy-Bose simultaneous test procedure for an arbitrary repeated       |
| measures RBF.p-q design data.                                        |
|                                                                      |
|  Caution!                                                            |
|                                                                      |
| (1) Users must revise the necessary parts of the following program   |
|  in order to specify (1) raw data, (2) transformation matrix for A   |
|  effect, (3) transformation matrix for B effect, and so on, which    |
|  are suggested by the comments which begin with '/* Specify ... '.   |
| (2) In this case, data is cited from Table 1 of Rouanet and Lepine   |
|  (1970), The British Journal of Mathematical and Statistical Psy-    |
|  chology, design of the data being RBF.4-2.                          |
| (3) If the overall interaction effect is significant, this program   |
|  skips both of the test of the main A effect and that of the main B  |
|  effect.                                                             |
|                                                                      |
*----------------------------------------------------------------------*;

 ここでは、冒頭のコメントを記述している。

back icon


(1) データインプット

options pagesize=60 ls=80;

/* (1) data input */
data role1970;
  /* Specify variable names and their labels */
  input no 1. (A1_B1 A1_B2 A2_B1 A2_B2 A3_B1 A3_B2 A4_B1 A4_B2) (4.);
  label no='sample number'
        A1_B1='combination of A1 and B1'
        A1_B2='combination of A1 and B2'
        A2_B1='combination of A2 and B1'
        A2_B2='combination of A2 and B2'
        A3_B1='combination of A3 and B1'
        A3_B2='combination of A3 and B2'
        A4_B1='combination of A4 and B1'
        A4_B2='combination of A4 and B2';

  /* Specify the raw data */
 cards;
1 265 245 260 216 286 247 291 255
2 263 242 274 256 222 195 228 247
3 241 207 217 199 213 171 246 211
4 223 250 224 223 200 193 208 217
5 254 242 268 244 266 236 265 262
6 222 170 197 172 203 183 211 206
7 254 244 259 229 257 266 236 239
8 280 292 284 257 247 245 248 236
9 276 214 230 204 207 200 219 191
;
proc iml;
  use role1970;
  /* Specify the variable names for repeated measures, which must
       be the same as those defined by the input statement */
  read all var{A1_B1 A1_B2 A2_B1 A2_B2 A3_B1 A3_B2 A4_B1 A4_B2}
       into y;
  print "Input raw-data matrix, Y", y;

この項では、IML による2要因反復測定 RBF_4.2 デザインデータの入力とデータ のプリントの指示をしている。

back icon


変数や変換行列の定義とクロネッカー積のプリント

  nr=nrow(y);
  nc=ncol(y);

 if nr < nc then do;
   print "number of samples is too small"; return;
     end;

  /* Specify the transformation matrix for A */
   m_a={-1 -1 -1,
         1  0  0,
         0  1  0,
         0  0  1};
  /* Specify the names for contrasts of A effect */
   name_ca={ca1_cbu ca2_cbu ca3_cbu};

 marow=nrow(m_a);
 macol=ncol(m_a);

  /* Specify the transformation matrix for B */
   m_b={-1, 1};
  /* Specify the names for contrasts of B effect */
   name_cb={cau_cb};

 mbrow=nrow(m_b);
 mbcol=ncol(m_b);
 mint=m_a@m_b;

  /* Specify the names for contrast-contrast interactions */
   name_cab={ca1_cb ca2_cb ca3_cb};

 print "transformation matrices and the Kronecker product",
               m_a, m_b, mint;

SAS/IML では、上の例から明らかなように、2つの行列のクロネッカー積は "at" マークで簡単に計算される。

back icon


2要因反復測定デザインの交互作用の検定とその出力

 start test(y,nr,m,pcon,namef,namedf1,namedf2,namep,namecon);
  ybar=y[+,]/nr;          /* ybar is a row vector */
  h=nr*m`*ybar`*ybar*m;   /* H matrix */
  e=m`*y`*y*m-h;          /* E matrix */
  g=h*inv(e);
  roy=trace(g);           /* Roy's greatest root */
  nu1=ncol(m);
  nu2=nr-nu1;
  f=roy*nu2/nu1;
  p=1-probf(f,nu1,nu2);
   print "test for the hypothesis of no overall effect under study",
            f[colname=namef],
                nu1[colname=namedf1], nu2[colname=namedf2],
                    p[colname=namep];
  z=m`*ybar`;
  z2=z##2;
  vece=vecdiag(e);
  mat=nr*nu2*diag(1/vece)/nu1;
  fcon=mat*z2;
  pcon=vecdiag(I(nu1))-probf(fcon,nu1,nu2);
      print "F values of simultaneous contrast test",
                         fcon[rowname=namecon colname=namef];
   print "p-values of simultaneous contrast test",
                      pcon[rowname=namecon colname=namep];
 finish;

 namef={F_value};
 namep={Prob_ge_F};
 namedf1={df_1};
 namedf2={df_2};

 print "1. test for the hypothesis of no interaction effect";
 m=mint;           /* M matrix for testing interaction effect*/
 namecon=name_cab;
 run test(y,nr,m,pcon,namef,namedf1,namedf2,namep,namecon);

この項では、2要因反復測定デザインの交互作用の検定とその出力を行う。

back icon


交互作用が有意の場合の、主効果の検定とそれらの出力

 if pcon > 0.05 then do;
   print "2. test for the hypothesis of no A effect";
   m_unitb=vecdiag(I(mbrow));
   m=m_a@m_unitb;   /* M matrix for testing A effect */
   namecon=name_ca;
   run test(y,nr,m,pcon,namef,namedf1,namedf2,namep,namecon);

   print "3. test for the hypothesis of no B effect";
   m_unita=vecdiag(I(marow));
   m=m_unita@m_b;   /* M matrix for testing B effect */
   namecon=name_cb;
   run test(y,nr,m,pcon,namef,namedf1,namedf2,namep,namecon);
 end;

quit;

プログラムのダウンロード・コーナー

Eric's abar10 icon

imlrole.sas

Eric's eye-bar icon

1.6.6.2 SAS による反復測度 RB-p デザイン ANOVA プログラムの出力結果の概要

 うえのプログラムを実行すると、以下のような出力結果が得られる:

1. ローデータ及び各要因の対比行列とそれらのクロネッカー 積の出力

                                  SAS システム                                 1

                            Input raw-data matrix, Y

        Y
      265       245       260       216       286       247       291       255
      263       242       274       256       222       195       228       247
      241       207       217       199       213       171       246       211
      223       250       224       223       200       193       208       217
      254       242       268       244       266       236       265       262
      222       170       197       172       203       183       211       206
      254       244       259       229       257       266       236       239
      280       292       284       257       247       245       248       236
      276       214       230       204       207       200       219       191

 この項では、プログラムの中の (1) データインプット、のところで入力した ローデータを iml プロシジャの最初の print 文により単にプリントした結果を 示す。

2. 2要因ごとの対比行列から計算されたクロネッカー積 の出力

               transformation matrices and the Kronecker product

                               M_A
                                -1        -1        -1
                                 1         0         0
                                 0         1         0
                                 0         0         1


                                         M_B
                                          -1
                                           1


                              MINT
                                 1         1         1
                                -1        -1        -1
                                -1         0         0
                                 1         0         0
                                 0        -1         0
                                 0         1         0
                                 0         0        -1
                                 0         0         1

 この項では、プログラムの各要因の対比行列とそれらのクロネッカー積の出力 を行う。これらのうち最後のクロネッカー積 MINT については、プログラムで計算し た結果である。

3. 2要因反復測定デザインの交互作用及び対比・対比 交互作用の検定結果

              1. test for the hypothesis of no interaction effect

            test for the hypothesis of no overall effect under study

                                  F   F_VALUE

                                    1.5662578



                                 NU1      DF_1

                                             3



                                 NU2      DF_2

                                             6

                                  SAS システム                                 2

                                  P PROB_GE_F

                                    0.2924662

                     F values of simultaneous contrast test

                                FCON     F_VALUE

                                CA1_CB 0.0675725
                                CA2_CB 0.0016646
                                CA3_CB 0.2806013

                     p-values of simultaneous contrast test

                                PCON   PROB_GE_F

                                CA1_CB 0.9751531
                                CA2_CB 0.9998952
                                CA3_CB  0.837837

 この項では、2要因反復測定デザインの全体的交互作用及び対比・対比交互作用 の検定結果を示す。全体的交互作用の検定の F-値や p-値は、1.6.6 節の出力のところ で示した glm プロシジャによるそれらと一致していることがわかる。
 1.6.6 節での glm プロシジャによる結果との相違点は、全体的交互作用検定の 下位検定としての対比・対比交互作用検定結果である。1.6.6 節のそこでの結果の ところで指摘したように、SAS の glm プロシジャでは対比・対比交互作用の検定に おいて、もしそれらが事後的非直交対比であるとすれば族あたりの危険率はコントロ ールされていないが、この項での IML によるプログラムでは Roy-Bose 方式を 用いているので、対比・対比交互作用の検定における族あたりの危険率はコントロール できている
 1.6.6 節では、これらの対比・対比交互作用には、TREAT_.2*TREAT.2、 TREAT_.3*TREAT.2、及びTREAT_.4*TREAT.2、なる変数名がついていたが、ここでは これらをプログラムの中で順に、CA1_CB、CA2_CB、及び CA3_CB、と定義しており、 両者を比較すると、族あたりの危険率をコントロールしたこの節での上記の p-値の 方が 1.6.6 節でのそれらに比べて大きくなっていることがわかる。たまたまこの データの場合には、両結果からはどの対比・対比交互作用も有意ではないという 結果が得られてはいるものの、上の結果はデータによっては 1.6.6 節のやり方では 有意でも、族あたりの危険率をコントロールしたこの節でのやり方によれば有意で なくなるケースがあることを示唆している。

4. 要因 A の主効果の検定結果と同時対比検定結果

                   2. test for the hypothesis of no A effect

            test for the hypothesis of no overall effect under study

                                  F   F_VALUE

                                    2.7274883



                                 NU1      DF_1

                                             3



                                 NU2      DF_2

                                             6



                                  P PROB_GE_F

                                    0.1366194

                     F values of simultaneous contrast test

                               FCON      F_VALUE

                               CA1_CBU 1.2462601
                               CA2_CBU  1.380948
                               CA3_CBU 0.3542702

                     p-values of simultaneous contrast test

                               PCON    PROB_GE_F
                                  SAS システム                                 3

                               CA1_CBU 0.3730159
                               CA2_CBU 0.3360569
                               CA3_CBU 0.7882528

 この項では、要因 A の主効果の検定結果と同時対比検定結果を示す。まず、主 効果については F-値や p-値は 1.6.6 節の glm プロシジャによるそれらと一致して いることがわかる。
 相違点はもちろん要因 A の対比検定結果である。このデータの場合、交 互作用は有意ではなかったので各要因の主効果を検討するのが自然である。要因 A に関しては、上の結果より有意な傾向がみられるので、水準間の対比を検討することに なるが、(1.6.6 節の glm プロシジャでの対比検定では有意な対比が存在したが) 上の出力の最後にある同時検定の結果を見ると、族あたりの危険率をコントロール するならばどの対比も有意ではなくなることが、p-値からわかる。

5. 要因 B の主効果の検定結果と同時対比検定結果

                   3. test for the hypothesis of no B effect

            test for the hypothesis of no overall effect under study

                                  F   F_VALUE

                                    14.107633



                                 NU1      DF_1

                                             1



                                 NU2      DF_2

                                             8



                                  P PROB_GE_F

                                     0.005576

                     F values of simultaneous contrast test

                                FCON     F_VALUE

                                CAU_CB 14.107633

                     p-values of simultaneous contrast test

                                PCON   PROB_GE_F

                                CAU_CB  0.005576

 この項では、要因 B の主効果の検定結果と同時対比検定結果を示す。要因 B の 場合、水準数が2であるので、主効果の検定結果と対比検定結果は一致し、さらに その故に対比検定結果も glm プロシジャによる 1.6.6 節の結果とも当然一致する。

Eric's back icon

Eric's color bar icon