This README file describes the programs used to produce the results discussed in "Aggregate Consequences of Dynamic Credit Relationships" by Stephane Verani. The programs included in this archive were last run on Ubuntu 14.04 using: * SAS version 9.4 (only used in Part 0.) * STATA version 15 (only used in Part 0.) * R version 3.4 with the R libraries: * GenSA * Schumaker * doMC * plm * numDeriv * xtable * gplots * ggplots2 * tikzDevice * MASS The R programs are written to take advantage of parallel computing and should run reasonably quickly on a personal computer, such as a laptop with an Intel Core i7 processor or better. Depending on the cases and the starting values, computing the steady states can take anywhere from a few minutes for the benchmark contract to a few hours for the model with stochastic monitoring and endogenous enforcement. Transition dynamics can be computed in a few hours, but, of course, the code takes longer to run when the outside option needs to be computed in every period. Random numbers are generated using R re-implementation of Pierre L'Ecuyer's 'RngStreams' multiple streams of pseudo-random numbers and the seed can be found in the programs. Running these programs requires at least 500mb of disk space to store the intermediate output saved by the programs. ----------------------------------------------------------------- Part 0. Input for SMM estimation ----------------------------------------------------------------- Preparing the final dataset used by the SMM estimation procedure requires access to the SAS database varbas.sas7bdat, which was created by the authors of Eslava, Haltiwanger, Kugler & Kugler, 2013. "Trade and Market Selection: Evidence from Manufacturing Plants in Colombia," Review of Economic Dynamics vol. 16(1), pages 135-158. This database is housed at the Colombian Departamento Administrativo Nacional de Estad?sticas (DANE) and access to this data can be requested from DANE. More information about this data can be found here: https://ideas.repec.org/c/red/ccodes/11-69.html. The STATA program inv_momnets.do and the R program moment_estimation.R use varbas.sas7bdat and the CSV file depreciation.csv (included in this archive) to estimate p, delta, and the moments and the moment covariance matrix used in the SSM estimation procedure discussed in Part 1. * inv_momnets.do: coverts the SAS database varbas.sas7bdat into a STATA database and uses the sector-level depreciation rates in depreciation.csv of Pombo (1999) to back out plant-level investment rates from the plant level capital stock computed by Eslava etal (2013). This step is necessary because although Eslava etal (2013) used the depreciation rates in Pombo (1999) to construct the plant-level capital variables in varbas.sas7bdat, these rates are not available in varbas.sas7bdat. * moment_estimation.R uses the output of inv_momnets.do, colombia_firm_data.csv, to estimate p, delta and to compute the moments used in the SMM estimation procedure discussed in Part 1 below. The output is SMM_input.RData, which is included in this archive. The results of this paper can be reproduced in full using SMM_input.RData and the R code described in Part 1., 2. and 3. ----------------------------------------------------------------- Part 1. SMM estimation ----------------------------------------------------------------- benchmark_SMM.R implements the SMM procure discussed in the online appendix using: * SMM_input.RData * benchmark_parameters.R sets the model parameters * benchmark_setup.R sets up the state space for V and compute f, F, k(R) and n(R) * contract_NoMonitoring_NoEnforcement.R computes the optimal contract * benchmark_simulated_sample.R simulates the T artifical samples The results are collected in SMM_results.RData, which are used in Part 2. ----------------------------------------------------------------- Part 2: Stationary steady states and transition dynamics ----------------------------------------------------------------- run_first_time.R computes the steady states for the nine static versions of the model and the two transition paths by sequentially running step 1. through to step 11. described below. The dependencies for each steps are listed. Each step saves the results in .Rdata archives, which are used in Part 3. Steady states: * 1. Benchmark_GE.R solves for the benchmark steady state using: * SMM_results.RData contains the estimated parameter * benchmark_parameters.R sets the model parameters * benchmark_setup.R sets up the state space for V and compute f, F, k(R) and n(R) * contract_NoMonitoring_NoEnforcement.R computes the optimal contract * benchmark_distribution.R computes the stationary distribution * 2. NoEnforcement_GE.R solves the model after eliminating private information frictions using * BenchmarkGEResults.Rdata the results outputted by Benchmark_GE.R * benchmark_parameters.R * transition_setup.R the main difference relative to benchmark_setup.R is that z is fixed * contract_NoMonitoring.R * NoMonitoring_distribution.R * 3. NoMonitoring_GE.R: solves the model after eliminating enforcement friction using * BenchmarkGEResults.Rdata * benchmark_parameters.R * transition_setup.R * contract_NoMonitoring.R * NoMonitoring_distribution.R * 4. FirstBest_GE.R: solves the model after eliminating enforcement and private enforcement frictions using * BenchmarkGEResults.Rdata * benchmark_parameters.R * transition_setup.R * 5. SomeMonitoring_GE.R: solves the model with stochastic monitoring-i.e, m=0.005-using * BenchmarkGEResults.Rdata * ini_contract_EndoMonitoring.R finds a starting value for W * benchmark_parameters.R * transition_setup.R * contract_EndoMonitoring.R * EndoMonitoring_distribution.R * 6. SomeEnforcement_GE.R: solves the model with endogenous enforcement-i.e, phi(e) = 0.5e^2-- using * BenchmarkGEResults.Rdata * ini_contract_EndoEnforcement.R * benchmark_parameters.R * transition_setup.R * contract_EndoEnforcement.R * EndoEnforcement_distribution.R * 7. SomeEnforcement_SomeMonitoring_GE.R: solves the model with endogenous enforcement and stochastic monitoring-i.e., m= 0.005 and phi(e) = 0.5e^2-using * BenchmarkGEResults.Rdata * ini_contract_EndoMonitoring_EndoEnforcement.R * benchmark_parameters.R * transition_setup.R * contract_EndoMonitoring_EndoEnforcement.R * EndoMonitoring_EndoEnforcement_distribution.R * 8. StrongEnforcement_NoMonitoring_GE.R: solves the model with Vbar = 0-i.e., the entrepreneur can only consumes the cash flow when repudiating * BenchmarkGEResults.Rdata * benchmark_parameters.R * transition_setup.R * contract_StrongEnforcement_NoMonitoring.R * StrongEnforcement_NoMonitoring_distribution.R * 9. StrongEnforcement_FreeMonitoring_GE.R: solves the model with Vbar = 0 and m=0 using * BenchmarkGEResults.Rdata * benchmark_parameters.R * transition_setup.R * contract_StrongEnforcement_NoMonitoring.R * StrongEnforcement_NoMonitoring_distribution.R Transition dynamics: * 10. benchmark_stationary_crossection.R: finds the marginal of the stationary distribution for the benchmark economy and adjusts some of the parameters accordingly using * BenchmarkGEResults.Rdata * benchmark_parameters.R * transition_setup.R * contract_NoMonitoring_NoEnforcement.R * StrongEnforcement_NoMonitoring_distribution.R * 11. transition_NoMonitoring.R: computes the transition dynamics following the enforcement reform using * BenchmarkGEResults.Rdata * benchmark_crossection.RData * initial_distribution_[CORE_NUMBER_HERE].RData: the initial distributions from benchmark_stationary_crossection.R. There is one file per core used by foreach. * benchmark_parameters.R * transition_setup.R * contract_NoMonitoring.R * 12. transition_NoEnforcement.R: computes the transition dynamics following the private information reform using * BenchmarkGEResults.Rdata * benchmark_crossection.RData * initial_distribution_[CORE_NUMBER_HERE].RData: the initial distribution from benchmark_stationary_crossection.R. There is one file per core used by foreach. * benchmark_parameters.R * transition_setup.R * contract_NoEnforcement.R ----------------------------------------------------------------- Part 3: Tables and Figures ----------------------------------------------------------------- * graphics_table.R can be run after running run_first_time.R in its entirety to generate the tables and figures of the paper. graphics_table_1.R go through the same steps as run_first_time.R with the same dependencies and using the results that were saved in Part 2. * contract_graphics.R solves the model with endogenous enforcement and stochastic monitoring once more to produces the basic Tex code used to create figures 2 and 3 using * BenchmarkGEResults.Rdata * EndoMonitoring_EndoEnforcementGEResults.Rdata * benchmark_parameters.R * transition_setup.R