pysal / segregation

Segregation Measurement, Inferential Statistics, and Decomposition Analysis
https://pysal.org/segregation/
BSD 3-Clause "New" or "Revised" License
112 stars 26 forks source link

Concentration indexes rank fix #118

Closed renanxcortes closed 5 years ago

renanxcortes commented 5 years ago

This addresses directly https://github.com/pysal/segregation/issues/43.

Ok, today I dived into the details of this code and found the difference and will register here.

The point here is that I was having a different interpretation on the calculation of n2 explained in the original formula mentioned in the first comment of https://github.com/pysal/segregation/issues/43 present in Massey (1988).

Originally, I thought that, in order to calculate n2, you needed to sort from largest to smallest unit and extract the rank of that cumulative condition in this largest to smallest ordering. However, reading again, I realized that n1 and n2 are rank of ordering from smallest to largest. Therefore, you need to find the specific track of the n2 condition and check the rank value in the original smallest to largest order.

Also, although this is not problematic, I was working with the first unit before reaching that condition: "cumulative total population of units equals the minority population totalling" given the fact that it is very unlike that the equality of the condition. So, I changed the rank to the first unit that this condition actually happens (i.e., possibly being a larger value) by adding 1 in both conditions checking. This also matches OasisR and GSA implementations exactly.

This interpretation of n1 and n2 is a little bit tricky but now it is more clear and the implementation is correct.