[英]plotrix: How to plotCI without the y-values. y-values are outside the confidence interval
如何在没有y值的情况下绘制CI。 我只想绘制间隔。 这是因为我的y值不在置信区间内。
我试过: plotCI(x, y=NULL, ui=U, li=L)
其中所有都是数值向量; 而且没有用
现在,如果对于一个条目y=2
, U=4
和L=3
,则间隔将一直下降到2
(而不是下降到3=L
)
我需要的是y
(其中y
可以低于或高于垂直置信区间)
谢谢你的帮助。
与其深入研究plotCI
功能以及为什么它在缺少y值的plotCI
不起作用的细节, plotCI
使用arrows()
做一个老式的版本:
x <- 1:10
L <- -(1:10)
U <- 1:10
ylim <- range(c(L,U))
plot(x,y=rep(NA,length(x)),type="n",ylim=ylim)
arrows(x,L,x,U,code=3,angle=90,length=0.1)
另请参见http://rwiki.sciviews.org/doku.php?id=tips:graphics-base:errbars
这是一个使用点图添加置信区间的示例:
http://www.r-bloggers.com/r-tutorial-add-confidence-intervals-to-dotchart-2/
示例代码:
### 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()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.