Method to plot trace and densities of hyperparameters and marginal likelihood
or coefficient values obtained from bvar
. Plots may be subset
to certain types using type and to hyperparameters using vars.
Multiple chains, that is comparable bvar
objects, may be plotted
together using the chains argument.
The type argument may be used to access plot.bvar_irf
and plot.bvar_fcast
.
# S3 method for 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),
...
)bv_plot(x, mar = c(2, 2, 2, 0.5), ...)
A bvar
object, obtained from bvar
.
A string with the type of plot desired. The standard method
"full"
includes both density and trace plots.
Optional character vector used to subset the plot. The elements
need to match the names of hyperparameters (plus "ml"
). Defaults
to NULL
, i.e. all hyperparameters.
Optional integer vector with the positions of coefficient values used to subset the plot. vars_response corresponds to a specific dependent variable, vars_impulse to an independent one. Note that the constant is found at position one.
List with additional bvar
objects. Contents are then
added to trace and density plots.
Numeric vector. Margins for par
.
Other graphical parameters for par
.
Returns x invisibly.
# NOT RUN {
data <- matrix(rnorm(200), ncol = 2)
x <- bvar(data, lags = 2, irf = bv_irf(), fcast = bv_fcast())
y <- bvar(data, lags = 2)
# Plot full traces and densities
plot(x)
# Compare with second chain
plot(x, chains = y)
# Only plot the marginal likelihood's density
plot(x, "dens", "ml")
# Use plot as an alternative to plot(irf(x)) and plot(predict(x))
plot(x, "irf")
plot(x, "fcast", vars = 2)
# }
Run the code above in your browser using DataLab