[R] Confidence intervals plot

Duncan Murdoch dmurdoch at pair.com
Sat Jun 14 21:33:06 CEST 2003


On Sat, 14 Jun 2003 20:44:09 +0200, you wrote:

>Hi all!!
>
>I am trying to plot several confidence intervals in a unique plot. That is, for each x, I have a confidence interval for a parameter related to x and I would like to plot them in the same plot, in order to compare them. The plot would look like some parallel vertical lines, each one corresponding to a x value. Their extrem points would be the confidence interval limits.

>I do not know if I am clear enough. Anyway, thank you in advance.

Suppose the upper limits are in U, the lower limits in L, and the x
values in X.  Then 

# set up the axes etc.
plot(X, U, ylim=range(c(L,U)), type='n')

segments(X, L, X, U)

will do what you describe.  You should also look at arrows(), in case
you want points or crossbars on the ends of the segments.

Duncan Murdoch




More information about the R-help mailing list