Learn R Programming

BVAR (version 0.2.2)

density.bvar: Density methods for Bayesian VARs

Description

Calculates densities of hyperparameters or coefficient values of Bayesian VARs generated via bvar. Wraps standard density functionality into a list.

Usage

# S3 method for bvar
density(x, vars = NULL, vars_response = NULL, vars_impulse = NULL, ...)

# S3 method for bvar_density print(x, ...)

# S3 method for bvar_density plot(x, mar = c(2, 2, 2, 0.5), mfrow = c(length(x), 1), ...)

independent_index(var, n_vars, lag)

Arguments

x

A bvar object, obtained from bvar.

vars

Optional character vector used to specify hyperparemeters to retrieve the density of. The elements need to match the names of hyperparameters (plus "ml"). Defaults to NULL, i.e. all hyperparameters.

vars_response, vars_impulse

Optional integer vector with the positions of coefficient values to retrieve densities of. vars_response corresponds to a specific dependent variable, vars_impulse to an independent one. Note that the constant is found at position one.

...

Fed to density or par.

mar

Numeric vector. Margins for par.

mfrow

Numeric vector. Rows for par.

var, n_vars, lag

Integer scalars.

Value

Returns a list with outputs of density.

See Also

bvar

Examples

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

# Get densities of standard hyperparameters
density(x)

# Plot them
plot(density(x))

# Only get the density of the marginal likelihood
density(x, vars = "ml")

# Check out the constant's density on both dependents
plot(density(x, vars_impulse = 1))

# Get the density of the 1st lag of variable 2's coefficients with
# respect to variable 1
idx <- independent_index(var = 2, n_vars = 2, lag = 1)
density(x, vars_response = 1, vars_impulse = idx)
# }

Run the code above in your browser using DataLab