Pietrzykowski, Matthew (GE, Research)
2008-Jan-18 18:49 UTC
[R] forming a linear discriminant function from the output of lda()
Hello all- I am a relatively new user of R and am working through a graduate course in Statistics that uses Minitab, SAS and some Matlab. I like using R but am having some trouble lining up the output from lda() to that of the other programs' results. The dataset below is a modified set of wine data from the Pinot Noir data set as an illustration of the 2 group LDA scenario. Mo Ba Region 1 0.058 0.225 3 2 0.071 0.105 3 3 0.147 0.301 2 4 0.116 0.166 3 5 0.166 0.132 3 6 0.261 0.078 3 7 0.191 0.085 3 8 0.009 0.072 3 9 0.027 0.094 3 10 0.030 0.349 2 11 0.268 0.099 3 12 0.245 0.071 3 13 0.161 0.181 2 14 0.146 0.328 2 15 0.155 0.081 3 16 0.126 0.299 2 17 0.211 0.206 2 18 0.129 0.281 2 19 0.166 0.292 2 20 0.199 0.292 2 21 0.208 0.087 3 There are various displays from SAS, Minitab and Matlab's Statistics Toolbox, but they all agree with the final linear discriminant function: 0 = -19.51 + 21.47*Mo + 84.08*Ba. When I run the following code in R:> library(MASS) > wine.lda <- lda(Region ~ Mo + Ba, data = wine, prior = c(1,1)/2) > wine.ldaCall: lda(Region ~ Mo + Ba, data = wine, prior = c(1, 1)/2) Prior probabilities of groups: 2 3 0.5 0.5 Group means: Mo Ba 2 0.1461111 0.2810000 3 0.1479167 0.1079167 Coefficients of linear discriminants: LD1 Mo -5.636024 Ba -22.069187 I am having trouble going from the cofficients derived from the spherical within group covariance to the function I am able to obtain in the other programs. The rest of the problem set up for all programs are: Region = group assignment, prior = equal priors and I do not do any data pretreatment prior to analysis. Any help would be great. Thanks, Matt [[alternative HTML version deleted]]