成对测试的紧凑字母显示
Compact letter display from pairwise test
我想根据我在线性混合效应模型 (lmer) 上进行的 post-hoc 测试创建一个紧凑的字母显示
这里是我做成对时想要的示例 t.test
df <- read.table("https://pastebin.com/raw/Dzfh7b2f", header=T,sep="")
library(rcompanion)
library(multcompView)
PT <- pairwise.t.test(df$fit,df$treatment, method=bonferroni)
PT = PT$p.value
PT1 = fullPTable(PT)
multcompLetters(PT1,
compare="<",
threshold=0.05,
Letters=letters,
reversed = FALSE)
这很有效,因为从成对的t.test,很容易简单地提取 p 值,并创建 table I想。
现在假设我 运行 一个线性模型,进行成对比较,并且还想创建一个 table,就像我上面所做的那样,它为我创建了一个紧凑的字母显示提取的 pvalues
library(multcomp)
mult<- summary(glht(model, linfct = mcp(treatment = "Tukey")), test = adjusted("holm"))
mult
我可以看到 p 值,但在过去的 2-3 小时里,我一直在试图弄清楚如何提取这些值(就像我在上面对成对所做的那样。t.test),随后,创建一个紧凑的字母显示 table.
非常感谢任何帮助。祝一切顺利
感谢@roland的建议,答案很简单:
mult<- summary(glht(model, linfct = mcp(treatment = "Tukey")), test = adjusted("holm"))
letter_display <- cld(mult)
letter_display
查找更多详细信息here。
mod <- lm(Sepal.Width ~ Species, data = iris)
mod_means_contr <- emmeans::emmeans(object = mod,
pairwise ~ "Species",
adjust = "tukey")
mod_means <- multcomp::cld(object = mod_means_contr$emmeans,
Letters = letters)
### Bonus plot
library(ggplot2)
ggplot(data = mod_means,
aes(x = Species, y = emmean)) +
geom_point() +
geom_errorbar(aes(ymin = lower.CL,
ymax = upper.CL),
width = 0.2) +
geom_text(aes(label = gsub(" ", "", .group)),
position = position_nudge(x = 0.2)) +
labs(caption = "Means followed by a common letter are\nnot significantly different according to the Tukey-test")
由 reprex package (v2.0.0)
于 2021-06-03 创建
我想根据我在线性混合效应模型 (lmer) 上进行的 post-hoc 测试创建一个紧凑的字母显示
这里是我做成对时想要的示例 t.test
df <- read.table("https://pastebin.com/raw/Dzfh7b2f", header=T,sep="")
library(rcompanion)
library(multcompView)
PT <- pairwise.t.test(df$fit,df$treatment, method=bonferroni)
PT = PT$p.value
PT1 = fullPTable(PT)
multcompLetters(PT1,
compare="<",
threshold=0.05,
Letters=letters,
reversed = FALSE)
这很有效,因为从成对的t.test,很容易简单地提取 p 值,并创建 table I想。
现在假设我 运行 一个线性模型,进行成对比较,并且还想创建一个 table,就像我上面所做的那样,它为我创建了一个紧凑的字母显示提取的 pvalues
library(multcomp)
mult<- summary(glht(model, linfct = mcp(treatment = "Tukey")), test = adjusted("holm"))
mult
我可以看到 p 值,但在过去的 2-3 小时里,我一直在试图弄清楚如何提取这些值(就像我在上面对成对所做的那样。t.test),随后,创建一个紧凑的字母显示 table.
非常感谢任何帮助。祝一切顺利
感谢@roland的建议,答案很简单:
mult<- summary(glht(model, linfct = mcp(treatment = "Tukey")), test = adjusted("holm"))
letter_display <- cld(mult)
letter_display
查找更多详细信息here。
mod <- lm(Sepal.Width ~ Species, data = iris)
mod_means_contr <- emmeans::emmeans(object = mod,
pairwise ~ "Species",
adjust = "tukey")
mod_means <- multcomp::cld(object = mod_means_contr$emmeans,
Letters = letters)
### Bonus plot
library(ggplot2)
ggplot(data = mod_means,
aes(x = Species, y = emmean)) +
geom_point() +
geom_errorbar(aes(ymin = lower.CL,
ymax = upper.CL),
width = 0.2) +
geom_text(aes(label = gsub(" ", "", .group)),
position = position_nudge(x = 0.2)) +
labs(caption = "Means followed by a common letter are\nnot significantly different according to the Tukey-test")
由 reprex package (v2.0.0)
于 2021-06-03 创建