我可以使用 geom_smooth 轻松地在 ggplot2 scatterplot 中为相关数据绘制回归线置信区间 . 但是我不知道如何使用引导程序的结果来可视化引导置信区间 .

考虑以下:

library(bootES) # Library for easy bootstrapping

set.seed(5); x <- sample(50)
set.seed(6); y <- sample(50)

    biv.dat <- data.frame(x,y) # Example dataset

执行biv.dat的bootstrap并使用百分位数方法计算95%CI:

bootES(data = biv.dat, ci.conf = 0.95, ci.type = "perc") 

95.00% perc Confidence Interval, 2000 replicates
Stat        CI (Low)    CI (High)   bias        SE          
0.040       -0.243      0.336       0.008       0.149

使用ggplot2绘制散点图:

plot <- ggplot() + geom_point(aes(x = biv.dat[,1], y = biv.dat[,2]))

如何在我的情节中使用 CI (low) = -0.243CI (high) = 0.336 可视化置信区间?