Instructions for running the replicating code.

The code was run in Fortran 90 with IMSL routines (Microsoft Visual Studio 2012) and in Matlab
8.1

1. Compute the baseline steady state. This is achieved by Credit25DP.f90, which uses
commonvar22DP.f90, a file of parameters that are common across the codes for the transition
and the steady state. This will generate the files valfun, invdistr, funtot, we2inc, and
govtax that are loaded into Matlab to compute descriptive statistics and produce graphs.

2. Compute a steady state with tighter borrowing constraints, to reproduce Figure 4. Change
parameter value eff to 0.8 and rename output files in Credit25DP.f90 to valfun2, invdistr2, funtot2,
we2inc2, and govtax2 (valfun2 is used by Matlab code in step 3, the other files are not needed, but
they should not overwrite files from step 1).

3. Next, run steadystatestuff.m (in Matlab). This computes many descriptive statistics and
produces the graphs of Figures 2, 3, and 4. It loads valfun, invdistr, funtot, we2inc, and
govtax from Step 1 and valfun2 from Step 2. It also loads scfdat_1.txt, a data file about the
SCF 1989 which was produced by Cagetti and De Nardi for their 2006 JPE (provided here). The
Matlab script uses the functions distwhist.m, giniperc.m, ginipercmorestuff.m, numtopmask.m,
quantili.m, and stackinvec.m

4. Compute the transition. This is achieved by Trans37ALL.f90, which also uses the file of
common parameter values commonvar22DP.f90. We do this in a fresh directory. The code uses as
an input information from the steady state, that is contained in the following files, that
should be copied onto the fresh directory: exobc, govtax, invdistr, and valfun. The code
automatically generates a subdirectory structure where the various experiments are stored:
eff__ contains the experiments where the parameter f changes (the fraction of capital with which
the entrepreneur can run away); phi__ relates to experiments where phi changes (intermediation
cost); phixi is for experiments where phi changes but xi is also changed to insulate the
corporate sector from the shock; finally, tfp__ contains experiments where TFP is changed.
Within each of these directories, 3 subdirectories are created: AGGE stores the general-equilibrium
experiment in which government spending adjusts; AGPE is for the partial-equilibrium
experiment in which government spending adjusts; and ATGE contains the general-equilibrium
experiment in which taxes adjust.

5. Produce all the graphs for the transition experiments with
endogenous borrowing constraints. To do so, create a subdirectory
makegraphs in the directory of step 4. Put there the Matlab files
plotmarcoredrevision.m, trans201307.m, giniperc.m,
ginipercmorestuff.m, numtopmask.m, quantili.m, and stackinvec.m.
Copy in this directory the following output files from steady
state: valfun, invdistr, we2inc, and govtax. The code looks
automatically for the transition results in the proper
subdirectories (which is why it is important to respect the
directory structure). Run plotmarcoredrevision.

6. Compute the transition with exogenously fixed borrowing limits.
To do this, go back to the parent directory of the directory
created for step 4 (this is important to properly execute the
Matlab files later, otherwise the directory structure there needs
to be changed). Create a new directory called Transexo, and put
there the experiment. Trans37All.f90 and commonvar22DP.f90 should
be stored there. In Trans37All.f90, change the parameter switchbc
to 1 (exogenously given borrowing constraint). The code uses as an
input the same information from the steady state as step 4, so the
same files need to be copied: exobc, govtax, invdistr, and valfun.
It also creates the same subdirectory structure as step 4.

7. Produce the graphs for the transition experiments that compare
endogenous and exogenous borrowing constraints. To do so, put the
file exobcplotmarco1.m in the same directory (makegraphs) created
in step 5 and run it. There is no need to copy other files, since
they have all been copied already in step 5.

8. Figure 1 is produced by plotvarstuff_ff.m, which loads data from
ffcredita.txt (these are flow of funds data as explained in the
text)

9. Figure 9 is produced by bed_plots_commented.m, using data stored in
bed_netchange.prn and bed_lev_y.prn
