1
$\begingroup$

I am researching how to calculate Somers' D in python for a discrete dependent variable and continuous independent variable, I found this answer on stack overflow:

https://stackoverflow.com/questions/59442544/is-there-an-efficient-python-implementation-for-somersd-for-ungrouped-variables/64705594?noredirect=1#comment114407875_64705594

In short, the question poses the following Somers' D formula:

X = The independent variable (In my case, continuous)

Y = The dependent variable (In my case, discrete [1, 2, 3, 4, 5])

N_tot = len(X)*(len(X)-1) / 2                        
Somers D = (N_C - N_D) / (N_tot - N_Tie_y)

And I am wondering why the Somers' D calculation removes the Number of times Y ties? Why is the formula not

N_tot = len(X)*(len(X)-1) / 2                        
Somers D = (N_C - N_D) / (N_tot)

I further have found the reference to this Wikipedia article (as mentioned in the stack overflow question) and see that this implementation of removing the number of Binary Y ties is proposed.

https://en.wikipedia.org/wiki/Somers%27_D

However, I am still wondering whether this is suitable for a problem with a discrete Y dependent variable with buckets from 1 to 5 [1, 2, 3, 4, 5]

Option 1:
N_tot = len(X)*(len(X)-1) / 2                        
Somers D = (N_C - N_D) / (N_tot - N_Tie_y)
Option 2:
N_tot = len(X)*(len(X)-1) / 2                        
Somers D = (N_C - N_D) / (N_tot)
Option 3:
Somers D = Kendall's Tau(X, Y) / Kendall's Tau(X, X)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.