这是我的应急表:
X
# Yes No
# Pre 5 685
# Post 17 1351Fisher检验
fisher.test(X)
# Fisher's Exact Test for Count Data
# data: X
# p-value = 0.3662
# alternative hypothesis: true odds ratio is not equal to 1
# 95 percent confidence interval:
# 0.1666371 1.6474344
# sample estimates:
# odds ratio
# 0.5802157计算赔率比
P1<-5/(5+685)
P2<-17/(17+1351)
(P1/(1-P1))/(P2/(1-P2))
# [1] 0.5800773为什么价值观是不同的?R中fisher检验函数是如何计算估计的优势比的?
发布于 2016-09-01 11:06:53
查看fisher.test的底层代码,我看到
ESTIMATE <- c(`odds ratio` = mle(x))就在这上面
mle <- function(x) {
if (x == lo)
return(0)
if (x == hi)
return(Inf)
mu <- mnhyper(1)
if (mu > x)
uniroot(function(t) mnhyper(t) - x, c(0, 1))$root
else if (mu < x)
1/uniroot(function(t) mnhyper(1/t) - x, c(.Machine$double.eps,
1))$root
else 1
}如果不研究mle定义上的代码的所有细节,看起来fisher.test是在根据mnhyper (fisher.test1中定义的另一个函数)中定义的理论假设来求解赔率方程,而不是直接从数据中计算它。我怀疑如果我想得到一个完整的答案,我需要阅读?fisher.test中的参考资料
1在fisher.test中有几个函数,如dnhyper、mnhyper和pnhyper,它们似乎是非中心超几何分布的分布函数。
https://stackoverflow.com/questions/39267220
复制相似问题