Dear Users! I think I still have some problems in understanding LDA and the methods of plotting the results. The case is the following: I'm having a dataset containing two classes where each datapoint has 19 dimensions. Training with lda(...) works fine, and I'm getting 19 LD coefficients. So far so good. Now I want to visualize the result, and here is where my simple knowledge ends. What I simply want to do is doing a scatterplot on two dimensions and then plotting the projected hyperplane in order to see the dividing line. The scatterplot I'm doing with plot(class1[1:100,1], class1[1:100,2]) points(class2[1:100,1], class2[1:100,2]) but now I face with the problem of determining the intercept for abline(...) (the slope should be -LD[1]/LD[2] I think...). What I really don't understand is the result of plot.lda(...). As a result it gives two histograms, each one for one class. So which distributions are shown there? And why does it only plot a scatterplot when I have three classes? Thank you very much in advance! Greetings, Matthias -- View this message in context: http://r.789695.n4.nabble.com/Plotting-LDA-results-tp4637766.html Sent from the R help mailing list archive at Nabble.com.
On 25.07.2012 13:52, Meffy wrote:> Dear Users! > I think I still have some problems in understanding LDA and the methods of > plotting the results. > The case is the following: I'm having a dataset containing two classes where > each datapoint has 19 dimensions. Training with lda(...) works fine, and I'm > getting 19 LD coefficients. So far so good. Now I want to visualize the > result, and here is where my simple knowledge ends. What I simply want to do > is doing a scatterplot on two dimensions and then plotting the projected > hyperplane in order to see the dividing line. The scatterplot I'm doing with > > plot(class1[1:100,1], class1[1:100,2]) > points(class2[1:100,1], class2[1:100,2]) > > but now I face with the problem of determining the intercept for abline(...) > (the slope should be -LD[1]/LD[2] I think...).The scatterplot shows a projection on the first two linear discriminant components, the histogram is the projection on the first component only.> What I really don't understand is the result of plot.lda(...). As a result > it gives two histograms, each one for one class. So which distributions are > shown there?>> And why does it only plot a scatterplot when I have three > classes?If you have two classes, there will only be one component. No chance two invent a second dimension. Uwe Ligges> Thank you very much in advance! > Greetings, Matthias > > > > > > > > > -- > View this message in context: http://r.789695.n4.nabble.com/Plotting-LDA-results-tp4637766.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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. >
Thank you! Still not clear...I can plot two of my data dimensions against each other where I see two separated clouds. So it must be possible to determine the coefficients of the dividing line from the model I get from lda(...), or am I completely wrong now...? -- View this message in context: http://r.789695.n4.nabble.com/Plotting-LDA-results-tp4637766p4637780.html Sent from the R help mailing list archive at Nabble.com.
You asked why you could not get two discriminant functions and that question was answered. The number of discriminant functions is one less than the number of groups (assuming you have more variables than groups). Now you are asking a different question. How to plot the discriminant boundary between the groups in a plot of the original variables. Time to provide "provide commented, minimal, self-contained, reproducible code" [including data] as called for at the bottom of your message. ---------------------------------------------- David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77843-4352> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of Meffy > Sent: Wednesday, July 25, 2012 8:23 AM > To: r-help at r-project.org > Subject: Re: [R] Plotting LDA results > > Thank you! > Still not clear...I can plot two of my data dimensions against each > other > where I see two separated clouds. So it must be possible to determine > the > coefficients of the dividing line from the model I get from lda(...), > or am > I completely wrong now...? > > > > -- > View this message in context: http://r.789695.n4.nabble.com/Plotting- > LDA-results-tp4637766p4637780.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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.