1

First post here, but long-time lurker. I'm working on a batch of multivariate data and want to make comparisons between the standardized coefficients generated by an LDA and the standardized loadings generated by a PCA.

I've read through the posts (and here), where ttnphns and Etienne had a great exchange about PCA and LDA. I'm looking for some code in R to calculate what ttnphns describes as the standardized discriminant coefficients and pooled within-groups correlations between variable and discriminants.

I know that ttnphns offers the formulas for how these are calculated, in the posts above but it would be great to get some snippets of code that the community can use to generate these super-useful sets of values!

Does anybody have any experience with calculating these from the lda function in MASS?

Cheers!

kjetil b halvorsen
  • 63,378
  • 26
  • 142
  • 467
  • Because the formulas were very clear and easy I suppose your question amounts to how one does matrix algebra in R. I hope a kind R user will help you. But does `MASS` package not outputting those coefficients? (asking because I don't know) – ttnphns Sep 27 '16 at 20:52
  • Hahah. Yeah - the MASS package outputs just the non-standardized (though they call them standardized) coefficients, and definitely not the pooled within-groups correlations. If you look at Etienne's notes that he added to your example, you'll see that he mentions this. Not going to lie - my matrix algebra game isn't the strongest. ;) – Keaton Wilson Sep 27 '16 at 22:11

1 Answers1

3

It's a bit weird to answer your own question, I suppose, but hopefully this will be a useful bit of information for folks looking to do this in the future. I used the great package candisc, which has outputs for both the structure matrix and the standardized coefficients! Cheers!