This repository contains the simulation code for "Identification of Dynamic Discrete Choice Model with Hyperbolic Discounting Using a Terminating Action" by Wang, Weiergraeber, and Xiao (2025). Parts of this code build on "Dynamic Discrete Choice Models: Methods, Matlab Code, and Exercises" by Jaap H. Abbring and Tobias J. Klein, which is available at http://ddc.abbring.org.
The code in this repository constructs all tables and figures in the paper using a combination of Python and MATLAB. The code is structured based on a template for reproducible research projects in Economics by Gaudecker, 2019. The automation is pre-configured by describing the workflow as a dependent acyclic graph using Waf (https://code.goo gle.com/p/waf/). In order to replicate all figures and tables referenced in the paper you need to:
- Install all the required software and packages (see Software Requirements below). If not already the case, add all executables for Python and MATLAB to your system path so that waf can access the software from the command line.
- Navigate to the root folder of the code repository.
- Configure waf using the command
python waf.py configure. - Let waf build the project using the command
python waf.py build. The filewaf.pyalong with thewscript-files in each subfolder and the code in folder.wafserve as a master file that runs all the programs for simulations and final formatting in the correct order. In addition, waf will create the corresponding folder structure within abld-folder in the root-directory of the repository. Details about this setup are provided by Gaudecker (2019). Therefore, you should not run any of the programs manually before running the waf-program. Once the folder structure and the associated project path files inbldare created, you can interactively rerun any of the programs contained in this repository and inspect all of its output. When running single files in isolation please set the working directory of your relevant program executable tobldto ensure that the automatically generated absolute path names can be accessed by the programs. Note that waf will run independent programs in parallel. On some machines this could lead to an inefficient overuse of hardware and in rare circumstances crash the system. In order to circumvent this, waf can be instructed to run all files serially by using the -j1 flag:python waf.py build -j1. You should expect the simulation code to run for less than one hour on a modern desktop computer.
In this section, we list all the software that is necessary to build the replication package. The code does not install these packages.. Please install each of the software and required packages manually before running the code.
- Python (code was last run using Anaconda Python 3.10.14, which should come with most of the required packages by default.) Important: Some of the waf code is likely incompatible with Python 3.11.
- matplotlib 3.3.2 – numpy 1.19.2 – pandas 1.1.3 – scipy 1.5.2
- Matlab (code was last run using Release 2024b)
The code was last run on a 6-core Intel-based iMac with MacOS version 10.15.7. Computation took less than 1 hour.
- All non-trivial program files contain an introductory docstring that explains the purpose and content of the respective file.
- The programs in
src/analysisrun the simulations.src/analysis/wscriptdescribes the detailed dependency structure and explains which output files are generated. The estimation output is stored in unformatted form inbld/out/analysis. - The programs in
src/finalread the estimation output frombld/out/analysisand format the final \LaTeX-tables for the simulation result tables and figures.src/final/wscriptdescribes the detailed dependency structure and explains which output files are generated by which program. The figures are stored inbld/out/figures. - Note that the file waf.py along with the wscript-files in each subfolder and the code in folder .waf serves as a master file that runs all the programs for simulation and final formatting in the correct order. In order to build the project, please execute the following:
- Navigate to the root folder of the code repository.
- Configure waf using the command
python waf.py configure. - Build the project using the command
python waf.py build. This step will also create the corresponding folder structure within abld-folder in the root-directory of the replication package. Details about this setup are provided by Gaudecker (2019).
- You should not run any of the programs manually before running the waf-program as described above. Once the folder structure and the associated project path files in bld are created on your computer, you can interactively rerun any of the programs contained in this repository and inspect all of its output. When running single files in isolation please set the working directory of your relevant program executable to
bldto ensure that the automatically generated absolute path names can be accessed by the programs. - Please note that this version of the waf-template is incompatible with Python 3.11.
- Abbring, Jaap, Klein, Tobias. Dynamic Discrete Choice Models: Methods, Matlab Code, and Exercises, available at http://ddc.abbring.org.
- Gaudecker, Hans-Martin von (2019). Templates for Reproducible Research Projects in Economics (v0.1). https://doi.org/10.5281/zenodo.2533241/.
- Wang, Chao, Weiergraeber, Stefan, Ruli Xiao (2025). Identification of Dynamic Discrete Choice Models Using a Terminating Action. https://sweiergr.github.io/publication/hyperbolicdiscountingta/hyperbolicDiscountingTA.pdf.