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

SPSS results:

Canonical Discriminant Function Coefficients        
                   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?

  • 1
    $\begingroup$ Possibly this stats.stackexchange.com/q/166942/3277 is a duplicate question? Check it. $\endgroup$
    – ttnphns
    Nov 5, 2016 at 8:40
  • 1
    $\begingroup$ @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. $\endgroup$ Nov 5, 2016 at 8:51
  • 1
    $\begingroup$ 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. $\endgroup$
    – ttnphns
    Nov 5, 2016 at 11:08
  • 1
    $\begingroup$ @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. $\endgroup$
    – ttnphns
    Nov 5, 2016 at 11:34
  • 1
    $\begingroup$ @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. $\endgroup$
    – amoeba
    Nov 5, 2016 at 12:40

1 Answer 1


The reason that the R and SPSS gave me different results is that for the SPSS analysis I took the following iris data from UCI website (https://www.kaggle.com/uciml/iris), while for the R software analysis I took the data from Wikipedia. The two iris datasets differ a little (the Wikipedia's one is deemed to be more correct, original one) - hence the results also differ.

See http://archive.ics.uci.edu/ml/datasets/Iris:

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.

All credit should go to @amoeda as can be seen in the below comments

  • $\begingroup$ @amoeba Since you provided the correct answer in a comment, you should put it officially in an answer so that Annaliese Azzopardi can delete her own answer and accept yours. This would not only give you the correct credit (which may not be that important, looking at all the reputation you earned) but also provide everyone searching with the information, that there is an accepted answer. $\endgroup$
    – Bernhard
    Nov 5, 2016 at 13:40
  • 1
    $\begingroup$ @amoeba -Sorry for any inconvenience caused I am new to this...all credit goes to you $\endgroup$ Nov 5, 2016 at 13:43
  • $\begingroup$ @Bernhard: I am actually happy if Annalise accepts her own answer, which I already upvoted! :-) No problem with me at all. I was only pedantically suggesting that she gives a proper credit where it's due. $\endgroup$
    – amoeba
    Nov 5, 2016 at 13:44
  • $\begingroup$ @amoeba -Thanks once again :) I will include you in the answer so as to makes things clear :). $\endgroup$ Nov 5, 2016 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.