8  分散に関する検定

※本ページの内容はテキストの第8章に相当します

 本章では分散の基本となるF検定を中心に学びます。本章ではRcmdrで実行した場合のコードと出力結果のみを記載し、手順の記載は省略しますので詳細はテキストを参照してください。

データの読み込み
  1. Rcmdrのメニューから[データ]-[データセットのロード…]を実行する
  2. ファイルダイアログで「外来患者ストレス.RData」ファイルを選択する
  3. アクティブデータセットがPatientStressになっていることを確認する

8.1 等分散性に関するF検定 2つの集団(P158)

 F検定はふたつの集団がともに正規分布にしたがう場合、統計量\(F\)(2群の標準偏差の比)はF分布に従うを利用した検定です。帰無仮説\(H_0\)は「分散の比は1に等しい(2群の分散は等しい)」(両側仮説)で、対立仮説\(H_1\)は「分散の比は1と等しくない」(両側仮説)です。

 母分散比\(\frac{\sigma_2^2}{\sigma_1^2} \ne 1\)の両側検定。

統計量 - 分散 - 分散の比のF検定
car::Tapply(健康統制感 ~ 性別, var, na.action=na.omit,
            data=PatientStress) # variances by group
var.test(健康統制感 ~ 性別, alternative='two.sided', conf.level=.95,
         data=PatientStress)
      男       女 
212.9299 173.3991 

    F test to compare two variances

data:  健康統制感 by 性別
F = 1.228, num df = 118, denom df = 217, p-value = 0.1952
alternative hypothesis: true ratio of variances is not equal to 1
95 percent confidence interval:
 0.9000029 1.7010485
sample estimates:
ratio of variances 
          1.227976 

 帰無仮説は\(5\%\)有意水準で棄却されません(テストは失敗です)ので、帰無仮説が採択され健康統制感の分散は男女で等しいと言えます。

 テキストにはありません。

統計量 - 分散 - 分散の比のF検定
car::Tapply(健康統制感 ~ 性別, var, na.action=na.omit,
            data=PatientStress) # variances by group
var.test(健康統制感 ~ 性別, alternative='less', conf.level=.95,
         data=PatientStress)
      男       女 
212.9299 173.3991 

    F test to compare two variances

data:  健康統制感 by 性別
F = 1.228, num df = 118, denom df = 217, p-value = 0.9024
alternative hypothesis: true ratio of variances is less than 1
95 percent confidence interval:
 0.000000 1.613525
sample estimates:
ratio of variances 
          1.227976 

 テキストにはありません。

統計量 - 分散 - 分散の比のF検定
car::Tapply(健康統制感 ~ 性別, var, na.action=na.omit,
            data=PatientStress) # variances by group
var.test(健康統制感 ~ 性別, alternative='greater', conf.level=.95,
         data=PatientStress)
      男       女 
212.9299 173.3991 

    F test to compare two variances

data:  健康統制感 by 性別
F = 1.228, num df = 118, denom df = 217, p-value = 0.09758
alternative hypothesis: true ratio of variances is greater than 1
95 percent confidence interval:
 0.9460203       Inf
sample estimates:
ratio of variances 
          1.227976 

 テキストにはありません。

グラフ - ヒストグラム
with(PatientStress, RcmdrMisc::Hist(健康統制感, groups=性別,
                                    scale="frequency", breaks="Sturges",
                                    col="darkgray"))

8.2 ルービン検定 3つ以上の集団(P161)

ルービン検定の帰無仮設\(H_0\)は「すべての水準で分散は等しい」ですので、対立仮説\(H_1\)は「あらゆる水準で分散が異なる」の両側検定になります。

統計量 - 分散 - ルービン検定
car::Tapply(健康統制感 ~ 年齢区分, var, na.action=na.omit,
            data=PatientStress) # variances by group
car::leveneTest(健康統制感 ~ 年齢区分, data=PatientStress,
                center="median")
    青年     壮年     中年     高年 
166.8805 152.5515 189.6079 202.5386 
Levene's Test for Homogeneity of Variance (center = "median")
       Df F value Pr(>F)
group   3  0.3037 0.8228
      333               

 帰無仮説は\(5\%\)有意水準で棄却されません(テストは失敗です)ので、帰無仮説が採択され健康統制感の分散はすべての年齢区分で等しいと言えます。

 テキストにはありません。

統計量 - 分散 - バートレットの検定
bartlett.test(健康統制感 ~ 年齢区分, data=PatientStress)

    Bartlett test of homogeneity of variances

data:  健康統制感 by 年齢区分
Bartlett's K-squared = 1.298, df = 3, p-value = 0.7296

 テキストにはありません。

グラフ - ヒストグラム
with(PatientStress, RcmdrMisc::Hist(健康統制感, groups=年齢区分,
                                    scale="frequency", breaks="Sturges",
                                    col="darkgray"))