bv_ggplot {BVARverse} | R Documentation |
Quick ggplot2 plots for Bayesian VARs
Description
Function to quickly plot outputs from bvar
and derived objects.
Supported plots include traces and densities, forecasts, and impulse
response functions. For more flexible plots one may use the outputs of
tidy.bvar
and augment.bvar
.
Usage
bv_ggplot(x, ...)
## Default S3 method:
bv_ggplot(x, ...)
## S3 method for class 'bvar_chains'
bv_ggplot(x, ...)
## S3 method for class 'bvar'
bv_ggplot(
x,
type = c("trace", "density"),
vars = NULL,
vars_response = NULL,
vars_impulse = NULL,
orientation = c("horizontal", "vertical"),
chains = list(),
...
)
## S3 method for class 'bvar_irf'
bv_ggplot(x, vars_response = NULL, vars_impulse = NULL, col = "#737373", ...)
## S3 method for class 'bvar_fcast'
bv_ggplot(x, vars = NULL, col = "#737373", t_back = 1L, ...)
Arguments
x |
A |
... |
Not used. |
type |
A string with the type (trace or density) of plot desired. |
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 |
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
|
vars_impulse |
Optional character or integer vectors used
to select coefficents. Dependent variables are specified with
vars_response, explanatory ones with vars_impulse. Defaults to
|
orientation |
A string indicating the desired orientation of trace or density plots |
chains |
List of |
col |
Character vector. Colour(s) of the lines delineating credible
intervals. Single values will be recycled if necessary. Recycled HEX color
codes are varied in transparency if not provided (e.g. "#737373FF"). Lines
can be bypassed by setting this to |
t_back |
Integer scalar. Whether to include actual datapoints in the tidied forecast. |
Value
Returns a ggplot
object with a basic structure.
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 the outputs - alternatively use ggplot() with fortify()
bv_ggplot(x)
bv_ggplot(irf(x))
bv_ggplot(predict(x))