Skip to main content
Updated based on comments and further information
Source Link
David Nichols
  • 1.5k
  • 6
  • 21

This was my initial reply, to which the comments below were directed: I suggest checking carefully to make sure that the data values are identical in the programs, because when I compare results for SPSS and R I get identical results. I've tried with and without ties, and with and without some missing data, and the programs always give the same values.

Follow up after the comments, giving more information:

You're welcome. I suspected that the data were "fuzzy" and the answer you wanted was the one given by SPSS, which required recognizing that A_1 values were tied in some cases with A_2 and/or A_3 values where they were actually slightly different.

The Friedman test involves ranking values within each case across the dependent variables or repeated measures, then applying a standard formula to calculate a test statistic asymptotically distributed as chi-squared under the null hypothesis. The versions of the formula used in SPSS and R appear to be arranged slightly differently, but are equivalent and generally produce the same results to a high level of precision when given the same sets of ranked values.

SPSS is using a "fuzz" check in comparing values to rank the values within each case, while R and Python appear to be taking the values as given. In this situation SPSS seems to be giving the result desired, though what's given in R and Python is closer to expected given exactly the data input.

There is a mystery remaining here for me though, which is why R and Python are getting the precise value they're getting (30.389 to three decimals), when SPSS and R both produce a value of 30.834 if I feed them the ranks within cases based on the original "fuzzy" input data. I thought perhaps R was using a tighter "fuzz" check and determined that a subset of the slight differences SPSS treated as ties were ties, but I couldn't find any value of a "fuzz" check cut off consistent with the data to make that a valid explanation. I can't explain why R is giving different results when fed the original data and the ranks based on the original data, since the calculations involve first creating those ranks and using those instead of the original data values in calculating the test statistic.

I suggest checking carefully to make sure that the data values are identical in the programs, because when I compare results for SPSS and R I get identical results. I've tried with and without ties, and with and without some missing data, and the programs always give the same values.

This was my initial reply, to which the comments below were directed: I suggest checking carefully to make sure that the data values are identical in the programs, because when I compare results for SPSS and R I get identical results. I've tried with and without ties, and with and without some missing data, and the programs always give the same values.

Follow up after the comments, giving more information:

You're welcome. I suspected that the data were "fuzzy" and the answer you wanted was the one given by SPSS, which required recognizing that A_1 values were tied in some cases with A_2 and/or A_3 values where they were actually slightly different.

The Friedman test involves ranking values within each case across the dependent variables or repeated measures, then applying a standard formula to calculate a test statistic asymptotically distributed as chi-squared under the null hypothesis. The versions of the formula used in SPSS and R appear to be arranged slightly differently, but are equivalent and generally produce the same results to a high level of precision when given the same sets of ranked values.

SPSS is using a "fuzz" check in comparing values to rank the values within each case, while R and Python appear to be taking the values as given. In this situation SPSS seems to be giving the result desired, though what's given in R and Python is closer to expected given exactly the data input.

There is a mystery remaining here for me though, which is why R and Python are getting the precise value they're getting (30.389 to three decimals), when SPSS and R both produce a value of 30.834 if I feed them the ranks within cases based on the original "fuzzy" input data. I thought perhaps R was using a tighter "fuzz" check and determined that a subset of the slight differences SPSS treated as ties were ties, but I couldn't find any value of a "fuzz" check cut off consistent with the data to make that a valid explanation. I can't explain why R is giving different results when fed the original data and the ranks based on the original data, since the calculations involve first creating those ranks and using those instead of the original data values in calculating the test statistic.

Source Link
David Nichols
  • 1.5k
  • 6
  • 21

I suggest checking carefully to make sure that the data values are identical in the programs, because when I compare results for SPSS and R I get identical results. I've tried with and without ties, and with and without some missing data, and the programs always give the same values.