This directory contains all computational code for reproducing the results in "Welfare and Spending Effects of Consumption Stimulus Policies."
Full replication takes 4-5 DAYS on a high-end 2025 laptop. For quick validation (~1 hour), use the minimal reproduction: ../reproduce.sh --comp min
Primary Entry Point: do_all.py
This is the main computational workflow controller. It orchestrates 5 sequential steps:
- File:
Target_AggMPCX_LiquWealth/Estimation_BetaNablaSplurge.py - Purpose: Estimates the "splurge" factor (κ) using Norwegian lottery data
- Paper Section: 3.1
- Outputs:
- Figure 1 →
Target_AggMPCX_LiquWealth/Figures/MPC_WealthQuartiles_Figure.pdf - Table 1 →
Target_AggMPCX_LiquWealth/images/MPC_WealthQuartiles_Table.tex - Estimation results →
Target_AggMPCX_LiquWealth/*.txt
- Figure 1 →
- Files:
FromPandemicCode/EstimAggFiscalMAIN.py(main estimation)FromPandemicCode/CreateLPfig.py(creates Figure 2)FromPandemicCode/CreateIMPCfig.py(creates Figure 3a)
- Purpose: Estimates distribution of discount factors (β) for three education groups
- Paper Section: 3.3.3
- Outputs:
- Figure 2 →
FromPandemicCode/Figures/ - Model parameters →
FromPandemicCode/Results/
- Figure 2 →
- Note: This is the most time-intensive step (~7 hours per education group × 3 groups)
- File:
FromPandemicCode/EstimAggFiscalMAIN.py(with Splurge=0 parameter) - Purpose: Robustness analysis with no splurge factor
- Paper Section: Online Appendix
- Parameters: R=1.01, CRRA=2.0, ReplRate_w=0.7, ReplRate_wo=0.5, Splurge=0
- Default: DISABLED in
do_all.pyto save time - Outputs: Table 8 →
FromPandemicCode/Tables/Splurge0/welfare6_SplurgeComp.tex
- Files:
FromPandemicCode/HA-Fiscal-HANK-SAM.py(computes household Jacobians)FromPandemicCode/HA-Fiscal-HANK-SAM-to-python.py(runs HANK experiments)
- Purpose: Robustness check with general equilibrium effects
- Paper Section: 5
- Outputs:
- Figure 5 →
FromPandemicCode/Figures/ - HANK results →
FromPandemicCode/Results/
- Figure 5 →
- File:
FromPandemicCode/AggFiscalMAIN.py - Purpose: Compares three fiscal policies (UI, checks, tax cuts)
- Paper Section: 4
- Outputs:
- Figure 4 →
FromPandemicCode/Figures/ - Figure 6 →
FromPandemicCode/Figures/(uses Step 4 results) - Table 6 (Multipliers) →
FromPandemicCode/Tables/CRRA2/Multiplier.tex - Table 7 (Welfare) →
FromPandemicCode/Tables/CRRA2/welfare6.tex
- Figure 4 →
- Note: This is the longest-running step
Contains Stata scripts for processing Survey of Consumer Finances (SCF) 2004 data.
Key File: make_liquid_wealth.do
- Processes SCF 2004 data
- Calculates liquid wealth statistics by wealth quartile
- Generates empirical moments used in model calibration
- Requires: Stata (tested with version MP/18.0)
- Outputs: Statistics used in Table 2 (Panel B, lines 1-3), Table 4 (Panel B, line 1), Table 5 (Panels A & B, line 1)
Data Files:
rscfp2004.dta- SCF 2004 summary extract (Stata format)rscfp2004.csv- SCF 2004 summary extract (CSV format)ccbal_answer.dta- Processed credit card balance data (Stata format)ccbal_answer.csv- Processed credit card balance data (CSV format)
Data Source: Federal Reserve Board - 2004 Survey of Consumer Finances
See main ../README.md section "Data Availability and Provenance Statements" for detailed data documentation.
Test that environment is working without full computation:
Option 1: Minimal reproduction script
# From project root
./reproduce.sh --comp minOption 2: Enable only fast steps
cd Code/HA-Models
# Edit do_all.py: set run_step_1=True, run_step_4=True, others=False
python do_all.pyComplete replication of all paper results:
# From project root - recommended
./reproduce.sh --comp fullOr directly:
cd Code/HA-Models
# Edit do_all.py: ensure desired steps are enabled
python do_all.pyRecommended configuration for full replication:
# In do_all.py
run_step_1 = True # Required - provides splurge estimate
run_step_2 = True # Required - baseline model
run_step_3 = False # Optional - robustness (adds 21 hours)
run_step_4 = True # Required - HANK model
run_step_5 = True # Required - policy comparisonFor development, debugging, or selective replication:
-
Navigate to computational directory:
cd Code/HA-Models -
Edit
do_all.pyto enable/disable steps:run_step_1 = True # Modify these flags run_step_2 = False # to control execution # ... etc
-
Run the configured workflow:
python do_all.py
-
Check outputs in respective directories (see Output Locations below)
Example: Reproduce only Figure 1:
cd Code/HA-Models
# Edit do_all.py: run_step_1=True, all others=False
python do_all.pyExample: Reproduce policy comparison (requires steps 1-2 first):
cd Code/HA-Models
# Edit do_all.py: run_step_1=True, run_step_2=True, run_step_5=True
python do_all.pyAll outputs are generated in subdirectories of Code/HA-Models/:
- Figure 1:
Target_AggMPCX_LiquWealth/Figures/MPC_WealthQuartiles_Figure.pdf - Figure 2:
FromPandemicCode/Figures/LorenzPtsAll.pdf - Figure 3:
- Panel (a):
FromPandemicCode/Figures/iMPC_CRRA2.pdf - Panel (b):
FromPandemicCode/Figures/UIexitcon.pdf
- Panel (a):
- Figure 4:
FromPandemicCode/Figures/(6 panels)MPCall.pdf,CAll.pdf,YAll.pdf(with matching_WGGEversions)
- Figure 5:
FromPandemicCode/Figures/(6 panels)- HANK-SAM comparison figures
- Figure 6:
FromPandemicCode/Figures/MPCall_Combined.pdf
- Table 1:
Target_AggMPCX_LiquWealth/images/MPC_WealthQuartiles_Table.tex - Table 2-3: Not generated by code (parameter summaries)
- Table 4-5: Partial generation, see
FromPandemicCode/Results/AllResults_CRRA_2.0_R_1.01.txt - Table 6:
FromPandemicCode/Tables/CRRA2/Multiplier.tex - Table 7:
FromPandemicCode/Tables/CRRA2/welfare6.tex - Table 8:
FromPandemicCode/Tables/Splurge0/welfare6_SplurgeComp.tex
- All numerical results:
FromPandemicCode/Results/AllResults_CRRA_2.0_R_1.01.txt- Contains values used in Tables 4-5
- Written by
EstimAggFiscalMAIN.py(lines 1105, 1111)
- Estimation results:
Target_AggMPCX_LiquWealth/*.txt
The LaTeX compilation system automatically integrates outputs from this code directory:
- Python scripts generate PDFs in
Code/HA-Models/FromPandemicCode/Figures/ - These are symlinked to
../Figures/directory - LaTeX document references them via
\FigsDirmacro - No manual copying needed
- Python scripts generate
.texfiles with table content - LaTeX document includes them directly via
\input{} - Tables are automatically updated when code runs
- No manual copying needed
# This workflow keeps everything synchronized:
./reproduce.sh --comp full # Generate computational results
./reproduce.sh --docs # Compile paper (uses generated results)The build system ensures figures and tables are always up-to-date.
- RAM: 8GB minimum, 32GB recommended
- CPU: Multi-core processor beneficial (estimation can parallelize)
- Storage: ~5GB for all intermediate results and outputs
- Time: 4-5 days on a high-end 2025 laptop for complete replication
On Windows 11 laptop with 32GB RAM and AMD Ryzen 9 5900HS (3.30 GHz):
- Step 1: 20 minutes
- Step 2: 21 hours (~7 hours × 3 education groups)
- Step 3: ~21 hours (similar to Step 2, optional)
- Step 4: 1 hour
- Step 5: 65 hours
- Total: ~107 hours (4.5 days) with Step 3, ~86 hours (3.6 days) without
Your timing may vary based on hardware.
- Python: 3.11.7 (other versions may work)
- Core packages:
- econ-ark==0.14.1 (from conda-forge)
- numpy==1.26.4
- matplotlib==3.8.0
- scipy==1.11.4
- pandas==2.1.4
- numba==0.59.0
- sequence-jacobian (from pip)
- Optional: Stata (for empirical analysis only)
Complete dependency list: See ../binder/environment.yml
# Option 1: Using conda (recommended)
uv sync --all-groups # or: conda env create -f ../environment.yml
conda activate hafiscal
# Option 2: Using pip
pip install econ-ark==0.14.1 numpy pandas matplotlib scipy numba
pip install sequence-jacobianError: No module named 'HARK'
# Solution: Install econ-ark package
pip install econ-ark==0.14.1
# or
conda install -c conda-forge econ-ark=0.14.1Error: No module named 'sequence_jacobian'
# Solution: Install via pip (not available on conda)
pip install sequence-jacobianError: ModuleNotFoundError: No module named 'numba'
# Solution:
pip install numba==0.59.0
# or
conda install -c conda-forge numba=0.59.0Computation taking too long / want to test first
# Solution 1: Use minimal reproduction
./reproduce.sh --comp min # From project root
# Solution 2: Enable only fast steps
cd Code/HA-Models
# Edit do_all.py: run_step_1=True, run_step_4=True, others=False
python do_all.pyResults differ slightly from paper
- Expected: Small numerical differences possible
- Cause: Environment variations (OS, package versions, CPU)
- Note: Optimization routines should be deterministic but may vary slightly
- Acceptable: Differences in 3rd-4th decimal places
- Investigate: Large differences (>1% in key results)
Script fails partway through
# Solution: Steps are mostly independent after Step 1-2
# You can restart from a later step by editing do_all.py
# Example: Step 2 completed, want to skip to Step 5
# In do_all.py:
run_step_1 = False # Already done
run_step_2 = False # Already done
run_step_3 = False # Skip optional
run_step_4 = False # Skip if not needed
run_step_5 = True # Run thisPermission errors writing files
# Check write permissions in output directories
ls -ld FromPandemicCode/Figures/
ls -ld FromPandemicCode/Tables/
# Should show write permissions (drwxr-xr-x or similar)Figures not appearing in paper
# Check if figures were generated:
ls -lh FromPandemicCode/Figures/*.pdf
ls -lh Target_AggMPCX_LiquWealth/Figures/*.pdf
# Check if symlinks exist:
ls -lh ../Figures/*.pdf
# Regenerate paper:
cd ..
./reproduce.sh --docsTables not updating in paper
# Tables are .tex files directly included
# Check if generated:
ls -lh FromPandemicCode/Tables/CRRA2/*.tex
# Regenerate paper:
cd ..
./reproduce.sh --docsAdding a new step:
-
Create new Python script in appropriate subdirectory
-
Add step in
do_all.py:run_step_6 = True if run_step_6: print('Step 6: Your new analysis\n') os.chdir('YourSubdir') os.system("python " + "your_script.py") os.chdir('../') print('Concluded Step 6.\n\n')
-
Update this README with step description
-
Update paper if adding new results
Modifying parameters:
- Main parameters in
FromPandemicCode/EstimParameters.py - Model parameters in
FromPandemicCode/Parameters.py - Splurge factor (κ) in
FromPandemicCode/Parameters.py(ADelasticity)
# Quick test with Step 1 only
cd Code/HA-Models
# Edit do_all.py: run_step_1=True, others=False
python do_all.py
# Verify outputs
ls -lh Target_AggMPCX_LiquWealth/Figures/
ls -lh Target_AggMPCX_LiquWealth/*.txtKey files:
do_all.py- Main orchestratorreproduce_min.py- Minimal reproduction scriptEstimParameters.py- Estimated parametersParameters.py- Model parametersOutput_Results.py- Results formatting and table generationWelfare.py- Welfare calculations
Directory structure:
HA-Models/
├── do_all.py # Main entry point
├── reproduce_min.py # Minimal reproduction
├── Target_AggMPCX_LiquWealth/ # Step 1: Splurge estimation
│ ├── Estimation_BetaNablaSplurge.py
│ ├── Figures/ # Figure 1 output
│ └── images/ # Table 1 output
└── FromPandemicCode/ # Steps 2-5: Main analysis
├── EstimAggFiscalMAIN.py # Step 2: Estimation
├── CreateLPfig.py # Figure 2
├── CreateIMPCfig.py # Figure 3a
├── EvalConsDropUponUILeave.py # Figure 3b
├── AggFiscalMAIN.py # Step 5: Policy comparison
├── HA-Fiscal-HANK-SAM.py # Step 4: HANK household
├── HA-Fiscal-HANK-SAM-to-python.py # Step 4: HANK experiments
├── Figures/ # Figures 2-6 output
├── Tables/ # Tables 6-8 output
└── Results/ # Numerical results
- Main README:
../README.md- Setup and overview - AI Documentation:
../README_IF_YOU_ARE_AN_AI/- AI-optimized guides- Especially:
030_COMPUTATIONAL_WORKFLOWS.md- Detailed workflow guide
- Especially:
- Reproduction Scripts:
../reproduce/- Script documentation - Paper:
../HAFiscal.pdf- Complete paper with results - Slides:
../HAFiscal-Slides.pdf- Presentation version
If you use this code, please cite:
Carroll, Christopher D., Edmund Crawley, Weifeng Dai, Ivan Frankovic, and Hakon Tretvoll (2025). "Welfare and Spending Effects of Consumption Stimulus Policies."
For issues or questions:
- Check troubleshooting sections above
- Review main README troubleshooting:
../README.md - Check AI troubleshooting guide:
../README_IF_YOU_ARE_AN_AI/080_TROUBLESHOOTING_FOR_AI_SYSTEMS.md - Verify environment:
../reproduce/reproduce_environment_comp_uv.sh(or activate:source ../.venv/bin/activate) - Open an issue on the project repository (if applicable)
Quick Reference Command Summary:
# From project root:
./reproduce.sh --comp min # Test (~1 hour)
./reproduce.sh --comp full # Full replication (4-5 days on a high-end 2025 laptop)
./reproduce.sh --comp max # Maximum replication with robustness (~5 days on a high-end 2025 laptop)
./reproduce.sh --docs # Compile paper
# From Code/HA-Models/:
python do_all.py # Run configured steps
python reproduce_min.py # Minimal test