Hello Alejo,
Please, keep sending your post to the R-help mailing list in order other
people can also answer.
The type of lda_analysis is lda and that is normal and it also is
perfectly normal to find a different type for predict(lda_analysis)$x.
Moreover the example of the lda() function about iris gives me the exact
same types for the object z (of the example) and for predict(z).
When you plot lda_analysis, you use the function plot.lda whereas you
use the function plot for the predict object.
As I told you in my previous e-mail the predicted class are not the
class of X$G3 so it is normal if the two plots are not exactly the same.
which(predict(lda_analysis)$class != X$G3) gives you all the
observations that are predicted in a different category from X$G3. Look
at this points and you can see they are the only different points from
the two plots (the coordinates are the same).
Alain
Alejo C.S. wrote:
Hi Alain,
I thought (in the worng way I see) that the predict function applied
to an object of class "lda" returned the coordinates of the
discriminant axes. When doing the same to iris data, the original
classes are the same than those returned by predict. Is not the case
with my data, if you compare the original classes with those returned
by predict(), the are different.
I'm really confused now.......
Regards,
Alejo
2009/10/15, Alain Guillet <alain.guil...@uclouvain.be
<mailto:alain.guil...@uclouvain.be>>:
Hi Alejo,
According to my knowledge the two plots are different because in the
first one a point belongs to a group depending on its group in the
data
whereas in the second plot a point belongs to the group predicted
by the
linear discriminant analysis.
I hope somebody will correct me if I am wrong.
Alain
Alejo C.S. wrote:
Hi Alain, this is the code:
library(MASS)
library(mda)
#data attached, first column "G3" group membership
X <- read.table("data", header=T)
lda_analysis <- lda(formula(X), data=X)
plot(lda_analysis, col=palette()[X$G3])
#the above plot is completely different to:
plot(predict(lda_analysis)$x, type="n")
text(predict(lda_analysis)$x,
labels=predict(lda_analysis)$class,
col=palette()[predict(lda_analysis)$class])
The above code only reproduce the first plot using predict to
obtain coordinates and classes for the first tow discriminant
axis.
Thanks ,
Alejo
--
Alain Guillet
Statistician and Computer Scientist
SMCS - Institut de statistique - Université catholique de Louvain
Bureau c.316
Voie du Roman Pays, 20
B-1348 Louvain-la-Neuve
Belgium
tel: +32 10 47 30 50
--
Alain Guillet
Statistician and Computer Scientist
SMCS - Institut de statistique - Université catholique de Louvain
Bureau c.316
Voie du Roman Pays, 20
B-1348 Louvain-la-Neuve
Belgium
tel: +32 10 47 30 50
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.