scipy - 如果使用不同的包,为什么我会得到不同的 P 值
问题描述
我正在尝试比较两组的分类数据。
Yes No
GrpA: [152, 220]
GrpB: [187, 350]
但是,当使用不同的方法时,我会得到不同的 P 值结果:
count = [152, 220]
nobs = [187, 350]
import statsmodels
import scipy.stats
# USING STATSMODELS PACKAGE:
res = statsmodels.stats.proportion.proportions_chisquare(count, nobs)
print("P value =", res[1])
res = statsmodels.stats.proportion.proportions_ztest(count, nobs)
print("P value =", res[1])
# USING SCIPY.STATS PACKAGE:
res = scipy.stats.chi2_contingency([count, nobs], correction=True)
print("P value =", res[1])
res = scipy.stats.chi2_contingency([count, nobs], correction=False)
print("P value =", res[1])
输出是:
P value using proportions_chisquare = 1.037221289479458e-05
P value using proportions_ztest= 1.0372212894794536e-05
P value using chi2_contingency with correction= 0.0749218380702875
P value using chi2_contingency without correction= 0.06421435896354544
前 2 个相同(并且非常重要),但它们与后 2 个不同(不重要)。
为什么结果不一样?进行此分析的正确方法是什么?
解决方案
推荐阅读
- c# - Azure CosmosDB SQL APi 如何保存创建文档时创建的日期
- c# - 我可以防止重命名暴露给外界的方法吗?
- jasmine - 茉莉“期待”和柴“期待”有什么区别?首选使用哪一个?
- csvhelper - 如何从行尾删除评论
- asp.net - 日期格式显示不正确
- docker - Redis 使用带有 3 个 Pod 的 Kube 部署时出错
- html - Flexbox 对齐项目中的内容
- algorithm - 查找最小幸存者数量的函数
- karate - 尝试从空手道的 API 响应中获取值时出错
- node.js - NestJS + Kafka + Azure Function 的微服务架构