python - 如何对多项式样本进行 Tukey 风格比例检验?
问题描述
我有一张 4 x 4 的桌子。行对应于人员组,列是他们的决策类型。表中的 ij 是具有决策类型 j 的类型 i 的人数。
decision 1 decision 2 decision 3 decision 4
people type 1 150 50 130 270
people type 2 540 60 160 240
people type 3 530 70 170 230
people type 4 540 40 150 270
我想做一个 Tukey 风格的比例测试来比较人的类型对。预期的输出必须类似于下表。
p_value
people type 1 & 2 X
people type 1 & 3 X
people type 1 & 4 X
people type 2 & 3 X
people type 2 & 4 X
people type 3 & 4 X
解决方案
好吧,由于没有任何名称为“Tukey 风格比例测试”,我只能假设您的意思是您想要调整 p 值,因为您在进行重大总体发现后进行多重比较。
该rcompanion
软件包具有允许您执行此操作并选择使用哪种常用r
调整方法的功能。我的示例使用holm
Input =("
People 'decision 1' 'decision 2' 'decision 3' 'decision 4'
'people type 1' 150 50 130 270
'people type 2' 540 60 160 240
'people type 3' 530 70 170 230
'people type 4' 540 40 150 270")
your_data = as.matrix(read.table(textConnection(Input),
header=TRUE,
row.names=1))
your_data
#> decision.1 decision.2 decision.3 decision.4
#> people type 1 150 50 130 270
#> people type 2 540 60 160 240
#> people type 3 530 70 170 230
#> people type 4 540 40 150 270
chisq.test(your_data)
#>
#> Pearson's Chi-squared test
#>
#> data: your_data
#> X-squared = 185.06, df = 9, p-value < 2.2e-16
library(rcompanion)
pairwiseNominalIndependence(your_data,
fisher = FALSE,
gtest = FALSE,
chisq = TRUE,
method = "holm")
#> Comparison p.Chisq p.adj.Chisq
#> 1 people type 1 : people type 2 5.44e-29 3.26e-28
#> 2 people type 1 : people type 3 1.56e-28 7.80e-28
#> 3 people type 1 : people type 4 3.02e-28 1.21e-27
#> 4 people type 2 : people type 3 7.11e-01 7.11e-01
#> 5 people type 2 : people type 4 1.07e-01 2.14e-01
#> 6 people type 3 : people type 4 5.27e-03 1.58e-02
推荐阅读
- scroll - goto 功能与 sapper-noscroll
- flutter - 如何使用 ThemeData 为相同的小部件类型设置不同的颜色?[扑]
- javascript - 如何一键禁用峰会按钮,如果验证错误不应该禁用
- node.js - npm outdated 命令不返回当前版本
- python-3.x - Faust 框架(或其他框架)中是否有 celery countdown 和 eta 的替代方案?
- javascript - 如果我使用 jQuery 创建选择下拉列表,则 .change() 方法不起作用
- r - 如何在ggplot的堆积条形图中将误差条组织到相关条形?
- javascript - 增加理解 - 在循环内使用扩展运算符复制数组
- mysql - Mysql在插入和删除时死锁
- python - 没有名为“setuptools”的模块