How to generate a compact letter display for pairwise TukeyHSD

时光总嘲笑我的痴心妄想 提交于 2021-01-07 03:24:52

问题


I'm having trouble generating a compact letter display for my results. I've run an ANOVA followed by Tukey's HSD to generate the p values for each pair, but I do not know how (or if it is possible?) to assign letters to these p values to show which pairs are significant from each other.

csa.anova<-aov(rate~temp*light,data=csa.per.chl) summary(csa.anova) TukeyHSD(csa.anova)

This runs the tests I need, but I don't know how to assign letters to each p value to show which pairs are significant.


回答1:


You need to install the multcomp package first. It can compute the Tukey HSD Test and returns an object that has summary and plot methods. The package also has a function (cld) to print the "compact letter display." As an example we can use the iris data set that comes with R:

library(multcomp)
data(iris)
iris.aov <- aov(Petal.Length~Species, iris)
iris.tukey <- glht(iris.aov, linfct=mcp(Species="Tukey"))
cld(iris.tukey)
#     setosa versicolor  virginica 
#        "a"        "b"        "c" 



回答2:


I cannot make this code work:

data("iris")
iris.aov<-aov(Petal.Length~Species,iris)
iris.tukey<-glht(iris.aov,linfct=mcp(Species="Tukey"))

Here is the error triggered:

Error in glht(iris.aov, linfct = mcp(Species = "Tukey")) : could not find function "glht"



来源:https://stackoverflow.com/questions/57737598/how-to-generate-a-compact-letter-display-for-pairwise-tukeyhsd

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!