Replication package 194 · dataverse · 2021 · open the deposit

How the code gets from data to results

Replication Code for "Can Corporate Debt Foster Innovation and Growth?"

Code for: Can Corporate Debt Foster Innovation and Growth? Review of Financial Studies 2022

35
scripts
7
input files
5
file hand-offs
3
merges
11
sample steps
0
estimations

1 · Data in — files the code reads and no script of the package writes

Datasets this package uses (item detector / README): Compustat, Compustat North America (database)
  • compx.funda SAS
    RFS_code_data_GHM_download_Compustat_data.sas:22
    RFS_code_data_GHM_download_Compustat_data.sas, line 22 set compx.funda(keep= gvkey cusip datadate fyear fyr &vars indfmt datafmt popsrc consol curcd);
  • link.ccmxpf_linktable SAS
    RFS_code_data_GHM_download_Compustat_data.sas:29
    RFS_code_data_GHM_download_Compustat_data.sas, line 29 set link.ccmxpf_linktable;
Other input files 5 files
  • \cs_table.mat MATLAB
    RFS_code_functions_results_figures.m:14
    RFS_code_functions_results_figures.m, line 14 load(os_dir(setts.dir,'\cs_table.mat'));
  • \nodebt_results.mat MATLAB
    RFS_code_functions_results_figures.m:15
    RFS_code_functions_results_figures.m, line 15 load(os_dir(setts.dir,'\nodebt_results.mat'));
  • \static_results.mat MATLAB
    RFS_code_functions_results_figures.m:16
    RFS_code_functions_results_figures.m, line 16 load(os_dir(setts.dir,'\static_results.mat'));
  • data\debt\H_ext.txt text
    RFS_code_functions_results_figures.m:144
    RFS_code_functions_results_figures.m, line 144 H_ds=readtable(os_dir(setts.dir,'data\debt\H_ext.txt'));
  • input\firm_innovation.csv CSV
    RFS_code_data_GHM_data_import.do:13
    RFS_code_data_GHM_data_import.do, line 13 import delimited "input\firm_innovation.csv"

Plus 1 reads whose file name is built at run time (a macro or loop variable) and cannot be named.

2 · The file pipeline — which script writes which file that a later script reads

35 scripts, in run order for the master script RFS_code_results.m and the 30 scripts it runs (directly or through each other); the other 4 are not run by a master script and follow in file-name order; 5 hand-offs through 5 intermediate files; 11 files written and never read back (outputs).

RFS_code_data_GHM_download_Compustat_data.sas → RFS_code_data_GHM_data_import.do: compannual.csvRFS_code_data_GHM_data_import.do → RFS_code_data_GHM_figure1.do: patentsRFS_code_data_GHM_data_import.do → RFS_code_data_GHM_table2_data.do: patentsRFS_code_results.m → RFS_code_functions_results_comparative_statics_table.m: [setts.dir,'nodebt_results.mat'], [setts.dir,'static_results.mat']RFS_code_functions_results_figures.m → RFS_code_functions_results_smoothing_cs.m: figure_10.txt RFS_code_functions_model_q.m 1. RFS_code_functions_model_q.m RFS_code_functions_other_binopdf.m 2. RFS_code_functions_other_binopdf.m RFS_code_functions_other_nanmean.m 3. RFS_code_functions_other_nanmean.m RFS_code_functions_other_os_dir.m 4. RFS_code_functions_other_os_dir.m RFS_code_results.m 5. RFS_code_results.m RFS_code_model_settings.m 6. RFS_code_model_settings.m RFS_code_functions_model_moments.m 7. RFS_code_functions_model_moments.m RFS_code_functions_model_updatematrix.m 8. RFS_code_functions_model_updatematrix.m RFS_code_functions_model_equilibrium.m 9. RFS_code_functions_model_equilibrium.m RFS_code_functions_model_entrant_value.m 10. RFS_code_functions_model_entrant_value.m RFS_code_functions_model_equity_value_coupon.m 11. RFS_code_functions_model_equity_value_coupo… RFS_code_functions_model_equity_value.m 12. RFS_code_functions_model_equity_value.m RFS_code_functions_model_OPT.m 13. RFS_code_functions_model_OPT.m RFS_code_functions_model_equity_update.m 14. RFS_code_functions_model_equity_update.m RFS_code_functions_model_debt_value.m 15. RFS_code_functions_model_debt_value.m RFS_code_functions_model_debt_update.m 16. RFS_code_functions_model_debt_update.m RFS_code_functions_model_OPT_E.m 17. RFS_code_functions_model_OPT_E.m RFS_code_functions_model_q_E.m 18. RFS_code_functions_model_q_E.m RFS_code_functions_model_steadystate_distribution.m 19. RFS_code_functions_model_steadystate_distri… RFS_code_functions_other_binocdf.m 20. RFS_code_functions_other_binocdf.m RFS_code_functions_other_binornd.m 21. RFS_code_functions_other_binornd.m RFS_code_functions_results_comparative_statics.m 22. RFS_code_functions_results_comparative_stat… RFS_code_functions_results_comparative.m 23. RFS_code_functions_results_comparative.m RFS_code_functions_results_csMoments.m 24. RFS_code_functions_results_csMoments.m RFS_code_functions_results_comparative_statics_table.m 25. RFS_code_functions_results_comparative_stat… RFS_code_functions_other_ltable.m 26. RFS_code_functions_other_ltable.m RFS_code_functions_results_figures.m · reads 4 input files 27. RFS_code_functions_results_figures.m RFS_code_functions_results_underinvestment.m 28. RFS_code_functions_results_underinvestment.m RFS_code_functions_other_pd_plot.m 29. RFS_code_functions_other_pd_plot.m RFS_code_functions_results_smoothing_cs.m 30. RFS_code_functions_results_smoothing_cs.m RFS_code_functions_other_polyfix.m 31. RFS_code_functions_other_polyfix.m RFS_code_data_GHM_download_Compustat_data.sas · reads 2 input files 32. RFS_code_data_GHM_download_Compustat_data.s… RFS_code_data_GHM_data_import.do · reads 1 input files 33. RFS_code_data_GHM_data_import.do RFS_code_data_GHM_figure1.do 34. RFS_code_data_GHM_figure1.do RFS_code_data_GHM_table2_data.do 35. RFS_code_data_GHM_table2_data.do
  1. 1.RFS_code_functions_model_q.m setup file sourced by 2 scripts
  2. 2.RFS_code_functions_other_binopdf.m setup file sourced by 4 scripts
  3. 3.RFS_code_functions_other_nanmean.m setup file sourced by 2 scripts
  4. 4.RFS_code_functions_other_os_dir.m setup file sourced by 4 scripts
  5. 5.RFS_code_results.m master script
    writes [setts.dir,'nodebt_results.mat'] → read by RFS_code_functions_results_comparative_statics_table.m
    writes [setts.dir,'static_results.mat'] → read by RFS_code_functions_results_comparative_statics_table.m
  6. 6.RFS_code_model_settings.m run by RFS_code_results.m line 9
  7. 7.RFS_code_functions_model_moments.m run by RFS_code_results.m line 10
  8. 8.RFS_code_functions_model_updatematrix.m run by RFS_code_functions_model_moments.m line 24
  9. 9.RFS_code_functions_model_equilibrium.m run by RFS_code_functions_model_moments.m line 27
  10. 10.RFS_code_functions_model_entrant_value.m run by RFS_code_functions_model_equilibrium.m line 32
  11. 11.RFS_code_functions_model_equity_value_coupon.m run by RFS_code_functions_model_entrant_value.m line 13
  12. 12.RFS_code_functions_model_equity_value.m run by RFS_code_functions_model_equity_value_coupon.m line 46
  13. 13.RFS_code_functions_model_OPT.m run by RFS_code_functions_model_equity_value.m line 38
  14. 14.RFS_code_functions_model_equity_update.m run by RFS_code_functions_model_equity_value.m line 48
  15. 15.RFS_code_functions_model_debt_value.m run by RFS_code_functions_model_equity_value.m line 60
  16. 16.RFS_code_functions_model_debt_update.m run by RFS_code_functions_model_debt_value.m line 25
  17. 17.RFS_code_functions_model_OPT_E.m run by RFS_code_functions_model_entrant_value.m line 18
  18. 18.RFS_code_functions_model_q_E.m run by RFS_code_functions_model_OPT_E.m line 18
  19. 19.RFS_code_functions_model_steadystate_distribution.m run by RFS_code_functions_model_moments.m line 31
  20. 20.RFS_code_functions_other_binocdf.m run by RFS_code_functions_model_steadystate_distribution.m line 51
  21. 21.RFS_code_functions_other_binornd.m run by RFS_code_functions_model_moments.m line 40
  22. 22.RFS_code_functions_results_comparative_statics.m run by RFS_code_results.m line 50
  23. 23.RFS_code_functions_results_comparative.m run by RFS_code_functions_results_comparative_statics.m line 12
    writes (not read again): .txt
  24. 24.RFS_code_functions_results_csMoments.m run by RFS_code_functions_results_comparative.m line 22
  25. 25.RFS_code_functions_results_comparative_statics_table.m run by RFS_code_results.m line 54
    reads what RFS_code_results.m wrote
10 more scripts
  1. 26.RFS_code_functions_other_ltable.m run by RFS_code_functions_results_comparative_statics_table.m line 194
  2. 27.RFS_code_functions_results_figures.m run by RFS_code_results.m line 58 reads 4 input files ·
    writes figure_10.txt → read by RFS_code_functions_results_smoothing_cs.m
    writes (not read again): figure_3.txt, figure_5.txt, figure_6.txt, figure_7.txt
  3. 28.RFS_code_functions_results_underinvestment.m run by RFS_code_functions_results_figures.m line 33
  4. 29.RFS_code_functions_other_pd_plot.m run by RFS_code_functions_results_figures.m line 130
  5. 30.RFS_code_functions_results_smoothing_cs.m run by RFS_code_functions_results_figures.m line 193
    reads what RFS_code_functions_results_figures.m wrote
  6. 31.RFS_code_functions_other_polyfix.m run by RFS_code_functions_results_smoothing_cs.m line 18
  7. 32.RFS_code_data_GHM_download_Compustat_data.sas reads 2 input files · 1 merge ·
    writes compannual.csv → read by RFS_code_data_GHM_data_import.do
  8. 33.RFS_code_data_GHM_data_import.do reads 1 input file ·
    reads what RFS_code_data_GHM_download_Compustat_data.sas wrote
    writes patents → read by RFS_code_data_GHM_figure1.do, RFS_code_data_GHM_table2_data.do
    writes (not read again): comp_ann.dta
  9. 34.RFS_code_data_GHM_figure1.do 1 merge ·
    reads what RFS_code_data_GHM_data_import.do wrote
    writes (not read again): size.txt
  10. 35.RFS_code_data_GHM_table2_data.do 1 merge ·
    reads what RFS_code_data_GHM_data_import.do wrote

3 · Merges — 3 joins, 2 followed by a check of the merge result

JoinsHowOn keysCheck that followsWhere
comp1 ← link join (inner) gvkey none
RFS_code_data_GHM_download_Compustat_data.sas:41
RFS_code_data_GHM_download_Compustat_data.sas, line 41 from comp1 a, link b where a.gvkey=b.gvkey and a.datadate >= b.linkdt and ((b.linkenddt=.E) or (a.datadate<=b.linkenddt));
comp_ann ← patents merge 1:1 permno year drop if _merge==2
RFS_code_data_GHM_figure1.do:8
RFS_code_data_GHM_figure1.do, line 8 merge 1:1 permno year using patents
comp_ann ← patents merge 1:1 permno year drop if _merge==2
RFS_code_data_GHM_table2_data.do:8
RFS_code_data_GHM_table2_data.do, line 8 merge 1:1 permno year using patents

4 · The sample — 8 keep/drop steps, 3 variables winsorized or trimmed

Filters, by kind
industry screens ×2
  • drop if (sic>=9000) | ((sic>=4900) & (sic<=4999)) | ((sic>=6000) & (sic<=6999))
    RFS_code_data_GHM_figure1.do:25
    RFS_code_data_GHM_figure1.do, line 25 drop if (sic>=9000) | ((sic>=4900) & (sic<=4999)) | ((sic>=6000) & (sic<=6999))
  • drop if (sic>=9000) | ((sic>=4900) & (sic<=4999)) | ((sic>=6000) & (sic<=6999))
    RFS_code_data_GHM_table2_data.do:28
    RFS_code_data_GHM_table2_data.do, line 28 drop if (sic>=9000) | ((sic>=4900) & (sic<=4999)) | ((sic>=6000) & (sic<=6999))
time period ×1
  • keep if fyear>=1975 & fyear<2010
    RFS_code_data_GHM_table2_data.do:27
    RFS_code_data_GHM_table2_data.do, line 27 keep if fyear>=1975 & fyear<2010
category values ×1
  • drop if dup>0 & linkprim=="C"
    RFS_code_data_GHM_data_import.do:7
    RFS_code_data_GHM_data_import.do, line 7 drop if dup>0 & linkprim=="C"
missing values ×2
  • drop if sic==.
    RFS_code_data_GHM_figure1.do:24
    RFS_code_data_GHM_figure1.do, line 24 drop if sic==.
  • drop if ceq<0 | mtb>20 | missing(at) | missing(sale)
    RFS_code_data_GHM_table2_data.do:29
    RFS_code_data_GHM_table2_data.do, line 29 drop if ceq<0 | mtb>20 | missing(at) | missing(sale)
drops after a merge (_merge) ×2
  • drop if _merge==2
    RFS_code_data_GHM_figure1.do:10
    RFS_code_data_GHM_figure1.do, line 10 drop if _merge==2
  • drop if _merge==2
    RFS_code_data_GHM_table2_data.do:10
    RFS_code_data_GHM_table2_data.do, line 10 drop if _merge==2
Outliers
winsorize at 2.5/97.5 within fyear · 2 variables
quantityRaw valueRaw
RFS_code_data_GHM_figure1.do:27
RFS_code_data_GHM_figure1.do, line 27 winsor2 quantityRaw valueRaw, replace cuts(2.5 97.5) by(fyear)
winsorize at 2/98 within fyear · 1 variable
mktLevRaw
RFS_code_data_GHM_table2_data.do:33
RFS_code_data_GHM_table2_data.do, line 33 winsor2 `var'Raw, replace cuts(2 98) by(fyear)
Missing values
dropped ×2
  • RFS_code_data_GHM_table2_data.do:29
    RFS_code_data_GHM_table2_data.do, line 29 drop if ceq<0 | mtb>20 | missing(at) | missing(sale)
  • RFS_code_data_GHM_figure1.do:24
    RFS_code_data_GHM_figure1.do, line 24 drop if sic==.

5 · Key variables — what enters the models, and where the code builds it

Standard measures computed here: Log Total Assets (size
RFS_code_data_GHM_figure1.do:19
RFS_code_data_GHM_figure1.do, line 19 g size=log(at)
), Market Leverage (mktLevRaw
RFS_code_data_GHM_table2_data.do:22
RFS_code_data_GHM_table2_data.do, line 22 g mktLevRaw=(dlc+dltt)/(dlc+dltt+mktCap)
), Tobin's Q / Market-to-Book (mtb
RFS_code_data_GHM_table2_data.do:21
RFS_code_data_GHM_table2_data.do, line 21 g mtb=(at-ceq+mktCap)/at
)

6 · Models, by the table or figure they feed — 0 estimations, 0 traced into 0 exhibits

Tables and figures the code writes:

7 · Figures: how each is drawn — 2 figures in the code (command, layers, options, the file it is saved to)

scatter 1 · line 1
commandlayersvariables optionssaved aswhere
scatter
scatter
scatter y entrant_history x f_history not saved
RFS_code_functions_model_equilibrium.m:109
RFS_code_functions_model_equilibrium.m, line 109 scatter(f_history,entrant_history,"*")
plot
line
line y f_H_ds(1:end-1), f_nd*ones(length(elasticity_ds_scaled),1) x elasticity_ds_scaled not saved
RFS_code_functions_results_figures.m:161
RFS_code_functions_results_figures.m, line 161 plot(elasticity_ds_scaled,f_H_ds(1:end-1),elasticity_ds_scaled,f_nd*ones(length(elasticity_ds_scaled),1))