zoukankan      html  css  js  c++  java
  • 卡方检验 | 富集分析 | Chi-Square Test in R

    基本10分以上的paper都要求有严格地统计分析,所以看起来才会professional。

    本质就是两个离散变量的关联分析,还可以给出OR。

    • 小样本就用Fisher's exact test for small cell sizes
    • 大样本就用Chi-Square Test

    首先画一个2X2的表格

      H1 non-H1
    H2 a b
    non-H2 c d

    首先就可以算一个OR,就是比例的比例 = a * d / b *c = (a/b) / (c/d),越接近1就越代表没有区别,即没有关联(两个变量随机)。

    其次可以用R来算P-value

    tmp.table <- matrix(data = c(66,76,7,197), byrow = F, nrow = 2)
    
    colnames(tmp.table) <- c("core6", "others")
    rownames(tmp.table) <- c("WES", "non-WES")
    
    core6	others
    WES	66	7
    non-WES	76	197
    

      

    epitools::oddsratio(tmp.table, method = "wald")
    

      

    结果:

    $data
    A matrix: 3 × 3 of type dbl
    core6	others	Total
    WES	66	7	73
    non-WES	76	197	273
    Total	142	204	346
    
    $measure
    A matrix: 2 × 3 of type dbl
    estimate	lower	upper
    WES	1.00000	NA	NA
    non-WES	24.43985	10.7338	55.64725
    
    $p.value
    A matrix: 2 × 3 of type dbl
    midp.exact	fisher.exact	chi.square
    WES	NA	NA	NA
    non-WES	0	5.143003e-23	4.732414e-22
    

      

    参考:

    Contingency analysis: R code for Chapter 9 examples

      

  • 相关阅读:
    洛谷1509 找啊找啊找GF
    要怎样努力,才能成为很厉害的人?
    随笔
    2018NOIP模拟题 曲线
    洛谷4147 玉蟾宫
    洛谷2258 子矩阵
    Vijos 纸牌
    [leetcode] Word Break
    [leetcode] Maximum Binary Tree
    [leetcode] Binary Tree Preorder Traversal
  • 原文地址:https://www.cnblogs.com/leezx/p/15265049.html
Copyright © 2011-2022 走看看