Learn R Programming

cwhmisc (version 4.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) = cn^2$ with $A = rotL(phi,2,1,2) * matrix(c(a,0,0,b), 2, 2)$ will be generated, see rotL.

Usage

ellipse(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

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

Examples

Run this code
m <- c(2,7); a<-5; b<-2; 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
 # error in check but not in direct execution
  el7 <- conf.ellipse(60,m,a,b,phi,df1,df2,p[2])
  plot(el7,type="n",xlab="",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)

Run the code above in your browser using DataLab