Skip to content

R code for paper 'Bayesian model selection for unit root testing with multiple structural breaks'

Notifications You must be signed in to change notification settings

AVoss84/bayesian_unitroots

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bayesian Unit Root Testing with Multiple Structural Breaks

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.


📁 Repository Structure

Main Functions

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).

Marginal Likelihood & Model Comparison

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.

Prior Distributions

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.

MCMC Sampling Components

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.

Data Simulation

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.

Utility Functions

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.

Application & Data

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.

🚀 Quick Start

# 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 order

📦 Dependencies

The code requires the following R packages:

  • mvtnorm - Multivariate normal distributions
  • coda - MCMC diagnostics
  • VGAM - Vector generalized additive models
  • MASS - Matrix operations (ginv)
  • Bolstad - Numerical integration (sintegral)

Install with:

install.packages(c("mvtnorm", "coda", "VGAM", "MASS", "Bolstad"))

📖 Citation

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}
}

📄 License

This project is provided for academic and research purposes.

About

R code for paper 'Bayesian model selection for unit root testing with multiple structural breaks'

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages