【发布时间】:2021-11-20 14:31:42
【问题描述】:
我拟合了一个线性混合模型(带有 lmer 函数)。 “比例”作为我的响应变量,“阶段”作为固定因子(有 5 个水平),主题作为随机因子。
LMM.fit<-lmer(Proportion~Stage+(1|Subject),data=tab)
Chisq Df Pr(>Chisq)
Stage 290.07 4 < 2.2e-16 ***
使用 emmeans 函数进行事后成对比较,以确定不同阶段发生的差异:
emmeans(LMM.fit, pairwise ~ Stage)$contrasts
contrast estimate SE df t.ratio p.value
Stage1 - Stage2 0.178 0.0505 105087 3.528 0.0038
Stage1 - Stage3 0.601 0.0363 565787 16.529 <.0001
Stage1 - Stage4 0.438 0.0496 224258 8.833 <.0001
Stage1 - Stage5 0.272 0.0497 295762 5.472 <.0001
Stage2 - Stage3 0.422 0.0514 103631 8.216 <.0001
Stage2 - Stage4 0.260 0.0615 95267 4.224 0.0002
Stage2 - Stage5 0.094 0.0620 107696 1.517 0.5516
Stage3 - Stage4 -0.163 0.0496 229001 -3.279 0.0092
Stage3 - Stage5 -0.328 0.0491 314661 -6.683 <.0001
Stage4 - Stage5 -0.166 0.0599 190576 -2.769 0.0446
Degrees-of-freedom method: kenward-roger
P value adjustment: tukey method for comparing a family of 5 estimates
我基本上想在上面显示的箱线图上添加 emmeans 结果中显示的 p 值(在同一图中两个两个之间的所有组之间)。我知道有函数stat_pvalue_manual(),但我很想知道如何将它与 emmeans contrasts output
【问题讨论】:
标签: r plot boxplot p-value emmeans