[R] Lda versus Rda

Uwe Ligges ligges at statistik.uni-dortmund.de
Sat Nov 6 14:57:39 CET 2004


Julien Trolet wrote:

> Hello,
> 
> I used the lda function from the MASS (VR) package and the rda function 
> from the klaR package.
> I wanted to compare the result of this two functions by using the same 
> training set.
> Thus, I used the rda function with lambda=1 an gamma=0, I should emulate 
> the lda function and I should obtain the same result.
> 
> But this it not the case, the two result are very different.
> 
> My training set is 70 observations * 10 variables long, and I performed 
> a leave one out for each  observations.
> 
> Do somebody have an idea for the cause(s) of this?


With the iris data, the following works for me:

  x1 <- predict(lda(Species~., data=iris))
  x2 <- predict(rda(Species~., data=iris, lambda=1, gamma=0))

  all(x1$class == x2$class)
  all.equal(x1$posterior, x2$posterior)

So, can you specify an example (including data + code, in a private 
message) please?

If your analysis for your data is correct, the error is probably in 
rda(). I won't have time to look at it before monday (and the author of 
the rda() code is in Auckland these days).

It's always a good idea to ask the package maintainer first, BTW.

Uwe Ligges




> Thanks
> 
> Trolet Julien




More information about the R-help mailing list