[R] Confidence ellipse for correlation

John Fox jfox at mcmaster.ca
Wed Oct 29 02:43:51 CET 2003


Dear Tanya,

I believe that the data.ellipse function in the car package will do what 
you want (but note that the probability contours are for a bivariate-normal 
distribution, and hence won't necessarily enclose approximately the 
specified proportion of the data).

I hope that this helps,
  John

At 01:57 PM 10/28/2003 -0500, you wrote:
>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

-----------------------------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario, Canada L8S 4M4
email: jfox at mcmaster.ca
phone: 905-525-9140x23604
web: www.socsci.mcmaster.ca/jfox




More information about the R-help mailing list