Learn R Programming

BVAR (version 0.2.2)

plot.bvar_fcast: Plotting method for Bayesian VAR forecasts

Description

Plotting method for forecasts obtained from bvar or predict.bvar. Forecasts of all or a subset of the available variables can be plotted.

Usage

# S3 method for bvar_fcast
plot(
  x,
  conf_bands,
  vars = NULL,
  variables = NULL,
  orientation = c("vertical", "horizontal"),
  mar = c(2, 2, 2, 0.5),
  ...
)

bv_plot_fcast( x, conf_bands = 0.16, variables = NULL, vars = NULL, orientation = c("vertical", "horizontal"), mar = c(2, 2, 2, 0.5), ... )

Arguments

x

A bvar / bvar_fcast object, obtained from bvar / predict.bvar.

conf_bands

Deprecated. Use predict.bvar. Numeric vector of desired confidence bands.

vars

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

variables

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

orientation

String indicating the orientation of the plots. Defaults to "v" (i.e. vertical); may be set to "h" (i.e. horizontal).

mar

Numeric vector. Margins for par.

...

Other graphical parameters for par.

Value

Returns x invisibly.

See Also

bvar; predict.bvar

Examples

Run this code
# NOT RUN {
data <- matrix(rnorm(400), ncol = 4)
x <- bvar(data, lags = 2, fcast = bv_fcast())

# Plot forecasts for all available variables
plot(predict(x))
# Alternatively
plot(x$fcast)

# Subset to variables in positions 1, 2 and 4 via position and name
plot(x$fcast, vars = c(1, 2, 4))
plot(x$fcast,
  variables = c("gdp", "flux", "cpi", "capacitor"),
  vars = c("gdp", "flux", "capacitor")
)

# Use the method to plot and adjust orientation
plot(x$fcast, orientation = "h")

# Adjust confidence bands via predict
plot(predict(x, conf_bands = c(0.01, 0.05)))
# }

Run the code above in your browser using DataLab