Solved – Help in drawing confidence ellipse

confidence intervalmultivariate analysisr

car packages's ellipse function asks for a radius parameter. In help says that is the "radius of circle generating the ellipse". Could you please tell me which circle is this?

Thank you very much

Best Answer

An ellipse can be parametrized as the affine image of any given circle. If we consider the unit circle:

$$x=a \cos (t)$$ $$y=b \sin (t)$$

ellipse(center, shape, radius, log="", center.pch=19, center.cex=1.5, 
  segments=51, add=TRUE, xlab="", ylab="", 
   col=palette()[2], lwd=2, fill=FALSE, fill.alpha=0.3, grid=TRUE, ...)

You can notice the ellipse function asks for the center and the radius of the circle, as well as the covariance matrix, which is equivalent to giving the parameters of the affine transformation.

center  2-element vector with coordinates of center of ellipse.
shape   2 * 2 shape (or covariance) matrix.
radius  radius of circle generating the ellipse.

Let us have a look at the car package function:

ellipse <- t(center + radius * t(unit.circle %*% chol(shape)))

The radius parameter can be set to 1 if you want to use the covariance matrix directly for the shape parameter. I believe it was introduced to help people use normalized matrices instead if they prefer so.


Edit: As mentioned in whuber's comment, the two ellipses below are the same.

> library(car)
> s=matrix(c(1,0,0,1), nrow=2, ncol=2)
> plot(0, 0, xlim=c(-5,5), ylim=c(-5,5))
> ellipse(c(0,0), 4*s, 1)
> ellipse(c(0,0), s, 2)
Related Question