Learn R Programming

cwhmisc (version 5.0)

ellipse: Generate ellipses

Description

Given the axes a, b and an angle phi (in radian, counter clockwise), and the midpoint coordinates m, points on the ellipse $(y-m)'*A^{(-1)}*(y-m) = const^2$ (with $A = rotL(phi,3) * matrix(c(a,0,0,b), 2, 2)$) will be generated, see rotL.

Usage

ellipse1(k, m, a, b, phi, mlt = 1.0 )
  conf.ellipse(k, m, a, b, phi, df1, df2, level = 0.95)

Arguments

k
the number of generated points on the ellipse.
m
vector c(x, y) containing the midpoint coordinates of the ellipse.
mlt
(positive) expansion factor for axes.
a
major axis
b
minor axis
phi
angle in radian describing the counter clockwise rotation from the x-axis to the major axis.
df1, df2, level
degrees of freedom and probability level of F-distribution.

Value

  • Matrix with columns consisting of x and y coordinates ellipse .. of the ellipse. conf.ellipse .. of the confidence ellipse according to qf(level, df1, df2), see qf.

Examples

Run this code
opar <- par(mfrow=c(1,1))
  k <- 60; m <- c(0,0); a <- 2; b <- 1; phi <- pi/7
  df1 <- 2; df2 <- 20
# show F for different confidence levels:
  p <- c(0.5, 0.75, 0.8, 0.95)
  qf(p, df1, df2) #  0.717735 1.486984 1.746189 3.492828
  el7 <- conf.ellipse(k,m,a,b,phi,df1,df2,p[2])
  plot(el7*1.3,type="n",xlab="Different confidence ellipses",ylab="")
  lines(conf.ellipse(60,m,a,b,phi,df1,df2,p[1]),lty=2,col="red")
  lines(conf.ellipse(60,m,a,b,phi,df1,df2,p[3]),lty=2,col="green")
  lines(conf.ellipse(60,m,a,b,phi,df1,df2,p[4]),lty=2,col="blue")
  lines(el7,lty=2,col="orange")
legend(x="bottom",paste(as.character(p*100),rep("%",length(p)),sep=""),
 col = c("red", "orange","green","blue"), text.col="black", lty = c(2,2,2,2),
 merge = TRUE, bg='white', cex=0.9)
  par(opar)

Run the code above in your browser using DataLab