美文网首页散文想法简友广场
R语言 非参数检验:Mann-Whitney检验和Wilcoxo

R语言 非参数检验:Mann-Whitney检验和Wilcoxo

作者: Cache_wood | 来源:发表于2021-11-11 12:53 被阅读0次
    参数检验 非参数检验
    分布特征 正态分布 非正态分布或未知分布
    独立样本 独立t检验 Mann-Whitney检验
    成对样本 配对t检验 Wilcoxon秩和检验paired

    两独立样本t检验的假设条件是样本分布需要符合正态性。

    但是,当样本分布非正态,且经过一定的数值转换尝试后,仍然无法满足正态性要求时,两独立样本的Wilcoxon秩和检验成为备选方法,它将两独立样本组的非正态样本值进行比较。它是一种非参数样本检验,基于样本的秩次排列,而非平均值。

    注意,当数据呈非正态分布时,选择Wilcoxon检验。可以使用Shapiro-Wilk test进行检查。

    非正态分布的独立样本

    data <- read.csv(file = file.choose(),header = TRUE)
    attach(data)
    head(data)
    tail(data)
    wilcox.test(scores~methods,paired=FALSE)##Mann-Whitney U Test
    
    > head(data)
      scores methods
    1     70       A
    2     61       A
    3     63       A
    4     77       A
    5     51       A
    6     70       A
    > tail(data)
       scores methods
    45     87       B
    46     88       B
    47     79       B
    48     96       B
    49     70       B
    50     89       B
    > wilcox.test(scores~methods,paired=FALSE)##Mann-Whitney U Test
    
        Wilcoxon rank sum test with
        continuity correction
    
    data:  scores by methods
    W = 39.5, p-value = 1.149e-07
    alternative hypothesis: true location shift is not equal to 0
    

    可得出结论:两个班级的平均成绩有显著差异 (W = 39.5, df = 48, p<0.001)

    非正态分布的成对样本

    data <- read.csv(file = file.choose(),header = TRUE)
    attach(data)
    head(data)
    tail(data)
    wilcox.test(test1,test2,paired=TRUE)  ## Wilcoxon Test
    
    > head(data)
      test1 test2
    1    81    87
    2    63    67
    3    75    77
    4    67    80
    5    64    70
    6    65    68
    > tail(data)
       test1 test2
    21    66    68
    22    74    89
    23    77    89
    24    76    88
    25    67    76
    26    75    89
    > wilcox.test(test1,test2,paired=TRUE)  ## Wilcoxon Test
    
        Wilcoxon signed rank test with
        continuity correction
    
    data:  test1 and test2
    V = 12.5, p-value = 0.0001412
    alternative hypothesis: true location shift is not equal to 0
    

    可得出结论:两个班级的平均成绩有显著差异 (V = 12.5, df = 25, p<0.001)

    相关文章

      网友评论

        本文标题:R语言 非参数检验:Mann-Whitney检验和Wilcoxo

        本文链接:https://www.haomeiwen.com/subject/lgowzltx.html