This project is a deployable Streamlit-based application that models the causal effect of macroeconomic policy interventions—like changes in the federal funds rate—on economic output using machine learning and causal inference. The app enables interactive simulation of counterfactual economic scenarios with multiple predictive models and interpretable visualizations.
Understanding how macroeconomic variables influence GDP is essential for data-driven economic policy. This tool allows users to simulate the impact of monetary levers, estimate causal treatment effects, and evaluate how different models behave in response to changes in inputs such as interest rates, inflation, and unemployment.
We use the FRED API to fetch:
- Gross Domestic Product (GDP)
- Consumer Price Index (CPI)
- Unemployment rate
- Federal Funds Rate (Fed Rate)
- Money supply (M2)
- Employment
These are merged into a time-indexed macroeconomic dataset.
We train multiple forecasting models to predict log(GDP)
using the full set of economic variables:
- 📈 Ridge Regression (baseline linear)
- 🌲 XGBoost, LightGBM, CatBoost (tree ensembles)
🔹 These 4 models are available for use in the deployed Streamlit UI. Prophet and PyTorch models are trained offline but not exposed in the app due to performance or interface constraints.
We simulate the treatment effect of adjusting fed_rate
using a simple T-learner-style logic:
- Predict
log(GDP)
for current data - Predict again after perturbing
fed_rate
- Compute the difference as treatment effect
This gives an interpretable time series of estimated marginal effects from changing Fed policy.
The user can:
- Choose from 4 forecast models
- Adjust the Fed rate using a slider
- View counterfactual forecasts of GDP
- View treatment effect curves
⚠️ Currently onlyfed_rate
is user-adjustable. All other features remain fixed, though they are used by the models.
While Ridge regression offers interpretability, many real-world relationships between macroeconomic factors and GDP are nonlinear or interaction-heavy. That’s why we include multiple model families and causal estimators:
Model | Type | Purpose |
---|---|---|
Ridge | Linear | Transparent baseline |
XGBoost | Tree ensemble | Nonlinear + interaction effects |
CatBoost | Tree ensemble | Handles heterogeneity robustly |
LightGBM | Tree ensemble | Fast + high accuracy |
Prophet (offline) | Time series | Captures seasonal trends |
PyTorch NN (offline) | Neural Net | General function approximation |
T-Learner | Causal Inference | Measures isolated impact of Fed rate |
counterfactual-policy-simulator/
├── data/
│ ├── raw_macro.csv # Raw data from FRED
│ ├── clean_macro.csv # Cleaned time series data
│ └── final_macro.pkl # Preprocessed DataFrame
│
├── models/
│ ├── *.pkl, .pt, .npy # Trained ML + causal models
│
├── streamlit_app/
│ └── app.py # Dashboard entry point
│
├── notebooks/
│ └── model_eval.ipynb # Forecast comparison + metrics
│
├── scripts/
│ ├── fetch_fred_data.py # Automated FRED pipeline
│ └── model_training.py # Full training pipeline
│
├── requirements.txt
└── .streamlit/
└── config.toml # Deployment config
pip install -r requirements.txt
echo "YOUR_KEY" > ~/.fred_api_key
python scripts/fetch_fred_data.py
jupyter notebook models/models.ipynb
streamlit run streamlit_app/app.py
- Push this repo to GitHub
- Go to https://streamlit.io/cloud
- Set
streamlit_app/app.py
as the entry point
- Add
app.py
,requirements.txt
- Configure as a Gradio or Streamlit app
Q: Are features like CPI and unemployment used?
✅ Yes. All models are trained on them. The only variable adjusted in simulation is the Fed rate.
Q: Can I simulate inflation shocks or recessions?
🛠 You can extend the UI to allow sliders for all variables. We’ll add this soon.
Q: Where is the causal forest model?
❌ Removed due to package issues. A simplified T-learner approach is used instead.
James Burrell
Public Policy Fellow @ Google | ML Researcher @ USF | Applied ML Intern @ RTX
GitHub
MIT