plotrix:如何在没有y值的情况下绘制CI。y值超出置信区间

plotrix:如何在没有y值的情况下绘制CI。y值超出置信区间,r,R,如何在没有y值的情况下绘制CI。我只想画出时间间隔。这是因为我的y值超出了置信区间 我试过:plotCI(x,y=NULL,ui=U,li=L)其中所有都是数字向量;但它不起作用 现在,如果对于一个条目,y=2、U=4和L=3,则间隔将一直向下到2(而不是向下到3=L) 我需要的是y(其中y可以低于或高于垂直置信区间) 感谢您的帮助。与其深入了解plotCI的功能以及为什么它不能处理缺少的y值,不如使用带有箭头()的老式版本。: x以下是使用点图添加置信区间的示例: 示例代码: ### Cre

如何在没有y值的情况下绘制CI。我只想画出时间间隔。这是因为我的y值超出了置信区间

我试过:
plotCI(x,y=NULL,ui=U,li=L)
其中所有都是数字向量;但它不起作用

现在,如果对于一个条目,
y=2
U=4
L=3
,则间隔将一直向下到
2
(而不是向下到
3=L

我需要的是
y
(其中
y
可以低于或高于垂直置信区间)


感谢您的帮助。

与其深入了解
plotCI
的功能以及为什么它不能处理缺少的y值,不如使用带有
箭头()的老式版本。


x以下是使用点图添加置信区间的示例:

示例代码:

### Create data frame with mean and std dev
x <- data.frame(mean=tapply(mtcars$mpg, list(mtcars$cyl), mean), sd=tapply(mtcars$mpg, list(mtcars$cyl), sd) )

###  Add lower and upper levels of confidence intervals
x$LL <- x$mean-2*x$sd
x$UL <- x$mean+2*x$sd

### plot dotchart with confidence intervals

title <- "MPG by Num. of Cylinders with 95% Confidence Intervals"

dotchart(x$mean, col="blue", xlim=c(floor(min(x$LL)/10)*10, ceiling(max(x$UL)/10)*10), main=title )

for (i in 1:nrow(x)){
    lines(x=c(x$LL[i],x$UL[i]), y=c(i,i))
}
grid()
###使用平均值和标准偏差创建数据框

x“不起作用”到底是什么意思?叹气……好吧,我要咬一口:为什么你的y值超出了你的“置信区间”?我构造了一个简单的例子:x=c(1)y=c(2)U=c(4)L=c(3)plotCI(x,y,ui=U,li=L)plotCI(x,y=NULL,ui=U,li=L)两者产生相同的垂直线。请注意,下限应为3而不是2。我可能做错了什么?谢谢你的帮助。啊,事实上,你使用plotCI的目的远远超出了它的预期目的。我认为,直接使用
points
segments
手动绘制点和线段会更幸运。您的用例并非不合理,但由于原始作者(me/Bill Venables/Greg Warnes)没有预见到,因此该函数无法处理它。从原则上讲,我们可以深入研究到底为什么不这样做,但这可能不值得——很容易生成下面的答案所示的所需图形。
### Create data frame with mean and std dev
x <- data.frame(mean=tapply(mtcars$mpg, list(mtcars$cyl), mean), sd=tapply(mtcars$mpg, list(mtcars$cyl), sd) )

###  Add lower and upper levels of confidence intervals
x$LL <- x$mean-2*x$sd
x$UL <- x$mean+2*x$sd

### plot dotchart with confidence intervals

title <- "MPG by Num. of Cylinders with 95% Confidence Intervals"

dotchart(x$mean, col="blue", xlim=c(floor(min(x$LL)/10)*10, ceiling(max(x$UL)/10)*10), main=title )

for (i in 1:nrow(x)){
    lines(x=c(x$LL[i],x$UL[i]), y=c(i,i))
}
grid()