[R] Discriminant Analysis Ellipse

MarcioRibeiro mestat at pop.com.br
Thu Apr 9 22:51:20 CEST 2009


Hi listers,
I am working on a program in order to create an ellipse as a limit of my
observations there are well classified.
I have two independent variables for an quadratic discriminant function
between 2 groups where my mean is zero and my covariance matrix is
proportional.
Q=y'Ay+c
My program follows below with unreal data... My ellipse it's not surrounding
the correct number of classified observations... I am getting more
misclassification than I should...

ellipse<-function(mu,sigma){
p<-2
priori1<-.55
priori2<-.45
gamma<-3
spectral<-eigen(sigma,symmetric=T)
value<-spectral$values
vector<-spectral$vectors
angle<-seq(0,2*pi,length=100)
c<-log(priori1/priori2)+(p/2)*log(gamma) #gamma=proportional constant
y<-c*rbind(sqrt(value[1])*cos(angle),sqrt(value[2])*sin(angle))
t(mu+(vector%*%y))
}
mu=c(0,0)
sigma=matrix(c(6,2,2,7),nrow=2,ncol=2,byrow=TRUE)
x=ellipse(mu,sigma)
par(pty="s")
plot(x[,1],x[,2],xlab="y1",ylab="y2",type="l",main="Graphic",xlim=c(-10,10),ylim=c(-10,10))
data<-cbind(c(1,2,4,6),c(1,3,5,4))
points(data[,1],data[,2],pch="+")

Thanks in advance,
Marcio
-- 
View this message in context: http://www.nabble.com/Discriminant-Analysis-Ellipse-tp22978984p22978984.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list