tidy.bvar {BVARverse}R Documentation

Tidy BVAR outputs and convert into a tibble


Turn the outputs of a Bayesian VAR (see bvar) into a a tidy tibble. Methods are available for bvar objects (will yield a subset of coefficient and/or hyperparameter draws), bvar_coefs objects (with the coefficients and their quantiles) bvar_fcast objects (with predictions, their quantiles and optionally real datapoints), and bvar_irf objects (with impulse responses).


## S3 method for class 'bvar'
  vars = NULL,
  vars_response = NULL,
  vars_impulse = NULL,
  chains = list(),

## S3 method for class 'bvar_coefs'
tidy(x, ...)

## S3 method for class 'bvar_fcast'
tidy(x, t_back = 0L, ...)

## S3 method for class 'bvar_irf'
tidy(x, ...)



A bvar or derived object to turn into a dataframe.


Character vector used to select variables. Elements are matched to hyperparameters or coefficients. Coefficients may be matched based on the dependent variable (by providing the name or position) or the explanatory variables (by providing the name and the desired lag). See the example section for a demonstration. Defaults to NULL, i.e. all hyperparameters.

vars_impulse, vars_response

Optional character or integer vectors used to select coefficents. Dependent variables are specified with vars_response, explanatory ones with vars_impulse. Defaults to NULL, indicating that no coefficients will be processed. draws.


List of bvar objects. Contents of multiple runs are added to the output, in order to help in assessing covergence.


Not used.


Integer scalar. Whether to include actual datapoints in the tidied forecast.


Returns a tidy tibble with relevant information for further processing.


# Access a subset of the fred_qd dataset
data <- fred_qd[, c("CPIAUCSL", "UNRATE", "FEDFUNDS")]
# Transform it to be stationary
data <- fred_transform(data, codes = c(5, 5, 1), lag = 4)

# Estimate a BVAR using one lag, default settings and very few draws
x <- bvar(data, lags = 1, n_draw = 1000L, n_burn = 200L, verbose = FALSE)

# Create tidy tibbles from the outputs

[Package BVARverse version 0.0.1 Index]