Learn R Programming

BVAR (version 0.1.5)

bv_plot_trace: Hyperparameter trace & density plot

Description

Diagnostic plots of the trace / density of a single hyperparameter. A parameter may be plotted across multiple iterations of bvar via the ellipsis parameter. Given that the settings for bvar are identical this can be used to assess convergence.

Usage

bv_plot_trace(x, name, ...)

bv_plot_density(x, name, ...)

Arguments

x

A bvar object, obtained from bvar.

name

String with the name of the hyperparameter to plot. Possible values are names of hyperparameters and "ml" for the posterior marginal likelihood.

...

Further bvar objects to include in the plot. The desired hyperparameter must be available and priors of the objects should match.

Examples

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

# Plot the trace of lambda
bv_plot_trace(x, "lambda")

# Adjust par() and plot the density of the posterior marginal likelihood
op <- par(mar = c(2, 2, 2, 0.5))
bv_plot_density(x, "ml")
par(op)

# Assess parameter convergence of several chains via their trace
y <- bvar(data, lags = 2)
z <- bvar(data, lags = 2)
bv_plot_trace(x, "lambda", y, z)
# }

Run the code above in your browser using DataLab