This repository contains code used to generate the results in "The
Response of Drug Expenditure to Non-Linear Contract Design: Evidence
from Medicare Part D" by Liran Einav, Amy Finkelstein, and Paul

All code is in the "src" directory. Within that folder, "estimation"
contains code for estimation. "dataProcessing" contains code for
preparing the data for estimation. "counterfactuals" contains code for
counterfactual simulations and reporting results. "deps" contains
external dependencies.

To recreate the results:

   1. Obtain access to the Medicare D data.

   2. Prepare the data for estimation. 

      a) Compile Stata plugin for creating MySQL database by running "make" in the dataProcessing directory.

      b) In Stata: "do createSQLite"

   3. Run the estimation.

      a) Compile the estimation program: run "make smm" in the estimation directory.

      b) Execute "./smm path-to-data.sl3 baseline3.cfg" (modify
      path-to-data.sl3 and baseline3.cfg with the name of the data and
      configuration file you want to use)

      c) Wait a few days

   4. Run the counterfactuals and create the results.
      a) Compile the simulation program: run "make" in the counterfactuals directory.

      b) Modify "run.R" as needed and execute it in R

      c) The results will be compiled into a pdf based on tex/slides/slides_PartD_paulFigures.tex