irf.bvar {bvartools}R Documentation

Impulse Response Function

Description

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

Usage

## S3 method for class 'bvar'
irf(
  x,
  impulse = NULL,
  response = NULL,
  n.ahead = 5,
  ci = 0.95,
  shock = 1,
  type = "feir",
  cumulative = FALSE,
  keep_draws = FALSE,
  period = NULL,
  ...
)

Arguments

x

an object of class "bvar", usually, a result of a call to bvar or bvec_to_bvar.

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.

shock

size of the shock.

type

type of the impulse response. 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.

period

integer. Index of the period, for which the IR should be generated. Only used for TVP or SV models. Default is NULL, so that the posterior draws of the last time period are used.

...

further arguments passed to or from other methods.

Details

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

A0yt=i=1pAiyti+ut,A_0 y_t = \sum_{i = 1}^{p} A_{i} y_{t-i} + u_t,

with utN(0,Σ)u_t \sim N(0, \Sigma).

Forecast error impulse responses Φi\Phi_i are obtained by recursions

Φi=j=1iΦijAj,i=1,2,...,h\Phi_i = \sum_{j = 1}^{i} \Phi_{i-j} A_j, i = 1, 2,...,h

with Φ0=IK\Phi_0 = I_K.

Orthogonalised impulse responses Θio\Theta^o_i are calculated as Θio=ΦiP\Theta^o_i = \Phi_i P, where P is the lower triangular Choleski decomposition of Σ\Sigma.

Structural impulse responses Θis\Theta^s_i are calculated as Θis=ΦiA01\Theta^s_i = \Phi_i A_0^{-1}.

(Structural) Generalised impulse responses for variable jj, i.e. Θjgi\Theta^g_ji are calculated as Θjig=σjj1/2ΦiA01Σej\Theta^g_{ji} = \sigma_{jj}^{-1/2} \Phi_i A_0^{-1} \Sigma e_j, where σjj\sigma_{jj} is the variance of the jthj^{th} diagonal element of Σ\Sigma and eie_i is a selection vector containing one in its jthj^{th} element and zero otherwise. If the "bvar" object does not contain draws of A0A_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)



[Package bvartools version 0.2.4 Index]