[R] plotting lda results

Silvia Lomascolo slomascolo at zoo.ufl.edu
Wed Aug 22 22:11:48 CEST 2007


Thanks for trying to answer even if my question isn't very clear. Please
allow me to try again with an example:
I want to predict group membership by the three variables below, and then
plot the results in one figure that compares the frequency of scores of both
groups on the LD obtained:
Group<- c(1,1,1,1,1,1,1,2,2,2,2,2,2,2,2)
var1<- c(2,3,1,2,3,2,3,3,5,6,7,6,8,5,5)
var2<- c(9,9,9,8,7,8,9,3,2,2,1,1,2,3,3)
var3<- c(6,7,6,6,5,6,7,1,2,1,2,3,1,1,2)
data.df <- as.data.frame (cbind(Group, var1, var2, var3)) 
data.lda <- lda(Group~., data=data.df)
predict(data.lda)
plot(data.lda)

As you said, I get two separate figures, one for each group, but I need them
both in one figure.  I tried ldahist by reading the help because it has an
argument sep, but I'm not managing to get it going.

I hope this code is reproducible but I'll certainly read the book suggested
to make my questions easier to answer.

Thanks! Silvia.


Prof Brian Ripley wrote:
> 
> Read ?plot.lda, which tells you the ... arguments are (for dimen=1, the 
> only option for two groups) passed to ldahist, so then read its help page.
> 
> I tried what is suggested plot.lda but 
> 
> I don't know what you want (and your example is not reproducible): I would 
> expect you to get a single plot with two panels (figures), but there are 
> options to have a single panel.  (Reading 'An Introduction to R' may help 
> you to use standard terminology that others will be able to follow.)
> 
> On Wed, 22 Aug 2007, Silvia Lomascolo wrote:
> 
>>
>> Hi all,
>> I am trying to plot the results of a discriminant analysis done with
>> lda(MASS) but my groups appear in two different plots (in the same
>> graphics
>> device) and I want to combine them in one plot. My code looks like:
>>
>> BirdTrain.lda <- lda(Bdisperser~., data=BirdTrain.mx)
>> predict(BirdTrain.lda)
>> plot(BirdTrain.lda)
>>
>> I have two types of Bdisperser, so I only get one linear discriminant
>> function. Can anyone please tell me how to combine the data in one plot?
>>
>> I work with R 2.4.1 using Windows.
> 
> But the version of MASS is what is relevant, and it would have been in 
> the sessionInfo() output the R posting guide asked you for.
> 
> -- 
> Brian D. Ripley,                  ripley at stats.ox.ac.uk
> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
> University of Oxford,             Tel:  +44 1865 272861 (self)
> 1 South Parks Road,                     +44 1865 272866 (PA)
> Oxford OX1 3TG, UK                Fax:  +44 1865 272595
> 
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
> 
> 

-- 
View this message in context: http://www.nabble.com/plotting-lda-results-tf4312870.html#a12282028
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list