美文网首页
R统计分析_变量同质性检验

R统计分析_变量同质性检验

作者: 谢俊飞 | 来源:发表于2020-02-20 20:03 被阅读0次

    英文:http://www.cookbook-r.com/Statistical_analysis/Homogeneity_of_variance/
    中文:https://openbiox.github.io/Cookbook-for-R-Chinese/section-7.html#section-7.6
    像t检验、ANOVA等统计分析都有适用条件,在进行数据分析时,首先需要对数据进行符合他条件的相应检验,才能进行下一步的统计分析。
    There are many ways of testing data for homogeneity of variance. Three methods are shown here.

    • Bartlett’s test:如果数据服从正态性,则此方法比较好。它对于非正态分布数据比较敏感,并返回一个“假阳性”结果。
    • Levene’s test:比 Bartlett’s test更加稳健的方法(内置于car包)。
    • Fligner-Killeen test :对于偏离正态数据非常稳健的一种非参数检验。
    head(InsectSprays)
    tg <- ToothGrowth
    tg$dose <- factor(tg$dose)
    head(tg)
    plot(count~spray, data = InsectSprays)
    plot(len~interaction(dose, supp), data = ToothGrowth)
    
    #有多个独立变量,必须使用 interaction() 函数将这些独立变量包裹为含所有因子组合的单个变量。
    #如果不适应,那么会得到错误的自由度,因而 p 值也将是错误的。
    #Bartlett’s test
    bartlett.test(count~spray, data = InsectSprays)
    bartlett.test(len~interaction(dose, supp), data = ToothGrowth)
    bartlett.test(len~dose, data = ToothGrowth)
    
    #Levene’s test
    library(car)
    leveneTest(count~spray, data = InsectSprays)
    leveneTest(len~dose*supp, data = tg)
    
    #Fligner-Killeen test
    fligner.test(count~spray, data = InsectSprays)
    fligner.test(len~interaction(dose, supp), data = ToothGrowth)
    fligner.test(len~dose, data = ToothGrowth)
    
    
    Rplot01.png Rplot02.png

    相关文章

      网友评论

          本文标题:R统计分析_变量同质性检验

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