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

absolute concentration values not matching with other open-source options? #43

Closed renanxcortes closed 5 years ago

renanxcortes commented 5 years ago

I've been struggling with the concentration indexes (especially the ACO), because I'm trying to match the values with the ones that is generated by OasisR (https://cran.r-project.org/web/packages/OasisR/OasisR.pdf)... in the original paper of OasisR the author (page 12, Table 6) states that this index matches the one of the GSA implementations.

However, I'm closely checking line by line of the functions and am not seeing any difference of the R implementation (https://github.com/cran/OasisR/blob/99f5d028c205329c4f3b1355e5bcaa09e1fcc077/R/SegFunctions.R#L1358) and our implementation. I highlight that the R and GSA implementation might be not correct, but I wanted to open a discussion of this.

The original formula is:

image

To reproduce this in Python (edit path needed):

import geopandas as gpd
import segregation
from segregation.spatial import Absolute_Concentration

irreg = gpd.read_file('C:\\Users\\renan\\Desktop\\oasisTests\\irregular_lattice_50.shp')
irreg['group_pop_var'] = list(range(1, 51))
irreg['total_pop_var'] = 100
index1 = Absolute_Concentration(irreg, 'group_pop_var', 'total_pop_var')
index1.statistic

to reproduce this in R (edit path needed):

library(OasisR)
library(rgdal)
irreg<-readOGR("C:\\Users\\renan\\Desktop\\oasisTests","irregular_lattice_50")
vector1 <- seq(1,50) # Group 1 Population
tot <- rep(100, 50)
vector2 <- tot - vector1 # Group 2 Population
irreg_input_data <- cbind(vector1, vector2)
ACO(irreg_input_data, spatobj = irreg)
# The first value is the ACO value for the first group

The irregular lattice used is attached. irregular_lattice_50.zip

renanxcortes commented 5 years ago

This issue is address in https://github.com/pysal/segregation/pull/118.