我需要在我的情节中增加二项置信区间。
以下是我的步骤:
library(binom)
library(plotrix)
x <- c(1:6)
y <- c(68, 69, 70, 75, 75, 87)
CI <- binom.confint(y, 265, conf.level = 0.95, methods = "exact")
plot(x, y)
plotCI(x, y, ui = CI$upper, li = CI$lower, add = TRUE)我认为我做的每件事都是正确的,但我的输出图似乎不对:

你有什么建议吗?
发布于 2016-07-27 12:32:41
binom.confint返回比例的置信区间,而不是总数(如果您通过打印CI对象来检查它,您可能已经注意到了这一点)。试一试
plotCI(x,y,ui=CI$upper*CI$n,li=CI$lower*CI$n)(这结合了两个绘图语句来同时绘制点和错误条。)
或者,您可以绘制比例和它们的CIs:
plotCI(x,y/CI$n,ui=CI$upper,li=CI$lower)发布于 2016-07-27 11:02:45
您考虑过使用ggplot2的选项了吗?
geom_smooth给出了线性模型("lm")预测的95%置信区间。
data<-data.frame(y=c(20.7, 18, 21.4, 15.3, 27.3, 20),x=c(1:6))
library(ggplot2)
g<-ggplot(data,aes(x,y))
g+geom_point()+geom_smooth(method="lm")产出如下:

https://stackoverflow.com/questions/38609870
复制相似问题