0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

比率の検定についてのあれこれ

Last updated at Posted at 2021-03-10

比率の検定をするにあたり、ちょっと色々と調べた。

比率の検定って色々ある。
とりあえずデータはこんな感じで観測点数がそれぞれ入ってる。

-- Yes No
群1 L1 L2
群2 U1 U2

具体的な数字としては、L1、L2、U1、U2はそれぞれ、22, 26, 11, 40。

基本的にはフィッシャーの正確確率検定が良いようだ。

他の参考資料としてはhttps://biolab.sakura.ne.jp/proportion-test.html

ピアソンのカイ2乗検定

chisq.test(matrix(c(L1,L2,U1,U2),nco=2,byrow = T))

結果

	Pearson's Chi-squared test with Yates' continuity correction

data:  matrix(c(L1, L2, U1, U2), nco = 2, byrow = T)
X-squared = 5.5051, df = 1, p-value = 0.01896

イェイツのカイ二乗検定

補正ありの場合

prop.test(c(L2,U2),c(L1+L2,U1+U2),correct =T)

結果

	2-sample test for equality of proportions with continuity correction

data:  c(L2, U2) out of c(L1 + L2, U1 + U2)
X-squared = 5.5051, df = 1, p-value = 0.01896
alternative hypothesis: two.sided
95 percent confidence interval:
 -0.4434519 -0.0418422
sample estimates:
   prop 1    prop 2 
0.5416667 0.7843137 

補正なしの場合

prop.test(c(L2,U2),c(L1+L2,U1+U2),correct = F)

結果

	2-sample test for equality of proportions without continuity correction

data:  c(L2, U2) out of c(L1 + L2, U1 + U2)
X-squared = 6.5515, df = 1, p-value = 0.01048
alternative hypothesis: two.sided
95 percent confidence interval:
 -0.42323133 -0.06206279
sample estimates:
   prop 1    prop 2 
0.5416667 0.7843137 

フィッシャーの正確確率検定

fisher.test(matrix(c(L1,L2,U1,U2),ncol=2,byrow = T))

結果

	Fisher's Exact Test for Count Data

data:  matrix(c(L1, L2, U1, U2), ncol = 2, byrow = T)
p-value = 0.01828
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
 1.182808 8.209687
sample estimates:
odds ratio 
  3.040688 

ダミー変数を割り当ててt検定(ウェルチの検定)

Ansは各観測について、Noに1を、Yesに2を割り振ったもの。Classは群。
以下のようなデータ構造を想定。

Sample Class Ans
1 L 1
2 L 2
3 U 2
4 U 1
5 U 2
: : :
t.test(this.data$Ans~this.data$class)
	Welch Two Sample t-test

data:  this.data[[Q2.list[i]]] by this.data$class
t = -2.6066, df = 91.286, p-value = 0.01068
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -0.42754871 -0.05774541
sample estimates:
mean in group Lower mean in group Upper 
           1.541667            1.784314 
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?