A modular research toolkit for time series econometrics focused on monetary policy and investment dynamics. It implements multiple approaches to handle mixed frequencies and proxy identification, inspired by Diego Känzig’s course.
- Mixed-Frequency VAR (MFVAR) with custom Kalman filter and aggregation constraints
- MIDAS regression to temporally disaggregate quarterly variables to monthly
- Simple interpolation VAR (baseline replication)
- Proxy SVAR identification with bootstrap inference
- Investment subcomponents (equipment vs structures) analysis
- Consistent, modular interfaces and comparison pipelines
Current status: Interpolation VAR, MIDAS, MFVAR, Proxy VAR, and comparison tooling are implemented and used in notebooks and scripts. Local Projections are partial; Stacked VAR is planned.
Requires Python 3.10+.
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
# If needed, common packages:
# pandas numpy matplotlib statsmodels pandas-datareader openpyxl scipy scikit-learn jupyterUse the high-level pipelines to run standard analyses and compare approaches.
from src.pipelines import quick_var_analysis
comp = quick_var_analysis(
approaches=["interpolation", "midas"],
shock_measure="gk"
)
comp.plot_comparison("log_inv")Or full control via VARPipeline:
from src.pipelines import VARPipeline
pipeline = VARPipeline(data_dir="./data")
results = pipeline.estimate_var_irfs(
variables=["gs1", "logcpi", "logip", "ebp"],
shock_measure="gk",
approach="midas", # or "interpolation"
midas_method="beta1", # 'ols', 'almon', 'almon1', 'beta', 'beta1', 'exp'
midas_lags=6,
var_lags=12,
horizon=48,
n_boot=1000,
bootstrap_method="mbb",
proxy_sample_start="1991-01-01",
proxy_sample_end="2012-06-30"
)
pipeline.plot_irfs()See API_GUIDE.md for a comprehensive usage guide.
TimeSeries/
├── README.md
├── API_GUIDE.md # Full API and workflow reference
├── pyproject.toml
├── requirements.txt
├── examples.ipynb # Usage examples
├── src/ # Modular implementation
│ ├── __init__.py
│ ├── data_loader.py # DataLoader: shocks, FRED, merge, prep
│ ├── var_models.py # ProxyVAR, VARWrapper, MixedFrequencyVAR
│ ├── mixed_freq_var.py # Custom MFVAR with Kalman filter
│ ├── midas.py # MIDAS regression (weighting schemes)
│ ├── irfs.py # IRF estimation (bootstrap, plotting)
│ ├── pipelines.py # VARPipeline, ComparisonPipeline
│ ├── utils.py # Plotting and export utilities
│ └── pytorch_var_optimized.py # Optional GPU acceleration
├── notebooks/ # Method tutorials
│ ├── ProxyVAR.ipynb # Proxy SVAR identification
│ ├── MIDAS.ipynb # MIDAS regression
│ ├── MFVAR_with_aggregation.ipynb # Mixed-frequency VAR
│ ├── VARMAX.ipynb # VARMAX state-space
│ ├── LP.ipynb # Local Projections
│ └── aggregation.ipynb # Time aggregation
├── data/ # Datasets
└── tests/ # Test suite
- Data loading: unified loader for GK data, FRED investment, multiple shock measures; quarterly→monthly merge and prep
- MIDAS: OLS and parametric weighting schemes (
beta,beta1,almon,exp), optional grouped lags - MFVAR: state-space with time-varying design (quarterly average of monthly latent states) and support for multiple quarterly variables
- VAR models: standard VAR wrapper plus Proxy SVAR identification
- IRFs: estimation with moving block bootstrap (recommended), plotting, hump-shape checks
- Pipelines: easy single-spec runs and side-by-side comparisons
Start Jupyter and explore the examples:
source .venv/bin/activate
jupyter notebook examples.ipynbMethod-specific tutorials are in the notebooks/ directory.
- FRED: Real Gross Private Domestic Investment (GPDIC1)
- GKData.xlsx: Gertler & Karadi (2015) monthly macro series
- GKMPSurprises.xlsx: monetary policy surprise instruments
- Optional: Compustat for micro extensions
Run tests (selected examples shown):
pytest -q tests/Some tests are long-running (bootstrap); start with a subset if needed.
- Import errors in scripts/notebooks:
import sys; sys.path.append('.')
- Bootstrap is slow: reduce
n_boot, or usebootstrap_method='iid'for quick checks - MIDAS convergence: try
beta1, fewer lags, or enablemidas_group_lags=True
- Complete Local Projections module and add tests
- Implement Stacked VAR approach
- Broaden identification options (sign restrictions, external instruments)
- Add ragged-edge handling and nowcasting utilities
- Package for pip/conda with CLI and docs site (mkdocs or Sphinx)
- Extend to arbitrary frequency mixes via generalized aggregation operators
Built on insights from Diego Känzig’s course; includes replication and extensions of several approaches (interpolation, MIDAS, MFVAR, Proxy VAR).