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
compx.fundaSASRFS_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);
CRSP/Compustat Merged (CCM)
1 file
link.ccmxpf_linktableSASRFS_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.matMATLABRFS_code_functions_results_figures.m:14
RFS_code_functions_results_figures.m, line 14 load(os_dir(setts.dir,'\cs_table.mat'));\nodebt_results.matMATLABRFS_code_functions_results_figures.m:15
RFS_code_functions_results_figures.m, line 15 load(os_dir(setts.dir,'\nodebt_results.mat'));\static_results.matMATLABRFS_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.txttextRFS_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.csvCSVRFS_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).
-
1.
RFS_code_functions_model_q.msetup file sourced by 2 scripts -
2.
RFS_code_functions_other_binopdf.msetup file sourced by 4 scripts -
3.
RFS_code_functions_other_nanmean.msetup file sourced by 2 scripts -
4.
RFS_code_functions_other_os_dir.msetup file sourced by 4 scripts -
5.
RFS_code_results.mmaster scriptwrites[setts.dir,'nodebt_results.mat']→ read byRFS_code_functions_results_comparative_statics_table.mwrites[setts.dir,'static_results.mat']→ read byRFS_code_functions_results_comparative_statics_table.m -
6.
RFS_code_model_settings.mrun by RFS_code_results.m line 9 -
7.
RFS_code_functions_model_moments.mrun by RFS_code_results.m line 10 -
8.
RFS_code_functions_model_updatematrix.mrun by RFS_code_functions_model_moments.m line 24 -
9.
RFS_code_functions_model_equilibrium.mrun by RFS_code_functions_model_moments.m line 27 -
10.
RFS_code_functions_model_entrant_value.mrun by RFS_code_functions_model_equilibrium.m line 32 -
11.
RFS_code_functions_model_equity_value_coupon.mrun by RFS_code_functions_model_entrant_value.m line 13 -
12.
RFS_code_functions_model_equity_value.mrun by RFS_code_functions_model_equity_value_coupon.m line 46 -
13.
RFS_code_functions_model_OPT.mrun by RFS_code_functions_model_equity_value.m line 38 -
14.
RFS_code_functions_model_equity_update.mrun by RFS_code_functions_model_equity_value.m line 48 -
15.
RFS_code_functions_model_debt_value.mrun by RFS_code_functions_model_equity_value.m line 60 -
16.
RFS_code_functions_model_debt_update.mrun by RFS_code_functions_model_debt_value.m line 25 -
17.
RFS_code_functions_model_OPT_E.mrun by RFS_code_functions_model_entrant_value.m line 18 -
18.
RFS_code_functions_model_q_E.mrun by RFS_code_functions_model_OPT_E.m line 18 -
19.
RFS_code_functions_model_steadystate_distribution.mrun by RFS_code_functions_model_moments.m line 31 -
20.
RFS_code_functions_other_binocdf.mrun by RFS_code_functions_model_steadystate_distribution.m line 51 -
21.
RFS_code_functions_other_binornd.mrun by RFS_code_functions_model_moments.m line 40 -
22.
RFS_code_functions_results_comparative_statics.mrun by RFS_code_results.m line 50 -
23.
RFS_code_functions_results_comparative.mrun by RFS_code_functions_results_comparative_statics.m line 12writes (not read again):.txt -
24.
RFS_code_functions_results_csMoments.mrun by RFS_code_functions_results_comparative.m line 22 -
25.
RFS_code_functions_results_comparative_statics_table.mrun by RFS_code_results.m line 54reads whatRFS_code_results.mwrote
10 more scripts
-
26.
RFS_code_functions_other_ltable.mrun by RFS_code_functions_results_comparative_statics_table.m line 194 -
27.
RFS_code_functions_results_figures.mrun by RFS_code_results.m line 58 reads 4 input files ·writesfigure_10.txt→ read byRFS_code_functions_results_smoothing_cs.mwrites (not read again):figure_3.txt,figure_5.txt,figure_6.txt,figure_7.txt -
28.
RFS_code_functions_results_underinvestment.mrun by RFS_code_functions_results_figures.m line 33 -
29.
RFS_code_functions_other_pd_plot.mrun by RFS_code_functions_results_figures.m line 130 -
30.
RFS_code_functions_results_smoothing_cs.mrun by RFS_code_functions_results_figures.m line 193reads whatRFS_code_functions_results_figures.mwrote -
31.
RFS_code_functions_other_polyfix.mrun by RFS_code_functions_results_smoothing_cs.m line 18 -
32.
RFS_code_data_GHM_download_Compustat_data.sasreads 2 input files · 1 merge ·writescompannual.csv→ read byRFS_code_data_GHM_data_import.do -
33.
RFS_code_data_GHM_data_import.doreads 1 input file ·reads whatRFS_code_data_GHM_download_Compustat_data.saswrotewritespatents→ read byRFS_code_data_GHM_figure1.do,RFS_code_data_GHM_table2_data.dowrites (not read again):comp_ann.dta -
34.
RFS_code_data_GHM_figure1.do1 merge ·reads whatRFS_code_data_GHM_data_import.dowrotewrites (not read again):size.txt -
35.
RFS_code_data_GHM_table2_data.do1 merge ·reads whatRFS_code_data_GHM_data_import.dowrote
3 · Merges — 3 joins, 2 followed by a check of the merge result
| Joins | How | On keys | Check that follows | Where |
|---|---|---|---|---|
comp1 ← link |
join (inner) | gvkey |
none | RFS_code_data_GHM_download_Compustat_data.sas:41RFS_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:8RFS_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:8RFS_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<2010RFS_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==2RFS_code_data_GHM_figure1.do:10
RFS_code_data_GHM_figure1.do, line 10 drop if _merge==2 - drop if
_merge==2RFS_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 valueRawRFS_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
mktLevRawRFS_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 (), Market Leverage (), Tobin's Q / Market-to-Book ()
size RFS_code_data_GHM_figure1.do:19
RFS_code_data_GHM_figure1.do, line 19
g size=log(at)
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)
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
| command | layers | variables | options | saved as | where |
|---|---|---|---|---|---|
scatterscatter
|
scatter |
y entrant_history
x f_history
|
not saved | RFS_code_functions_model_equilibrium.m:109RFS_code_functions_model_equilibrium.m, line 109
scatter(f_history,entrant_history,"*") |
|
plotline
|
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:161RFS_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)) |