[R] plot discriminant analysis
Alejo C.S.
alej.c.s at gmail.com
Wed Oct 14 14:20:07 CEST 2009
I'm confused on how is the right way to plot a discriminant analysis made by
lda function (MASS package).
(I had attached my data fro reproduction). When I plot a lda object :
X <- read.table("data", header=T)
lda_analysis <- lda(formula(X), data=X)
plot(lda_analysis)
#the above plot is completely different to:
plot(predict(lda_analysis)$x, col=palette()[predict(lda_analysis)$class])
that should be the same graph than the first?
In the second case, I use predict function to obtain the LD1 and LD2
coordinates of lda_analysis (predict(lda_analysis)$x) and it's respective
class (predict(lda_analysis)$class), but it seems that the classes are
different:
table(X$G3, predict(lda_analysis)$class)
B G M
B 29 0 3
G 0 26 2
M 4 0 46
any clues?
Regards,
More information about the R-help
mailing list