【问题标题】:Prop.test and fisher's exact test in R [closed]R中的Prop.test和fisher精确检验[关闭]
【发布时间】:2021-05-28 22:11:28
【问题描述】:

我对使用 Fisher 精确检验比较两个比例感到困惑。例如,我想测试两个比例 9/13 和 3/18 之间是否存在差异。我可以简单地输入

A <-  c( 9, 3)
B <-  c( 13, 18)
prop.test(A , B)

但是如何使用费希尔精确检验来进行呢?我不确定这是否正确:

A = matrix(c(9, 3,
             13,18), nrow = 2)

fisher.test(A)

感谢您的任何想法

【问题讨论】:

    标签: r testing statistics statistical-test


    【解决方案1】:

    是的,与 prop.test() 相比,您的 Fisher 检验设置不正确。

    来自 prop.test 帮助文件:

    prop.test(x, n, p = NULL, alternative = c("two.sided", "less", "greater"), conf.level = 0.95, correct = TRUE)
    
    x a vector of counts of successes,...
    
    n a vector of counts of trials ...
    

    费雪检验

    fisher.test(x, y = NULL, workspace = 200000, hybrid = FALSE,
                hybridPars = c(expect = 5, percent = 80, Emin = 1),
                control = list(), or = 1, alternative = "two.sided",
                conf.int = TRUE, conf.level = 0.95,
                simulate.p.value = FALSE, B = 2000)
    
    x a two-dimensional contingency table in matrix form.
    

    因此,如果您的 13 次和 18 次试验的 2 次测试结果分别为 9 次和 3 次成功,则意味着失败次数为 4 次和 15 次,因此 Fishers 测试应该是:

    A = matrix(c(9, 3, 4, 15), nrow = 2)
    #Row sums are the total number of trials
    #Column sums are the total number of True/False
     
    fisher.test(A)
    
        Fisher's Exact Test for Count Data
    
    data:  A
    p-value = 0.007518
    alternative hypothesis: true odds ratio is not equal to 1
    95 percent confidence interval:
      1.61038 89.70868
    sample estimates:
    odds ratio 
      10.18122 
    

    这提供了与 prop.test 结果相当的结果。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-07-29
    • 1970-01-01
    • 2021-11-11
    • 1970-01-01
    • 2021-05-18
    • 1970-01-01
    • 2016-12-01
    • 2016-04-29
    相关资源
    最近更新 更多