Skip to content

lbeziaud/mosaic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

siMulating sOcioeconomic baSed AffirmatIve aCtion

SWH

Louis Béziaud, 2022

Reardon, S.F., Baker, R., Kasman, M., Klasik, D. and Townsend, J.B. (2018), What Levels of Racial Diversity Can Be Achieved with Socioeconomic-Based Affirmative Action? Evidence from a Simulation Model. J. Pol. Anal. Manage., 37: 630-657. https://doi.org/10.1002/pam.22056

See https://github.com/lbeziaud/re-reardon2018 for details on the replication.

Content

The main model is model.py. Figures are generated by figures.ipynb. The file utils_figs.py contains auxiliary functions used for launching the experiments, with pre_run allowing to run all experiments in parallel.

Requirements

This code has been written with Python 3.9. Required packages are listed in requirements.txt

Usage

  1. Clone the repository:

    $ git clone https://github.com/lbeziaud/mosaic
    $ cd mosaic
  2. Install dependencies in a virtual environment:

    $ python3.9 -m venv venv  # create venv
    $ source venv/bin/activate  # activate venv
    (venv) $ pip install -r requirements.txt
  3. Generate all the figures (in headless mode):

    (venv) $ jupyter nbconvert --ExecutePreprocessor.timeout=-1 --to notebook --inplace --execute figures.ipynb

    The whole notebook takes around 20 minutes to execute if the simulation files are already available (see below).

  4. You can run all simulations required by the figures with:

    (venv) $ python pre_run.py

    The script accepts parameters -j <number of jobs to run in parallel> and -v/-vv/-vvv to control verbosity.

    Output is saved on disk in results/ (in human readable paths) as parquet files. Total size is 10 GB.

    Using 15 parallel jobs requires around 30 GB of memory and takes 20 minutes on AMD Ryzen 7 PRO 6850U.

  5. Running the model is done by calling model.run, which returns a tuple of dataframes:

    from model import run
    
    colleges, students, outcomes = run()

    Several examples are provided in utils_figs.py on how to cache the run and on how to run and aggregate repeated experiments.

About

siMulating sOcioeconomic baSed AffirmatIve aCtion

Resources

License

Stars

Watchers

Forks

Contributors