[R] Confidence ellipse for correlation

Tanya Murphy tmurph6 at po-box.mcgill.ca
Tue Oct 28 19:57:36 CET 2003


Hello,

SAS' point and click interface has the option of produce a scatterplot with a 
superimposed confidence ellipse for the correlation coefficient. Since I 
generally like R so much better, I would like to reproduce this in R. I've 
been playing with the ellipse package. In order to have the points and the 
ellipse on the same graph I've done the following. 
(Load ellipse package...)
> data(Puromycin)
> attach(Puromycin)
> my<-mean(rate)
> mx<-mean(conc)
> sdy<-sd(rate)
> sdx<-sd(conc)
> r<-cor(conc,rate)
> plot(ellipse(r,scale=c(sdx,sdy),centre=c(mx,my)),type='l')
> points(conc,rate)

1) Is my use of 'scale' and 'centre' theoretically correct?
2) Is there a more efficient way to get the 5 parameters? (I guess I could 
write a little function, but has it already been done?)

The non-linear relationship between these variables brings up another point: 
Is there a way to plot a contour (empirical?) containing, say, 95% of the 
values.

Thanks for your time!

Tanya




More information about the R-help mailing list