This project implements a custom Bayesian Nonparametric (BNP) model to perform change-point detection and regime clustering on U.S. macroeconomic time series. The algorithm utilizes Reversible-Jump Markov Chain Monte Carlo (MCMC) methods with Parallel Tempering to explore the parameter space and identify structural breaks in the economy, such as the impact of the COVID-19 pandemic.
The analysis is based on a combined dataset of three key macroeconomic indicators (monthly frequency, starting from August 1982):
- UNRATE: Civilian Unemployment Rate.
- CPIAUCSL: Consumer Price Index for All Urban Consumers.
- REAINTRATREARAT10Y: 10-Year Real Interest Rate.
- Parallel Tempering: Implemented using 4 different temperature chains (
T = {1, 2, 4, 8}) to improve the exploration of the posterior distribution and avoid local optima. - Partition Updates: The algorithm proposes changes to the time series partitions using custom
Split,Merge, andShufflemoves. - Parameter Inference: Metropolis-Hastings steps are used to update the hyperparameters (
gamma,sigma,theta) governing the regime distributions.
- The
codapackage is used to evaluate MCMC convergence. - Diagnostics included: Trace plots, Density plots, Autocorrelation plots (ACF), and Gelman-Rubin diagnostics across the multiple chains.
- To summarize the MCMC output, the project constructs a Posterior Similarity Matrix (PSM).
- The final optimal partition (regime identification) is selected by minimizing the Variation of Information (VI) loss function using tools from the
BNPmixpackage.
- Credible Intervals: Calculated for parameters (
gamma,sigma,theta) within each identified regime. - Posterior Probabilities: Plotted to show the probability of regime membership over time.
- Time Series Annotation: The raw time series are plotted with vertical dashed lines representing the identified change-points (e.g., automatically flagging the
2020-03-01COVID-19 shock).
The project heavily relies on a mix of R and C++ code (Rcpp, RcppArmadillo) for performance optimization.
Key R packages used include:
BNPmix, coda, ggplot2, dplyr, tidyr, LaplacesDemon, mvtnorm, and patchwork. Custom C++ functions (cpp_funz.cpp, wade.cpp) and R scripts for log-likelihood and alpha calculations are sourced directly in the main pipeline.