How diverse can spatial measures of cultural segregation be?

Results from Monte Carlo simulations of an agent-based model

[Dani Arribas-Bel, Peter Nijkamp & Jacques Poot]

Results and code

Visualizations

This page presents several additional figures that were not included in the paper but that were used in the analysis and may be of interest for readers. In addition, this page also shows the code required to create them. The page has the following sections:

Simulation output processing

In [1]:
%matplotlib inline

import os, sys
import pandas as pd
import pysal as ps
import results as tools
import statsmodels.formula.api as sm
import matplotlib.pyplot as plt
In [2]:
def _encode(cs):
    if cs['Yn'] == 5:
        return 'dense'
    elif cs['Yn'] == 10:
        return 'sprawl'
    else:
        return None

Read data

In [3]:
inds = pd.read_csv('sim_res.csv')\
                    .set_index(['tau', 'prop_mix', 'rep_id', 'group'])
In [4]:
inds.info()
<class 'pandas.core.frame.DataFrame'>
MultiIndex: 468688 entries, (0.0, 0.7_0.1_0.1_0.1, 0, g0-0.70) to (0.337931034483, 0.2_0.2_0.2_0.2_0.2, 499, g4-0.20)
Data columns (total 8 columns):
ellison_glaeser_egg_pop    468688 non-null float64
isolation_ii               468688 non-null float64
segregation_gsg            468688 non-null float64
theil_th                   468688 non-null float64
ticks                      468688 non-null int64
vacr                       468688 non-null float64
city                       468688 non-null object
job                        468688 non-null int64
dtypes: float64(5), int64(2), object(1)
memory usage: 30.8+ MB

In [5]:
inds.head()
Out[5]:
ellison_glaeser_egg_pop isolation_ii segregation_gsg theil_th ticks vacr city job
tau prop_mix rep_id group
0 0.7_0.1_0.1_0.1 0 g0-0.70 -0.000264 1.037704 0.140063 0.044388 0 0.25 sprawl 10
g1-0.10 -0.000837 1.201116 0.191111 0.044388 0 0.25 sprawl 10
g2-0.10 -0.000266 1.267656 0.218074 0.044388 0 0.25 sprawl 10
g3-0.10 -0.000077 1.282360 0.226370 0.044388 0 0.25 sprawl 10
1 g0-0.70 -0.000258 1.040111 0.148825 0.043880 0 0.25 sprawl 10

Simulation descriptives

The following figures represent the equivalent of Figure 3 in the submitted version and describe the average number of iterations as well as the number of draws the simulation performed for a given combination of population structure and value of $\tau$. There are four figures, one for each pair of type of city ("dense", "sprawl") and vacancy rate.

In [6]:
inds.xs('0.7_0.3', level='prop_mix').loc[('city'=='dense') & ('vacr'==0.25), :].head()
Out[6]:
ellison_glaeser_egg_pop isolation_ii segregation_gsg theil_th ticks vacr city job
rep_id group
0 g0-0.70 -0.000286 1.007726 0.061714 0.004440 0 0.25 dense 3
g1-0.30 -0.000373 1.018028 0.061714 0.004440 0 0.25 dense 3
1 g0-0.70 -0.000251 1.010429 0.074794 0.006025 0 0.25 dense 3
g1-0.30 -0.000180 1.024335 0.074794 0.006025 0 0.25 dense 3
2 g0-0.70 -0.000244 1.011023 0.081905 0.006402 0 0.25 dense 3
In [7]:
for (city, vacr), sce in inds.groupby(['city', 'vacr']):
    print city, vacr
    out, ts = tools.build_convfreqs(sce)
    if (city == 'dense') and (vacr == 0.25):
        out, ts = tools.build_convfreqs(sce)
        out, ts = tools.build_convfreqs(sce)
dense 0.15

dense 0.25

sprawl 0.15

sprawl 0.25

Main results

  • Mean values
In [8]:
for (city, vacr), sce in inds.groupby(['city', 'vacr']):
    print '####################################################'
    print city, vacr
    scetp = tools.build_tauplot_by_scenario(sce.drop(['city', 'job', 'vacr'], axis=1), \
                                            scenarios=\
                                        ['0.5_0.5', '0.7_0.3', \
                                         '0.4_0.4_0.1_0.1', \
                                         '0.7_0.1_0.1_0.1', \
                                         '0.4_0.3_0.2_0.1', \
                                         '0.2_0.2_0.2_0.2_0.2'])
####################################################
dense 0.15
Plotting scenario  0.5_0.5
Plotting scenario  0.7_0.3
Plotting scenario  0.4_0.4_0.1_0.1
Plotting scenario  0.7_0.1_0.1_0.1
Plotting scenario  0.4_0.3_0.2_0.1
Plotting scenario  0.2_0.2_0.2_0.2_0.2

####################################################
dense 0.25
Plotting scenario  0.5_0.5
Plotting scenario  0.7_0.3
Plotting scenario  0.4_0.4_0.1_0.1
Plotting scenario  0.7_0.1_0.1_0.1
Plotting scenario  0.4_0.3_0.2_0.1
Plotting scenario  0.2_0.2_0.2_0.2_0.2

####################################################
sprawl 0.15
Plotting scenario  0.5_0.5
Plotting scenario  0.7_0.3
Plotting scenario  0.4_0.4_0.1_0.1
Plotting scenario  0.7_0.1_0.1_0.1
Plotting scenario  0.4_0.3_0.2_0.1
Plotting scenario  0.2_0.2_0.2_0.2_0.2