[R] plot discriminant analysis

2009-10-14 Thread Alejo C.S.
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)

BG   M
  B  2903
  G0  26   2
  M   40  46


any clues?
Regards,
__
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.


Re: [R] plot discriminant analysis

2009-10-14 Thread Alain Guillet

Hi,

I did it with

Iris - data.frame(rbind(iris3[,,1], iris3[,,2], iris3[,,3]), Sp = 
rep(c(s,c,v), rep(50,3)))

train - sample(1:150, 75) table(Iris$Sp[train])
z - lda(Sp ~ ., Iris, prior = c(1,1,1)/3, subset = train)

Then I did plot(z,xlim=c(-10,10),ylim=c(-10,10)) before drawing 
points(predict(z)$x, 
col=palette()[predict(z)$class],xlim=c(-10,10),ylim=c(-10,10)) and all 
the points are superimposed. The only difference I found was the 
different x- and y-axis when I drew them separately, i.e.

plot(z)
plot(predict(z)$x, col=palette()[predict(z)$class])


Alain



Alejo C.S. wrote:

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)

BG   M
  B  2903
  G0  26   2
  M   40  46


any clues?
Regards,
  



__
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.
  


--
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.


Re: [R] plot discriminant analysis

2009-10-14 Thread Alejo C.S.
Hi Alain, thanks for the fast response. I've the same results with iris
data, but when I use my data (mentioned in the first message), I have
different results.

Regards,

Alejo

2009/10/14 Alain Guillet alain.guil...@uclouvain.be

 Hi,

 I did it with

 Iris - data.frame(rbind(iris3[,,1], iris3[,,2], iris3[,,3]), Sp =
 rep(c(s,c,v), rep(50,3)))
 train - sample(1:150, 75) table(Iris$Sp[train])
 z - lda(Sp ~ ., Iris, prior = c(1,1,1)/3, subset = train)

 Then I did plot(z,xlim=c(-10,10),ylim=c(-10,10)) before drawing
 points(predict(z)$x,
 col=palette()[predict(z)$class],xlim=c(-10,10),ylim=c(-10,10)) and all the
 points are superimposed. The only difference I found was the different x-
 and y-axis when I drew them separately, i.e.
 plot(z)
 plot(predict(z)$x, col=palette()[predict(z)$class])


 Alain



 Alejo C.S. wrote:

 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)

BG   M
  B  2903
  G0  26   2
  M   40  46


 any clues?
 Regards,
  

 __
 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.



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



[[alternative HTML version deleted]]

__
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.


Re: [R] plot discriminant analysis

2009-10-14 Thread David Winsemius


On Oct 14, 2009, at 12:24 PM, Alejo C.S. wrote:

Hi Alain, thanks for the fast response. I've the same results with  
iris

data, but when I use my data (mentioned in the first message),


You are apparently under the false impression that the data made it  
through the listserv. Read the Posting Guide to find out why that  
impression is false.




I have
different results.

Regards,

Alejo

2009/10/14 Alain Guillet alain.guil...@uclouvain.be


Hi,

I did it with

Iris - data.frame(rbind(iris3[,,1], iris3[,,2], iris3[,,3]), Sp =
rep(c(s,c,v), rep(50,3)))
train - sample(1:150, 75) table(Iris$Sp[train])
z - lda(Sp ~ ., Iris, prior = c(1,1,1)/3, subset = train)

Then I did plot(z,xlim=c(-10,10),ylim=c(-10,10)) before drawing
points(predict(z)$x,
col=palette()[predict(z)$class],xlim=c(-10,10),ylim=c(-10,10)) and  
all the
points are superimposed. The only difference I found was the  
different x-

and y-axis when I drew them separately, i.e.
plot(z)
plot(predict(z)$x, col=palette()[predict(z)$class])


Alain



Alejo C.S. wrote:

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)

  BG   M
B  2903
G0  26   2
M   40  46


any clues?
Regards,


__
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.




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




[[alternative HTML version deleted]]

__
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.


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
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.