Learn R Programming

bvhar

Overview

bvhar provides functions to analyze and forecast multivariate time series using

  • VAR
  • VHAR (Vector HAR)
  • BVAR (Bayesian VAR)
  • BVHAR (Bayesian VHAR)

Basically, the package focuses on the research with forecasting.

Installation

install.packages("bvhar")

Development version

You can install the development version from develop branch.

# install.packages("remotes")
remotes::install_github("ygeunkim/bvhar@develop")

We started to develop a Python version in python directory.

Models

library(bvhar) # this package
library(dplyr)

Repeatedly, bvhar is a research tool to analyze multivariate time series model above

Modelfunctionprior
VARvar_lm()
VHARvhar_lm()
BVARbvar_minnesota()Minnesota (will move to var_bayes())
BVHARbvhar_minnesota()Minnesota (will move to vhar_bayes())
BVARvar_bayes()SSVS, Horseshoe, Minnesota, NG, DL, GDP
BVHARvhar_bayes()SSVS, Horseshoe, Minnesota, NG, DL, GDP

This readme document shows forecasting procedure briefly. Details about each function are in vignettes and help documents.

Details will be updated after the function integration works are done. Until then, we remove Bayesian model sections here.

h-step ahead forecasting:

h <- 19
etf_split <- divide_ts(etf_vix, h) # Try ?divide_ts
etf_tr <- etf_split$train
etf_te <- etf_split$test

VAR

VAR(5):

mod_var <- var_lm(y = etf_tr, p = 5)

Forecasting:

forecast_var <- predict(mod_var, h)

MSE:

(msevar <- mse(forecast_var, etf_te))
#>   GVZCLS   OVXCLS VXFXICLS VXEEMCLS VXSLVCLS   EVZCLS VXXLECLS VXGDXCLS 
#>    5.381   14.689    2.838    9.451   10.078    0.654   22.436    9.992 
#> VXEWZCLS 
#>   10.647

VHAR

mod_vhar <- vhar_lm(y = etf_tr)

MSE:

forecast_vhar <- predict(mod_vhar, h)
(msevhar <- mse(forecast_vhar, etf_te))
#>   GVZCLS   OVXCLS VXFXICLS VXEEMCLS VXSLVCLS   EVZCLS VXXLECLS VXGDXCLS 
#>     6.15     2.49     1.52     1.58    10.55     1.35     8.79     4.43 
#> VXEWZCLS 
#>     3.84

BVAR

BVHAR

Citation

Please cite this package with following BibTeX:

@Manual{,
  title = {{bvhar}: Bayesian Vector Heterogeneous Autoregressive Modeling},
  author = {Young Geun Kim and Changryong Baek},
  year = {2023},
  doi = {10.32614/CRAN.package.bvhar},
  note = {R package version 2.4.0},
  url = {https://cran.r-project.org/package=bvhar},
}

@Article{,
  title = {Bayesian Vector Heterogeneous Autoregressive Modeling},
  author = {Young Geun Kim and Changryong Baek},
  journal = {Journal of Statistical Computation and Simulation},
  year = {2024},
  volume = {94},
  number = {6},
  pages = {1139--1157},
  doi = {10.1080/00949655.2023.2281644},
}

Code of Conduct

Please note that the bvhar project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Copy Link

Version

Install

install.packages('bvhar')

Monthly Downloads

247

Version

2.4.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Young Geun Kim

Last Published

February 1st, 2026

Functions in bvhar (2.4.0)

conf_fdr

Evaluate the Sparsity Estimation Based on FDR
coef

Coefficient Matrix of Multivariate Time Series Models
conf_prec

Evaluate the Sparsity Estimation Based on Precision
conf_fscore

Evaluate the Sparsity Estimation Based on F1 Score
conf_fnr

Evaluate the Sparsity Estimation Based on FNR
conf_recall

Evaluate the Sparsity Estimation Based on Recall
confusion

Evaluate the Sparsity Estimation Based on Confusion Matrix
compute_dic

Deviance Information Criterion of Multivariate Time Series Model
compute_logml

Extracting Log of Marginal Likelihood
divide_ts

Split a Time Series Dataset into Train-Test Set
forecast_expand

Out-of-sample Forecasting based on Expanding Window
gg_loss

Compare Lists of Models
financial_history_appendix

Time points and Financial Events
geom_eval

Adding Test Data Layer
forecast_roll

Out-of-sample Forecasting based on Rolling Window
fitted

Fitted Matrix from Multivariate Time Series Models
irf.varlse

Impulse Response Analysis
dynamic_spillover

Dynamic Spillover
fromse

Evaluate the Estimation Based on Frobenius Norm
etf_vix

CBOE ETF Volatility Index Dataset
mrae

Evaluate the Model Based on MRAE (Mean Relative Absolute Error)
is.stable

Stability of the process
predict

Forecasting Multivariate Time Series
relspne

Evaluate the Estimation Based on Relative Spectral Norm Error
mae

Evaluate the Model Based on MAE (Mean Absolute Error)
relmae

Evaluate the Model Based on RelMAE (Relative MAE)
mape

Evaluate the Model Based on MAPE (Mean Absolute Percentage Error)
mse

Evaluate the Model Based on MSE (Mean Square Error)
mase

Evaluate the Model Based on MASE (Mean Absolute Scaled Error)
reexports

Objects exported from other packages
rmsfe

Evaluate the Model Based on RMSFE
set_horseshoe

Horseshoe Prior Specification
set_gdp

Generalized Double Pareto Shrinkage Hyperparameters for Coefficients and Contemporaneous Coefficients
rmape

Evaluate the Model Based on RMAPE (Relative MAPE)
residuals

Residual Matrix from Multivariate Time Series Models
rmafe

Evaluate the Model Based on RMAFE
set_bvar

Hyperparameters for Bayesian Models
set_dl

Dirichlet-Laplace Hyperparameter for Coefficients and Contemporaneous Coefficients
rmase

Evaluate the Model Based on RMASE (Relative MASE)
set_factor

Factor Specification
set_ldlt

Covariance Matrix Prior Specification
sim_mnormal

Generate Multivariate Normal Random Vector
set_ssvs

Stochastic Search Variable Selection (SSVS) Hyperparameter for Coefficients Matrix and Cholesky Factor
set_intercept

Prior for Constant Term
sim_mniw

Generate Normal-IW Random Family
set_ng

Normal-Gamma Hyperparameter for Coefficients and Contemporaneous Coefficients
sim_mncoef

Generate Minnesota BVAR Parameters
sim_matgaussian

Generate Matrix Normal Random Matrix
sim_iw

Generate Inverse-Wishart Random Matrix
set_lambda

Hyperpriors for Bayesian Models
stableroot

Roots of characteristic polynomial
summary.normaliw

Summarizing Bayesian Multivariate Time Series Model
sim_vhar

Generate Multivariate Time Series Process Following VAR(p)
spillover

h-step ahead Normalized Spillover
spne

Evaluate the Estimation Based on Spectral Norm Error
sim_var

Generate Multivariate Time Series Process Following VAR(p)
sim_mnvhar_coef

Generate Minnesota BVAR Parameters
sim_mvt

Generate Multivariate t Random Vector
print.summary.bvharsp

Summarizing BVAR and BVHAR with Shrinkage Priors
summary.varlse

Summarizing Vector Autoregressive Model
var_lm

Fitting Vector Autoregressive Model of Order p Model
summary.vharlse

Summarizing Vector HAR Model
var_bayes

Fitting Bayesian VAR with Coefficient and Covariance Prior
vhar_bayes

Fitting Bayesian VHAR with Coefficient and Covariance Prior
vhar_lm

Fitting Vector Heterogeneous Autoregressive Model
HQ

Hannan-Quinn Criterion
autoplot.bvharirf

Plot Impulse Responses
autoplot.normaliw

Residual Plot for Minnesota Prior VAR Model
autoplot.predbvhar

Plot Forecast Result
alpl

Evaluate the Density Forecast Based on Average Log Predictive Likelihood (APLP)
VHARtoVMA

Convert VHAR to VMA(infinite)
FPE

Final Prediction Error Criterion
autoplot.bvharsp

Plot the Result of BVAR and BVHAR MCMC
VARtoVMA

Convert VAR to VMA(infinite)
autoplot.bvhardynsp

Dynamic Spillover Indices Plot
choose_bvar

Finding the Set of Hyperparameters of Individual Bayesian Model
bound_bvhar

Setting Empirical Bayes Optimization Bounds
bvar_minnesota

Fitting Bayesian VAR(p) of Minnesota Prior
autoplot.summary.normaliw

Density Plot for Minnesota Prior VAR Model
bvar_flat

Fitting Bayesian VAR(p) of Flat Prior
bvhar_minnesota

Fitting Bayesian VHAR of Minnesota Prior
bvhar-package

bvhar: Bayesian Vector Heterogeneous Autoregressive Modeling
autoplot.summary.bvharsp

Plot the Heatmap of SSVS Coefficients
choose_var

Choose the Best VAR based on Information Criteria
choose_bayes

Finding the Set of Hyperparameters of Bayesian Model