Rで確率・統計:ボンフェローニ補正

Rでデータサイエンス

ボンフェローニ補正

有意水準5%で「3群(分散同一)の平均値を比較」する場合を例とする。

帰無仮説(H0)は「3群間の平均値に差はない」

n <- 30
a <- rnorm(n = n, mean = 10, sd = 1)
b <- rnorm(n = n, mean = 10, sd = 1)
c <- rnorm(n = n, mean = 5, sd = 1)
# a群とb群
t.test(a, b, var.equal = T)

    Two Sample t-test

data:  a and b
t = 1.7362, df = 58, p-value = 0.08783
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -0.05795725  0.81607421
sample estimates:
mean of x mean of y 
10.277354  9.898296 

5%で棄却できず。

# a群とc群
t.test(a, c, var.equal = T)

    Two Sample t-test

data:  a and c
t = 20.268, df = 58, p-value < 0.00000000000000022
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 4.654844 5.675057
sample estimates:
mean of x mean of y 
10.277354  5.112403 

5%で棄却。

# b群とc群
t.test(b, c, var.equal = T)

    Two Sample t-test

data:  b and c
t = 20.686, df = 58, p-value < 0.00000000000000022
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 4.322766 5.249019
sample estimates:
mean of x mean of y 
 9.898296  5.112403 

5%で棄却。

それぞれの検定の第一種の過誤(\(\alpha\)エラー)は5%であるが、3つ同時に検定すると、3つの検定のうち少なくとも1つで第一種の過誤の生じる確率(Family Wise Error Rate)は

(1 - (1 - 0.05)^3) * 100
[1] 14.2625

と5%よりも大きくなる。

そこでFamily Wise Error Rate(FWER、多重比較検定全体の第一種の過誤)を調整する方法の一つがボンフェローニ補正。

m回の同時検定のうち、少なくとも1つで第一種の過誤が生じる確率は以下の通りとなる。 \[\textrm{FWER}=1-(1-\alpha)^m=1-\displaystyle\sum_{i=0}^m\dfrac{m!}{i!\,(m-i)!}(-\alpha)^m\simeq1-(1-m\,\alpha)=m\,\alpha\]

よって\(\alpha\)\(\alpha/m\)に置き換えれば、FWERが\(\alpha\)となる。

(1 - (1 - 0.05/3)^3) * 100
[1] 4.91713

参考引用資料

最終更新

Sys.time()
[1] "2024-04-15 14:11:12 JST"

R、Quarto、Package

R.Version()$version.string
[1] "R version 4.3.3 (2024-02-29 ucrt)"
quarto::quarto_version()
[1] '1.4.542'
packageVersion(pkg = "tidyverse")
[1] '2.0.0'

著者