1
$\begingroup$

I used the Friedman test to compare three repeated measures and I use Kendall’s Coefficient of Concordance (W) to get its effect size.

SPSS uses this formula: F (from Friedman test)/n_f (k-1), and I implemented it like and it returns similar value to SPSS:

stat/(k*(m-1))

I also used python, however, using the original Kendall’s Coefficient of Concordance (W) formula, but it yields very different outputs. Why is that and which one is mathematically correct?

Here is my function in python:

def my_friedman_test(q1, q2, q3, expt_ratings): 

    stat, p = friedmanchisquare(q1, q2, q3)
    print('stat=%.3f, p=%.3f' % (stat, p))
    if p > 0.05:
        print('Friedman Test: Probably the same distribution, the distributions of all samples are equal.')
    else:
        print('Friedman Test:Probably different distributions, the distributions of one or more samples are not equal.')

# Kendall’s W  
    if expt_ratings.ndim!=2:
        raise 'ratings matrix must be 2-dimensional'
    m = expt_ratings.shape[1] #raters
    k = expt_ratings.shape[0] # items rated

    print(stat/(k*(m-1)))

    rating_sums = np.sum(expt_ratings, axis=1)
    S = k*np.var(rating_sums)

    W= (12*S)/((m**2)*(k**3-k))
    print ("raters: ",m," items rated: ", k, "and W= ",'%.8f' % W)
    print("---------------------------------------------")
    return
$\endgroup$

2 Answers 2

3
$\begingroup$

In this context, as a tolerance when comparing numbers for equality. Instead of doing an exact comparison like

a = b

with true of false, one does

|a - b| <= fuzz_setting

when assessing whether two numbers are equal. This is necessitated in many contexts with digital computation. In this specific situation, SPSS treats values as equal when they're very close, while Python is comparing them in terms of absolute comparisons among the bit patterns and calling them different whenever these don't match exactly.

$\endgroup$
1
$\begingroup$

I believe this is the same issue as in this question about the Friedman statistic. The answer has to do with "fuzz" in the input data that's being treated differently in the different packages.

$\endgroup$
1
  • $\begingroup$ How are you defining "fuzz"? $\endgroup$
    – Galen
    Commented Nov 3, 2021 at 22:42

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.