Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

irf

Impulse Response Function


Description

Computes the impulse response coefficients of an object of class "bvar" for n.ahead steps.

A plot function for objects of class "bvarirf".

Usage

irf(
  x,
  impulse = NULL,
  response = NULL,
  n.ahead = 5,
  ci = 0.95,
  type = "feir",
  cumulative = FALSE,
  keep_draws = FALSE
)

## S3 method for class 'bvarirf'
plot(x, ...)

Arguments

x

an object of class "bvarirf", usually, a result of a call to irf.

impulse

name of the impulse variable.

response

name of the response variable.

n.ahead

number of steps ahead.

ci

a numeric between 0 and 1 specifying the probability mass covered by the credible intervals. Defaults to 0.95.

type

type of the impulse resoponse. Possible choices are forecast error "feir" (default), orthogonalised "oir", structural "sir", generalised "gir", and structural generalised "sgir" impulse responses.

cumulative

logical specifying whether a cumulative IRF should be calculated.

keep_draws

logical specifying whether the function should return all draws of the posterior impulse response function. Defaults to FALSE so that the median and the credible intervals of the posterior draws are returned.

...

further graphical parameters.

Details

The function produces different types of impulse responses for the VAR model

A_0 y_t = ∑_{i = 1}^{p} A_{i} y_{t-i} + u_t,

with u_t \sim N(0, Σ).

Forecast error impulse responses Φ_i are obtained by recursions

Φ_i = ∑_{j = 1}^{i} Φ_{i-j} A_j, i = 1, 2,...,h

with Φ_0 = I_K.

Orthogonalised impulse responses Θ^o_i are calculated as Θ^o_i = Φ_i P, where P is the lower triangular Choleski decomposition of Σ.

Structural impulse responses Θ^s_i are calculated as Θ^s_i = Φ_i A_0^{-1}.

(Structural) Generalised impulse responses for variable j, i.e. Θ^g_ji are calculated as Θ^g_{ji} = σ_{jj}^{-1/2} Φ_i A_0^{-1} Σ e_j, where σ_{jj} is the variance of the j^{th} diagonal element of Σ and e_i is a selection vector containing one in its j^{th} element and zero otherwise. If the "bvar" object does not contain draws of A_0, it is assumed to be an identity matrix.

Value

A time-series object of class "bvarirf" and if keep_draws = TRUE a simple matrix.

References

Lütkepohl, H. (2006). New introduction to multiple time series analysis (2nd ed.). Berlin: Springer.

Pesaran, H. H., Shin, Y. (1998). Generalized impulse response analysis in linear multivariate models. Economics Letters, 58, 17-29.

Examples

# Load data
data("e1")
e1 <- diff(log(e1)) * 100

# Generate model data
model <- gen_var(e1, p = 2, deterministic = 2,
                 iterations = 100, burnin = 10)
# Chosen number of iterations and burnin should be much higher.

# Add prior specifications
model <- add_priors(model)

# Obtain posterior draws
object <- draw_posterior(model)

# Obtain IR
ir <- irf(object, impulse = "invest", response = "cons")

# Plot IR
plot(ir)



# Load data
data("e1")
e1 <- diff(log(e1)) * 100

# Generate model data
model <- gen_var(e1, p = 2, deterministic = 2,
                 iterations = 100, burnin = 10)
# Number of iterations and burnin should be much higher.

# Add prior specifications
model <- add_priors(model)

# Optain posterior draws
object <- draw_posterior(model)

# Calculate IR
ir <- irf(object, impulse = "invest", response = "cons")

# Plot IR
plot(ir)

bvartools

Bayesian Inference of Vector Autoregressive Models

v0.2.0
GPL (>= 2)
Authors
Franz X. Mohr [aut, cre]
Initial release
2021-04-25

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.