Learn R Programming

cwhmisc (version 6.0)

ellipse: Generate ellipses

Description

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

Usage

ellipse1(k, a, b=a, ra=c(-1,361), phi=0 )
  conf.ellipse(k, a, b, phi, df1, df2, level = 0.95)

Arguments

k
the number of generated points on the ellipse.
a
major axis
b
minor axis
ra
range of arc [deg]
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,a,b,phi,df1,df2,p[2]) + m
  plot(el7*1.3,type="n",xlab="Different confidence ellipses",ylab="")
  lines(conf.ellipse(60,a,b,phi,df1,df2,p[1]) + m,lty=2,col="red")
  lines(conf.ellipse(60,a,b,phi,df1,df2,p[3]) + m,lty=2,col="green")
  lines(conf.ellipse(60,a,b,phi,df1,df2,p[4]) + m,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