plot.bvar_irf: Plotting method for Bayesian VAR impulse responses

View source: R/68_irf_plot.R

plot.bvar_irfR Documentation

Plotting method for Bayesian VAR impulse responses

Description

Plotting method for impulse responses obtained from irf.bvar. Impulse responses of all or a subset of the available variables can be plotted.

Usage

## S3 method for class 'bvar_irf'
plot(
  x,
  vars_response = NULL,
  vars_impulse = NULL,
  col = "#737373",
  area = FALSE,
  fill = "#808080",
  variables = NULL,
  mar = c(2, 2, 2, 0.5),
  ...
)

Arguments

x

A bvar_irf object, obtained from irf.bvar.

vars_impulse, vars_response

Optional numeric or character vector. Used to subset the plot's impulses / responses to certain variables by position or name (must be available). Defaults to NULL, i.e. all variables.

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 "transparent".

area

Logical scalar. Whether to fill the credible intervals using polygon.

fill

Character vector. Colour(s) to fill the credible intervals with. See col for more information.

variables

Optional character vector. Names of all variables in the object. Used to subset and title. Taken from x$variables if available.

mar

Numeric vector. Margins for par.

...

Other graphical parameters for par.

Value

Returns x invisibly.

See Also

bvar; irf.bvar

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)

# Store IRFs ex-post
irf(x) <- irf(x)

# Plot impulse responses for all available variables
plot(irf(x))

# Subset to impulse variables in positions 2 and 3 via their name
plot(irf(x), vars_impulse = c(2, 3))

# Subset via position and increase the plotted IRF horizon
plot(irf(x, horizon = 20), vars_impulse = c("UNRATE", "FED"))

# Adjust confidence bands and subset to one response variables
plot(irf(x, conf_bands = 0.25), vars_response = "CPI")

# Draw areas inbetween the confidence bands and skip drawing lines
plot(irf(x), col = "transparent", area = TRUE)

# Subset to a specific impulse and response
plot(irf(x), vars_response = "CPI", vars_impulse = "FED")


BVAR documentation built on May 29, 2024, 5:34 a.m.