ShixiangWang / MessageBoard

诗翔的留言板,用于博客评论和交流
5 stars 2 forks source link

单因素方差分析时的问题 #49

Closed levinyi closed 5 years ago

levinyi commented 5 years ago

就是单因素方差分析的时候,有些图(比如boxplot)上会标a,b我想问下这里的a,b是什么意思?怎么计算出来的,怎么画上去?

别人的图: image

下面是我画的图,想在图中标上a,b,应该怎么标? image

我的图代码是模仿下面这里:

ggbarplot(PlantGrowth, x = "group", y = "weight", add = "mean_se",
          color = "group",fill="group", palette = "jco")+
  stat_compare_means(label.y = 11,method = "anova") +    # Global p-value
  stat_compare_means(comparisons = my_comparisons,label.y = c(7,9, 8),method="t.test")+
  scale_y_continuous(expand=c(0,0))
levinyi commented 5 years ago

我知道P value > 0.05 was considered to be statistically significant and indicated by “b” and P < 0.05 was indicated by “a” ,但是两个柱子不是才有一个p value吗,用什么什么值跟这个p做比较呢

ShixiangWang commented 5 years ago

这个确实理解很抽象,我一下子也没看懂。根据图文,应该是用a b 表示不同的分布,如果2个柱子分布相同,都是a,那么就是说没有显著差异,样本来自同一总体。如果是a b 则表示数据来自不同的总体,即存在差异。

先算每个bar要加什么,然后计算y轴的刻度,加上去就可以了。

ggbarplot(PlantGrowth, x = "group", y = "weight", add = "mean_se",
          color = "group",fill="group", palette = "jco") + 
geom_text(aes(label=weight), 
                 data=PlantGrowth %>% dplyr::group_by(group) %>% dplyr::summarise(weight=mean(weight)), 
                vjust=2)

image

ggbarplot(PlantGrowth, x = "group", y = "weight", add = "mean_se",
          color = "group",fill="group", palette = "jco") + geom_text(aes(y=weight, label="a"), data=PlantGrowth %>% dplyr::group_by(group) %>% dplyr::summarise(weight=mean(weight)), vjust=2)

image

ggbarplot(PlantGrowth, x = "group", y = "weight", add = "mean_se",
          color = "group",fill="group", palette = "jco") + geom_text(aes(y=weight, label=c("a", "b", "c")), data=PlantGrowth %>% dplyr::group_by(group) %>% dplyr::summarise(weight=mean(weight)), vjust=2)

image

ShixiangWang commented 5 years ago

我建议不要用 a b 这种方式。

levinyi commented 5 years ago

感谢大佬,一眼就能看出问题,膜拜一下。我也好好学习去了