rplotrix:如何在没有y值的情况下绘制ci.y值在置信区间之外

  • 本文关键字:ci 区间 绘制 情况下 rplotrix
  • 更新时间 :
  • 英文 :


如何绘制没有y值的ci。我只想把这个区间画出来。这是因为我的y值在置信区间之外。

我尝试:plotCI(x, y=NULL, ui=U, li=L),其中所有是数字向量;它没有工作

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

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

谢谢你的帮助。

与其深入研究plotCI的功能以及为什么它不能处理丢失的y值,不如使用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()

最新更新