Learn R Programming

rrcov (version 1.7-6)

getEllipse: Calculates the points for drawing a confidence ellipsoid

Description

A simple function to calculate the points of a confidence ellipsoid, by default dist=qchisq(0.975, 2)

Usage

getEllipse(loc = c(0, 0), cov = matrix(c(1, 0, 0, 1), ncol = 2), crit = 0.975)

Value

A matrix with two columns containing the calculated points.

Arguments

loc

location vector

cov

a pXp covariance matrix

crit

the confidence level, default is crit=0.975

Author

Valentin Todorov, valentin.todorov@chello.at

Examples

Run this code

data(hbk)
cc <- cov.wt(hbk)
e1 <- getEllipse(loc=cc$center[1:2], cov=cc$cov[1:2,1:2])
e2 <- getEllipse(loc=cc$center[1:2], cov=cc$cov[1:2,1:2], crit=0.99)
plot(X2~X1, data=hbk,
    xlim=c(min(X1, e1[,1], e2[,1]), max(X1,e1[,1], e2[,1])),
    ylim=c(min(X2, e1[,2], e2[,2]), max(X2,e1[,2], e2[,2])))
lines(e1, type="l", lty=1, col="red")
lines(e2, type="l", lty=2, col="blue")
legend("topleft", legend=c(0.975, 0.99), lty=1:2, col=c("red", "blue"))

Run the code above in your browser using DataLab