|
<分割表のカイ二乗適合度検定>
SAS の freq で適合度検定のためのカイ2乗値を計算しようと思ったが,独立性の検定が自然にできるのに,適合度検定ができない(!?).
▼プログラム例:
data mendel81 ;
type = 1 ; f = 315 ; output ;
type = 2 ; f = 101 ; output ;
type = 3 ; f = 108 ; output ;
type = 4 ; f = 32 ; output ;
run ;
※ proc freq では testp = ( ) オプションで帰無仮説の比率(理論比率)を指定する.
proc freq data = mendel81 ;
tables type / testp = ( 0.5625 0.1875 0.1875 0.0625 ) ;
weight f ;
run ;
※ 出力結果は以下のようになる.
Test Cumulative Cumulative
TYPE Frequency Percent Percent Frequency Percent
------------------------------------------------------------
1 315 56.7 56.3 315 56.7
2 101 18.2 18.8 416 74.8
3 108 19.4 18.8 524 94.2
4 32 5.8 6.3 556 100.0
Chi-Square Test for Specified Proportions
-----------------------------------------
Statistic = 0.470 DF = 3 Prob = 0.925
※ 比率でなく, testf = ( ) で帰無仮説の度数(期待度数)を指定することもできる.
proc freq data = mendel81 ;
tables type / testf = ( 312.75 104.25 104.25 34.75 ) ;
weight f ;
run ;
※ 出力結果は以下のようになる.
Test Cumulative Cumulative
TYPE Frequency Frequency Percent Frequency Percent
--------------------------------------------------------------
1 315 312.75 56.7 315 56.7
2 101 104.25 18.2 416 74.8
3 108 104.25 19.4 524 94.2
4 32 34.75 5.8 556 100.0
Chi-Square Test for Specified Frequencies
-----------------------------------------
Statistic = 0.470 DF = 3 Prob = 0.925
▼メンデルの有名なデータは,以下からとった. |