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_rateis 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.txtecho "YOUR_KEY" > ~/.fred_api_keypython scripts/fetch_fred_data.py
jupyter notebook models/models.ipynbstreamlit run streamlit_app/app.py- Push this repo to GitHub
- Go to https://streamlit.io/cloud
- Set
streamlit_app/app.pyas 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