irf.bvar {BVAR}R Documentation

Impulse response and forecast error methods for Bayesian VARs

Description

Retrieves / calculates impulse response functions (IRFs) and/or forecast error variance decompositions (FEVDs) for Bayesian VARs generated via bvar. If the object is already present and no settings are supplied it is simply retrieved, otherwise it will be calculated ex-post. Note that FEVDs require the presence / calculation of IRFs. To store the results you may want to assign the output using the setter function (irf(x) <- irf(x)). May also be used to update confidence bands.

Usage

## S3 method for class 'bvar'
irf(x, ..., conf_bands, n_thin = 1L, verbose = FALSE)

## S3 method for class 'bvar'
fevd(x, ..., conf_bands, n_thin = 1L)

irf(x, ...)

## Default S3 method:
irf(x, ...)

irf(x) <- value

fevd(x, ...)

## Default S3 method:
fevd(x, ...)

fevd(x) <- value

## S3 method for class 'bvar_irf'
summary(object, vars_impulse = NULL, vars_response = NULL, ...)

Arguments

x, object

A bvar object, obtained from bvar. Summary and print methods take in a bvar_irf / bvar_fevd object.

...

A bv_irf object or arguments to be fed into bv_irf. Contains settings for the IRFs / FEVDs.

conf_bands

Numeric vector of confidence bands to apply. E.g. for bands at 5%, 10%, 90% and 95% set this to c(0.05, 0.1). Note that the median, i.e. 0.5 is always included.

n_thin

Integer scalar. Every n_thin'th draw in x is used to calculate, others are dropped.

verbose

Logical scalar. Whether to print intermediate results and progress.

value

A bvar_irf object to assign.

vars_impulse, vars_response

Optional numeric or character vector. Used to subset the summary method's outputs to certain variables by position or name (must be available). Defaults to NULL, i.e. all variables.

Value

Returns a list of class bvar_irf including IRFs and optionally FEVDs at desired confidence bands. The fevd method only returns a the nested bvar_fevd object. The summary method returns a numeric array of impulse responses at the specified confidence bands.

See Also

plot.bvar_irf; bv_irf

Examples


# 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 a BVAR using one lag, default settings and very few draws
x <- bvar(data, lags = 1, n_draw = 600L, n_burn = 100L, verbose = FALSE)

# Compute + store IRF with a longer horizon, no identification and thinning
irf(x) <- irf(x, bv_irf(horizon = 24L, identification = FALSE), n_thin = 5L)

# Update the confidence bands of the IRFs
irf(x, conf_bands = c(0.01, 0.05, 0.1))

# Recalculate with sign restrictions provided via the ellipsis
irf(x, sign_restr = matrix(c(1, NA, NA, -1, 1, -1, -1, 1, 1), nrow = 3))

# Recalculate with zero and sign restrictions provided via the ellipsis
irf(x, sign_restr = matrix(c(1, 0, 1, NA, 1, 1, -1, -1, 1), nrow = 3))

# Calculate the forecast error variance decomposition
fevd(x)

# Get a summary of the saved impulse response function
summary(x)

# Limit the summary to responses of variable #2
summary(x, vars_response = 2L)


[Package BVAR version 1.0.5 Index]