prop.test,调节另一个 class
prop.test, conditioning on the other class
我在 R 上 运行 prop.test。这里是偶然事件 table 和 prop.test 的输出。 'a' 是数据框的名称。 'cluster'和'AD_2'是两个二分变量。
table(a$cluster,a$AD_2)
no yes
neg 1227 375
pos 546 292
prop.test(table(a$cluster,a$AD_2))
2-sample test for equality of proportions with continuity
correction
data: table(a$cluster, a$AD_2)
X-squared = 35.656, df = 1, p-value = 2.355e-09
alternative hypothesis: two.sided
95 percent confidence interval:
0.07510846 0.15362412
sample estimates:
prop 1 prop 2
0.7659176 0.6515513
样本估计以 AD_2 为 'no' 为条件,从意外事件 table 可以看出,即 0.7659176 = 1227/(1227+375) 和 0.6515513 = 546/( 546+292)。作为一个 $cluster==pos 积极事件和 AD_2==yes 风险因素,我想将 AD_2 上的比例条件反转为 'yes'.
R 表本质上是矩阵。 `prop.test 函数可以处理矩阵,因此使用相同的数据并切换列:
> prop.test( matrix(c( 375,292,1227,546), 2))
2-sample test for equality of proportions with continuity correction
data: matrix(c(375, 292, 1227, 546), 2)
X-squared = 35.656, df = 1, p-value = 2.355e-09
alternative hypothesis: two.sided
95 percent confidence interval:
-0.15362412 -0.07510846
sample estimates:
prop 1 prop 2
0.2340824 0.3484487
我认为另一种方法可能是将列交换为:
table(a$cluster,a$AD_2)[ , 2:1]
我在 R 上 运行 prop.test。这里是偶然事件 table 和 prop.test 的输出。 'a' 是数据框的名称。 'cluster'和'AD_2'是两个二分变量。
table(a$cluster,a$AD_2)
no yes
neg 1227 375
pos 546 292
prop.test(table(a$cluster,a$AD_2))
2-sample test for equality of proportions with continuity
correction
data: table(a$cluster, a$AD_2)
X-squared = 35.656, df = 1, p-value = 2.355e-09
alternative hypothesis: two.sided
95 percent confidence interval:
0.07510846 0.15362412
sample estimates:
prop 1 prop 2
0.7659176 0.6515513
样本估计以 AD_2 为 'no' 为条件,从意外事件 table 可以看出,即 0.7659176 = 1227/(1227+375) 和 0.6515513 = 546/( 546+292)。作为一个 $cluster==pos 积极事件和 AD_2==yes 风险因素,我想将 AD_2 上的比例条件反转为 'yes'.
R 表本质上是矩阵。 `prop.test 函数可以处理矩阵,因此使用相同的数据并切换列:
> prop.test( matrix(c( 375,292,1227,546), 2))
2-sample test for equality of proportions with continuity correction
data: matrix(c(375, 292, 1227, 546), 2)
X-squared = 35.656, df = 1, p-value = 2.355e-09
alternative hypothesis: two.sided
95 percent confidence interval:
-0.15362412 -0.07510846
sample estimates:
prop 1 prop 2
0.2340824 0.3484487
我认为另一种方法可能是将列交换为:
table(a$cluster,a$AD_2)[ , 2:1]