Learn R Programming

BVAR (version 0.2.2)

bv_priors: Prior settings

Description

Function to provide priors and their parameters to bvar. Used for adjusting the parameters treated as hyperparameters, the Minnesota prior and adding various dummy priors through the ellipsis parameter. Note that treating \(\psi\) (psi) as a hyperparameter in a model with many variables may lead to very low acceptance rates and thus hinder convergence.

Usage

bv_priors(hyper = "auto", mn = bv_mn(), ...)

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

# S3 method for bv_minnesota print(x, indent = FALSE, ...)

# S3 method for bv_dummy print(x, indent = FALSE, ...)

# S3 method for bv_psi print(x, indent = FALSE, ...)

Arguments

hyper

Character vector. Used to specify the parameters to be treated as hyperparameters. May also be set to "auto" or "full" for an automatic / full subset. Other allowed values are the Minnesota prior's parameters "lambda", "alpha" and "psi" as well as the names of additional dummy priors included via ....

mn

List of class "bv_minnesota". Options for the Minnesota prior, set via bv_mn.

...

Optional lists of class "bv_dummy" with options for dummy priors. Must be assigned a name in the function call. Created with bv_dummy.

x

Object of class bv_priors, bv_dummy or bv_psi.

indent

Logical scalar. Used internally to format printed outputs.

Value

Returns a named list of class bv_priors with options for bvar.

See Also

bv_mn; bv_dummy

Examples

Run this code
# NOT RUN {
# Extending hyperparameters to the full Minnesota prior
bv_priors(c("lambda", "alpha", "psi"))
# Alternatively
bv_priors("full")

# Adding a dummy prior via `bv_dummy()`

# First create a single-unit-root prior
add_sur <- function(Y, lags, par) {
  sur <- if(lags == 1) {Y[1, ] / par} else {
    colMeans(Y[1:lags, ]) / par
  }
  Y_sur <- sur
  X_sur <- c(1 / par, rep(sur, lags))

  return(list("Y" = Y_sur, "X" = X_sur))
}
sur <- bv_dummy(mode = 1, sd = 1, min = 0.0001, max = 50, fun = add_sur)

# Then add the prior to `bv_priors()`
priors_dum <- bv_priors(hyper = "auto", sur = sur)
# }

Run the code above in your browser using DataLab