coda: Methods for 'coda' Markov chain Monte Carlo objects

codaR Documentation

Methods for coda Markov chain Monte Carlo objects

Description

Methods to convert parameter and/or coefficient draws from bvar to coda's mcmc (or mcmc.list) format for further processing.

Usage

as.mcmc.bvar(
  x,
  vars = NULL,
  vars_response = NULL,
  vars_impulse = NULL,
  chains = list(),
  ...
)

as.mcmc.bvar_chains(
  x,
  vars = NULL,
  vars_response = NULL,
  vars_impulse = NULL,
  chains = list(),
  ...
)

Arguments

x

A bvar object, obtained from bvar.

vars

Character vector used to select variables. Elements are matched to hyperparameters or coefficients. Coefficients may be matched based on the dependent variable (by providing the name or position) or the explanatory variables (by providing the name and the desired lag). See the example section for a demonstration. Defaults to NULL, i.e. all hyperparameters.

vars_response, vars_impulse

Optional character or integer vectors used to select coefficents. Dependent variables are specified with vars_response, explanatory ones with vars_impulse. See the example section for a demonstration.

chains

List with additional bvar objects. If provided, an object of class mcmc.list is returned.

...

Other parameters for as.mcmc.

Value

Returns a coda mcmc (or mcmc.list) object.

See Also

bvar; mcmc; mcmc.list

Examples


library("coda")

# 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 two BVARs using one lag, default settings and very few draws
x <- bvar(data, lags = 1, n_draw = 750L, n_burn = 250L, verbose = FALSE)
y <- bvar(data, lags = 1, n_draw = 750L, n_burn = 250L, verbose = FALSE)

# Convert the hyperparameter lambda
as.mcmc(x, vars = c("lambda"))

# Convert coefficients for the first dependent, use chains in method
as.mcmc(structure(list(x, y), class = "bvar_chains"), vars = "CPIAUCSL")

# Convert the coefs of variable three's first lag, use in the generic
as.mcmc(x, vars = "FEDFUNDS-lag1", chains = y)

# Convert hyperparameters and constant coefficient values for variable 1
as.mcmc(x, vars = c("lambda", "CPI", "constant"))

# Specify coefficent values to convert in alternative way
as.mcmc(x, vars_impulse = c("FED", "CPI"), vars_response = "UNRATE")


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