Skip to main content

Methods for estimating and performing inference for spatial and non-spatial segregation in PySAL.

Project description

Segregation Measures Framework in PySAL

Build Status

Methods for estimating and performing inference for spatial and non-spatial segregation.

Easily estimate several segregation measures:

Multiple Segregation Measures in Los Angeles in 2010

Perform comparative segregation:

Los Angeles and New York Comparison Illustration

Los Angeles and New York Comparison Results

What is segregation?

The PySAL segregation module allow users to estimate several segregation measures and perform inference for single measures and comparative inference in a concise way.

It can be divided into two frameworks: point estimation and inference wrappers. The first framework could be, in turn, subdivided in non-spatial indexes and spatial indexes. The inference approach present functions to perform inference for a single measure or for comparison between two measures.

Installation

The recommended method for installing segregation is with anaconda. Either of the the two methods listed below can be used to get started with the development version.

  1. Clone this repository or download it manually then cd into the directory and run the following commands:
$ conda env create -f environment.yml
$ source activate segregation
$ python setup.py develop
  1. pip directly from this repository:
$ pip install git+https://github.com/pysal/segregation

Segregation uses:

  • libpysal
  • pandas
  • geopandas
  • numpy
  • scipy
  • scikit-learn

Getting started

All input data for this module rely on pandas DataFrames for the non-spatial measures and geopandas DataFrames for spatial ones. In a nutshell, the user needs to pass the pandasDataFrame as its first argument and then two string that represent the variable name of population frequency of the group of interest (variable group_pop_var) and the total populationof the unit (variable total_pop_var).

So, for example, if a user would want to fit a dissimilarity index (D) to a DataFrame called df to a specific group with frequency freq with each total population population, a usual call would be something like this:

>>> from segregation.non_spatial_indexes import Dissim
>>> index = Dissim(df, "freq", "population")

If a user would want to fit a spatial dissimilarity index (SD) to a geopandas DataFrame called gdf to a specific group with frequency freq with each total population population, a usual call would be something like this:

>>> from segregation.spatial_indexes import Spatial_Dissim
>>> spatial_index = Spatial_Dissim(gdf, "freq", "population")

Every class of segregation has a statistic and a core_data attributes. The first is a direct access to the point estimation of the specific segregation measure and the second attribute gives access to the main data that the module uses internally to perform the estimates. To see the estimated D in the first generic example above, the user would have just to run index.statistic to see the fitted value.

For point estimation, all the measures available can be summarized in the following table:

Measure Class/Function Spatial? Function Inputs
Dissimilarity (D) Dissim No -
Gini (G) Gini_Seg No -
Entropy (H) Entropy No -
Isolation (xPx) Isolation No -
Exposure (xPy) Exposure No -
Atkinson (A) Atkinson No b
Correlation Ratio (V) Correlation_R No -
Concentration Profile (R) Con_Prof No m
Modified Dissimilarity (Dct) Modified_Dissim No iterations
Modified Gini (Gct) Modified_Gini_Seg No iterations
Bias-Corrected Dissimilarity (Dbc) Bias_Corrected_Dissim No B
Density-Corrected Dissimilarity (Ddc) Density_Corrected_Dissim No -
Spatial Proximity Profile (SPP) Spatial_Prox_Prof Yes m
Spatial Dissimilarity (SD) Spatial_Dissim Yes w, standardize
Boundary Spatial Dissimilarity (BSD) Boundary_Spatial_Dissim Yes standardize
Perimeter Area Ratio Spatial Dissimilarity (PARD) Perimeter_Area_Ratio_Spatial_Dissim Yes standardize
Spatial Isolation (SxPx) Spatial_Isolation Yes alpha, beta
Spatial Exposure (SxPy) Spatial_Exposure Yes alpha, beta
Spatial Proximity (SP) Spatial_Proximity Yes alpha, beta
Relative Clustering (RCL) Relative_Clustering Yes alpha, beta
Delta (DEL) Delta Yes -
Absolute Concentration (ACO) Absolute_Concentration Yes -
Relative Concentration (RCO) Relative_Concentration Yes -
Absolute Centralization (ACE) Absolute_Centralization Yes -
Relative Centralization (RCE) Relative_Centralization Yes -
Spatial Information Theory (SIT) Spatial_Information_Theory Yes w, unit_in_local_env, original_crs

Once the segregation indexes are fitted, the user can perform inference to shed light for statistical significance in regional analysis. The summary of the inference framework is presented in the table below:

Inference Type Class/Function Function main Inputs Function Outputs
Single Value Infer_Segregation seg_class, iterations_under_null, null_approach, two_tailed p_value, est_sim, statistic
Two Value Compare_Segregation seg_class_1, seg_class_2, iterations_under_null, null_approach p_value, est_sim, est_point_diff

If you are new to segregation and PySAL you will best get started with our documentation! We encourage you to take a look at some examples of this module in the notebooks repo!

Contribute

PySAL-segregation is under active development and contributors are welcome.

If you have any suggestion, feature request, or bug report, please open a new issue on GitHub. To submit patches, please follow the PySAL development guidelines and open a pull request. Once your changes get merged, you’ll automatically be added to the Contributors List.

Support

If you are having issues, please talk to us in the gitter room.

License

The project is licensed under the BSD license.

Funding

Award #1831615 RIDIR: Scalable Geospatial Analytics for Social Science Research

This study was financed in part by the Coordenação de Aperfeiçoamento de Pessoal de Nível Superior - Brasil (CAPES) - Process number 88881.170553/2018-01

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

segregation-1.0.2.tar.gz (31.9 kB view details)

Uploaded Source

Built Distribution

segregation-1.0.2-py3-none-any.whl (43.4 kB view details)

Uploaded Python 3

File details

Details for the file segregation-1.0.2.tar.gz.

File metadata

  • Download URL: segregation-1.0.2.tar.gz
  • Upload date:
  • Size: 31.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for segregation-1.0.2.tar.gz
Algorithm Hash digest
SHA256 cabe53c3e291323fbafbf8cbb5f1b4af86822eac6f1179621b417b953a9fa47b
MD5 0b7b325db670cd82c092015fdb534a5e
BLAKE2b-256 67743d544e444ef55bb187f9a15a06797aef6c003036e1098b90fcc65727455f

See more details on using hashes here.

File details

Details for the file segregation-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: segregation-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 43.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for segregation-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a51525f8449a6b48b989e7295128fd61eef6c45553694cc9776962a2b4dc61d9
MD5 9c510a6b0f2fd138b5a43c915552b514
BLAKE2b-256 a9afe5ab4ef8d3468082a0ee104cae191a4259229b55b8292ec6aadc8d74a659

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page