# Why are Discriminant analysis in SPSS and R are not giving me the same results (iris data)?

I tried the Iris Species lda problem in SPSS and R, but the scalings are different. Why?

SPSS results:

Canonical Discriminant Function Coefficients
Function
1      2
SepalLengthCm    -.819   .033
SepalWidthCm    -1.548  2.155
PetalLengthCm    2.185  -.930
PetalWidthCm     2.854  2.806
(Constant)      -2.119 -6.639


R results:

Coefficients of linear discriminants:
LD1 LD2
Sepal.Length  0.8293776  0.02410215
Sepal.Width   1.5344731  2.16452123
Petal.Length -2.2012117 -0.93192121
Petal.Width  -2.8104603  2.83918785


I know that the signs for the discriminant analysis is just a matter of coding but the scores differ by some 0.01 for all.

Does anyone know what estimate SPSS and R uses to solve LDA?

• Possibly this stats.stackexchange.com/q/166942/3277 is a duplicate question? Check it. – ttnphns Nov 5 '16 at 8:40
• @ttnphns - I had already checked the above question but it is clear in that question that the only difference is that the SPSS rounds to 3 decimal places while R doesn't. In my example some of the scores differ by 0.02, 0.01 and I need to check whether the two software maybe use different estimates. – Annalise Azzopardi Nov 5 '16 at 8:51
• This syntax produced me right now correct results ("R results"). There must be something wrong with your data in SPSS (missing values? case filtering? wrong values in the data?) I don't thing your SPSS has a bug (what version are you using?) Take iris from stats.stackexchange.com/q/82497/3277 and test again. – ttnphns Nov 5 '16 at 11:08
• @amoeba, SPSS has no iris data included. I used the data I linked just above which in turn was taken from wikipedia, I recommed the OP to test on that dataset. – ttnphns Nov 5 '16 at 11:34
• @ttnphns I can confirm that when LDA is done in Python using Python's version of the Iris data (taken from the UCI website), the results are identical to the OP's results in SPSS (example: sebastianraschka.com/Articles/2014_python_lda.html). So this must be the issue: OP most likely downloaded the data from UCI dataset. If Annalise confirms this, it would be useful to write it up as an answer for future reference. – amoeba Nov 5 '16 at 12:40

This data differs from the data presented in Fishers article [...]. The 35th sample should be: 4.9,3.1,1.5,0.2,"Iris-setosa" where the error is in the fourth feature. The 38th sample: 4.9,3.6,1.4,0.1,"Iris-setosa" where the errors are in the second and third features.