2

This is a followup on one of my previous question on ellipse. I am looking to find the semi-major and semi-minor axis for an ellipse and the axes for an ellipsoid (3-dimensional). I have looked over other posts. The most relevant is How to obtain the lengths of semi axes of an ellipse? in R I am getting a mixed message. Is the square of the semi-axes, the eigenvalues of the shape matrix, times the average squared radius? For eg heres my r code. Ares a,b and c the semi-principal axes?

library(MASS)
set.seed(1234)
m<-1
x<-NULL
k<-20
Sigma2 <- matrix(c(.58,.49,.37,.49,.58,.38,.37,.38,.34),3,3)
eta<-mvrnorm(k, mu=c(-0.85,-2.09,-1.90), Sigma2)
p1<-exp(eta[,1])/(1+exp(eta[,1]))
p2<-exp(eta[,2])/(1+exp(eta[,2]))
p3<-exp(eta[,3])/(1+exp(eta[,3]))
p<-cbind(p1,p2,p3)
n<-60
x1<-replicate(m,rbinom(k,n,p1))
x2<-replicate(m,rbinom(k,n,p2))
x3<-replicate(m,rbinom(k,n,p3))
x<-cbind(x1,x2,x3)
rate<-x/60
sigma<-var(rate)

library(cluster)
r <- ellipsoidhull(rate)

e <- sqrt(eigen(r$cov)$values)
a <- sqrt(r$d2) * e[1]  # semi-principal axes
b <- sqrt(r$d2) * e[2]
c <- sqrt(r$d2) * e[3]
Community
  • 1
  • 1
user1560215
  • 227
  • 1
  • 13

0 Answers0