R source code for:
Vosseler, Alexander (2016): Bayesian model selection for unit root testing with multiple structural breaks, published in Computational Statistics & Data Analysis (CSDA).
This repository implements a Bayesian approach to unit root testing that simultaneously accounts for multiple structural breaks in level and trend. The methodology uses Reversible Jump Markov Chain Monte Carlo (RJMCMC) for model selection, allowing joint inference on the number of breaks, break locations, autoregressive lag order, and the unit root hypothesis.
| File | Description |
|---|---|
bayes.urtest.R |
Main wrapper function for the Bayesian unit root testing procedure. Orchestrates the RJMCMC sampler, marginal likelihood computation, and posterior inference. |
rjbreak_ADF5.R |
Core RJMCMC algorithm implementing the reversible jump sampler for joint model selection over break points and lag orders in an ADF-type regression framework. |
rjbreak_ADF6.R |
Alternative version of the RJMCMC algorithm with different specifications. |
bayes.test.R |
Computes Bayesian unit root test statistics including posterior probabilities and Bayes factors under different prior specifications (Jeffreys, Normal, Berger-Yang, Lubrano). |
| File | Description |
|---|---|
marglike_BFbreak.R |
Computes the marginal likelihood for the unit root parameter ρ under structural breaks, used for Bayes factor calculations. |
marglike_Break.R |
Marginal likelihood computation for models with structural breaks. |
marglike_NoBreak.R |
Marginal likelihood computation for models without structural breaks. |
cBMA.R |
Bayesian Model Averaging (BMA) functions for combining inference across different model specifications. |
mlogpost.R |
Computes the log-posterior for model parameters. |
mlogpost2.R |
Alternative log-posterior computation. |
| File | Description |
|---|---|
prior_jeffrey.R |
Implements the Jeffreys prior for the autoregressive parameter ρ. |
berger.R |
Implements the Berger-Yang prior for unit root testing. |
lubrano.R |
Implements the Lubrano prior specification. |
| File | Description |
|---|---|
gibbsdraw_k.R |
Gibbs sampler for drawing break dates conditional on other parameters. |
wetbreak.R |
Computes weighted break date frequencies from MCMC output. |
indBrkL.R |
Constructs indicator matrices for structural breaks (drift and trend dummies). |
Xupdate.R |
Updates the design matrix given break locations and lag order. |
| File | Description |
|---|---|
ar1break.sim.R |
Simulates AR(1) processes with structural breaks in intercept, trend, and variance. |
arma.break.R |
Simulates ARMA processes with structural breaks for Monte Carlo experiments. |
| File | Description |
|---|---|
lagw.R |
Creates lagged variable matrices for autoregressive model estimation. |
inv.R |
Matrix inversion utility. |
dec2dual.R |
Converts decimal numbers to binary representation (used for model indexing). |
dual2dec.R |
Converts binary to decimal numbers (inverse of dec2dual.R). |
mymode.R |
Computes the mode of a distribution/sample. |
| File | Description |
|---|---|
Unemployment_rates_data_analysis_Rev_Jump_unitroot.R |
Example application: Unit root analysis of OECD unemployment rates with structural breaks (as presented in the paper). |
oecd_unemployment_rates.txt |
Dataset: OECD unemployment rates used in the empirical application. |
urtest_wmbr.R |
Additional unit root testing utilities with multiple break regression. |
# Load the main testing function
bayes.urtest <- dget("bayes.urtest.R")
# Load your time series data
data <- your_time_series
# Run the Bayesian unit root test
# - Automatic selection of lag order and number of breaks via RJMCMC
results <- bayes.urtest(
data = data,
lags = NULL, # NULL for automatic selection
breaknr = NULL, # NULL for automatic selection
determc = "both" # Include both drift and trend
)
# Access results
results$post_prob # Posterior probabilities for unit root
results$point_est # Point estimates
results$bpoints # Estimated break points
results$lags # Selected lag orderThe code requires the following R packages:
mvtnorm- Multivariate normal distributionscoda- MCMC diagnosticsVGAM- Vector generalized additive modelsMASS- Matrix operations (ginv)Bolstad- Numerical integration (sintegral)
Install with:
install.packages(c("mvtnorm", "coda", "VGAM", "MASS", "Bolstad"))If you use this code in your research, please cite:
@article{vosseler2016bayesian,
title={Bayesian model selection for unit root testing with multiple structural breaks},
author={Vosseler, Alexander},
journal={Computational Statistics \& Data Analysis},
volume={100},
pages={616--630},
year={2016},
publisher={Elsevier}
}This project is provided for academic and research purposes.