箱形图具有几何平均值和CI 95%

时间:2018-06-07 13:03:31

标签: r

我一直在尝试用几何方法用下面的函数编写一个盒子图。然而,虽然中位数Q1,Q3(方框的边界)与我的计算一致,但是胡须与我计算出的95%CI不符,我真的无法弄清楚为什么这样或者胡须实际显示的是什么。

   bp.vals <- function(x, probs = c(0.05, 0.25, 0.75, .95)) {
    r <- quantile(x, probs = probs, na.rm = TRUE)
    r = c(r[1:2], exp(mean(log(x))), r[3:4])
    names(r) <- c("ymin", "lower", "middle", "upper", "ymax")
    r
}

ggplot(data_7m, aes(
    x = factor(BCG),
    y = IPVtype1_7m,
    fill = Group,
    width = 0.4
)) + scale_fill_manual(values = c("dark grey", "light grey")) +
    stat_summary(fun.data = bp.vals, geom = "boxplot", show.legend = F) + 
labs(x = "", y = "GMC of antibodies against poliomyelitis type 1 (IU/mL)")

我的计算geometric mean 36.40 (CI 95% (27.76-47.75), Q1 21.49, median 40.29, Q3 67.84, max 173.11, min 2.33, sd 38.58

Box plots of geometric means

0 个答案:

没有答案