plot.bvar {BVAR}R Documentation

Plotting method for Bayesian VARs

Description

Method to plot trace and densities of coefficient, hyperparameter and marginal likelihood draws obtained from bvar. Several types of plot are available via the argument type, including traces, densities, plots of forecasts and impulse responses.

Usage

## S3 method for class 'bvar'
plot(
  x,
  type = c("full", "trace", "density", "irf", "fcast"),
  vars = NULL,
  vars_response = NULL,
  vars_impulse = NULL,
  chains = list(),
  mar = c(2, 2, 2, 0.5),
  ...
)

Arguments

x

A bvar object, obtained from bvar.

type

A string with the type of plot desired. The default option "full" plots both densities and traces.

vars

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_response, vars_impulse

Optional character or integer vectors used to select coefficents. Dependent variables are specified with vars_response, explanatory ones with vars_impulse. See the example section for a demonstration.

chains

List of bvar objects. Contents are then added to trace and density plots to help assessing covergence.

mar

Numeric vector. Margins for par.

...

Other graphical parameters for par.

Value

Returns x invisibly.

See Also

bvar; plot.bvar_fcast; plot.bvar_irf.

Examples


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

# Plot full traces and densities
plot(x)

# Only plot the marginal likelihood's trace
plot(x, "trace", "ml")

# Access IRF and forecast plotting functions
plot(x, type = "irf", vars_response = 2)
plot(x, type = "fcast", vars = 2)


[Package BVAR version 1.0.5 Index]