首页 > 解决方案 > ggpubr (stat_compare_means) 中是否有一种方法可以在假设方差相等的情况下运行测试比较(而不是 R 默认 Welch 的 t 检验)

问题描述

我想使用stat_compare_means()ggpubr 包添加两个独立组之间比较的显着性水平。

使用 时method = "t.test",假设方差不相等,该函数将运行 Welch t 检验。

如果使用 base Rt.test()我会添加var.equal=TRUE,但我在 ggpubr 中找不到这样做的方法?

ggstripchart(dat, x = "Group", error.plot = "errorbar", # Add error bars 
with SD
y = "tcm_cd4", combine = TRUE, color = "Group", size = 7, # Size of 
# shapes.
shape = "Group", # Change shape according to Group
add = c("mean_sd", "mean"),
jitter = 0.2, add.params = list(size = 1.4, color = "darkblue"),
font.label = list(size = 14, face = "bold")) + 
stat_compare_means(method = "t.test", label = "p.format", 
bracket.size = 1, 
tip.length = 0,
comparisons=list(c(1,2), c(1,3), c(2,3)))

假设方差相等,我需要该函数来运行 t 检验。

标签: rggpubr

解决方案


没有数据很难回答,但你试过这个method.args =论点吗?

+ stat_compare_means(method = "t.test",
                     method.args = list(var.equal = TRUE), 
                     label = "p.format", 
                     bracket.size = 1, 
                     tip.length = 0,
                     comparisons=list(c(1,2), c(1,3), c(2,3)))

推荐阅读