Abstract
Functions to prepare tidy objects from estimated models via 'BVAR' (see Kuschnig & Vashold, 2019) and visualisation thereof. Bridges the gap between estimating models with 'BVAR' and plotting the results in a more sophisticated way with 'ggplot2' as well as passing them on in a tidy format.
Introduction
Bayesian Vector Autoregression (BVAR) is a cornerstone of modern macroeconomic forecasting and policy analysis. However, the outputs of these models—often comprising high-dimensional posterior distributions, impulse responses (IRFs), and complex forecasts—are typically stored in nested list structures that are difficult to manipulate. This creates a significant "friction" point for researchers who wish to move from model estimation to publication-quality visualization or custom downstream analysis.
BVARverse is an R package designed to bridge this gap by applying "tidyverse" principles to BVAR outputs. By converting complex model objects into tidy data frames (tibbles), it allows users to leverage the power of dplyr, tidyr, and ggplot2 for a more streamlined and reproducible workflow.
Methods and Implementation
The package functions as a layer of "tidiers" and "augmenters" for objects generated by the BVAR package. It does not introduce new statistical estimators but rather focuses on data transformation and visualization.
Tidy and Augment Methods
The core of the package lies in its S3 methods. tidy.bvar decomposes BVAR objects into long-format tibbles, covering coefficients, hyperparameter draws, and IRFs. Complementing this, augment.bvar allows users to join model-derived data, such as quantiles and credible intervals, back onto original datasets or forecasts.
Unified Visualization
The bv_ggplot function serves as a high-level wrapper for ggplot2, automating the creation of standard diagnostic and analytical plots. This includes MCMC trace plots, posterior densities, and forecast "fan" charts. The package handles the complex task of mapping variables to facets and credible intervals to ribbons, significantly reducing boilerplate code.
Data and Application
The package's functionality is often demonstrated using the fred_qd dataset, a standard quarterly macroeconomic database. Key variables typically analyzed include the Consumer Price Index (CPIAUCSL), the Unemployment Rate (UNRATE), and the Federal Funds Rate (FEDFUNDS). BVARverse facilitates the transformation of these variables for stationarity before they enter the BVAR estimation pipeline.
Key Insights
The central philosophy of BVARverse is that Bayesian outputs are data. By treating posterior draws as rows in a data frame, the package unlocks the entire R ecosystem for post-estimation analysis.
- MCMC Diagnostics Made Easy: Simplifies convergence checks (trace and density plots) into single function calls.
- Flexible IRFs: Automates the calculation and mapping of IRF credible intervals to
ggplot2aesthetics. - Functional Consistency: Provides a standardized API (
tidy,augment) for interacting withbvar,bvar_fcast, andbvar_irfclasses.
Conclusion
While BVARverse is currently a specialized wrapper for the BVAR package, it represents a significant step toward making complex Bayesian workflows more accessible and reproducible. Future developments may include integration with the broader tidymodels framework and support for a wider range of BVAR implementations.
Summary updated