[R] Actual code for LDA

Uwe Ligges ligges at statistik.tu-dortmund.de
Thu Feb 13 15:49:58 CET 2014


On 12.02.2014 15:55, ben1983 wrote:
> Hi All,
>          I've been trying to write my own code for LDA (linear discrim) so I
> can modify it to be weighted LDA since some of my groups are outliers.
>
> However, the code I write for standard LDA gives me slightly different
> results to those from R (slightly different LDAs.....and not just scalar
> differences.
>
> Does R simply invert the pooled within groups scatter matrix e.g. solve(Sw)
> and multiply it by the between groups scatter Sb, then take the eigen
> vectors?
>
> This is the approach that I use, yet get slightly different
> results..........does R by default use a slightly more robust inverse or
> estimate of Sw??


Neither nor, the actual algorithm is more tricky than that.

Swetlana Herbrandt, one of my former master students, wrote her master 
thesis about the lda algorithm used in MASS. The thesis is written in 
German, but the formulas can be read anyway. If you are interested, 
please ask Swetlana (CCed) for a PDF version.

Best,
Uwe Ligges





> I've looked at the source code, and I find it very hard to follow.
>
> If anyone has any ideas that would be great!!
> Thanks,
> Ben
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Actual-code-for-LDA-tp4685194.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.
>




More information about the R-help mailing list