R语言教程之群体差异的非参数检验Nonparametric Tests of Group Differences
当前位置:以往代写 > R语言教程 >R语言教程之群体差异的非参数检验Nonparametric Tests of Group Differences
2019-06-13

R语言教程之群体差异的非参数检验Nonparametric Tests of Group Differences

R语言教程之群体差异的非参数检验Nonparametric Tests of Group Differences

R提供执行Mann-Whitney U,Wilcoxon签名排名,Kruskal Wallis和Friedman测试的功能。

# independent 2-group Mann-Whitney U Test 
wilcox.test(y~A) 
# where y is numeric and A is A binary factor

# independent 2-group Mann-Whitney U Test
wilcox.test(y,x) # where y and x are numeric

# dependent 2-group Wilcoxon Signed Rank Test 
wilcox.test(y1,y2,paired=TRUE) # where y1 and y2 are numeric

# Kruskal Wallis Test One Way Anova by Ranks 
kruskal.test(y~A) # where y1 is numeric and A is a factor

# Randomized Block Design - Friedman Test 
friedman.test(y~A|B)
# where y are the data values, A is a grouping factor
# and B is a blocking factor

对于wilcox.test,您可以使用alternative =“less”alternative =“greater”选项来指定单尾测试。

参数重新取样的替代品是可用的。

软件包pgirmess提供了非参数多重比较。(注意:该软件包已被撤销,但仍可在CRAN档案中找到。)

library(npmc)
npmc(x) 
# where x is a data frame containing variable 'var' 
# (response variable) and 'class' (grouping variable)

可视化结果

使用箱形图密度图来显示组的差异。

来练习

这个交互式示例允许您使用R练习Wilcoxon签名排名测试。

    关键字:

在线提交作业