Learn R Programming

tsDyn (version 11.0.4.1)

GIRF: Generalized Impulse response Function (GIRF)

Description

Generates a GIRF for multiple innovations and histories

Usage

GIRF(object, n.ahead, seed = NULL, ...)

# S3 method for setar GIRF( object, n.ahead = 10, seed = NULL, n.hist = 20, n.shock = 20, R = 10, hist_li = NULL, shock_li = NULL, ... )

# S3 method for linear GIRF( object, n.ahead = 10, seed = NULL, n.hist = 20, n.shock = 20, R = 10, hist_li = NULL, shock_li = NULL, ... )

# S3 method for nlVar GIRF( object, n.ahead = 10, seed = NULL, n.hist = 20, n.shock = 20, R = 10, hist_li = NULL, shock_li = NULL, ... )

# S3 method for GIRF_df plot( x, plot_type = c("density", "line"), n.ahead = c(1, 5, 10), var = unique(x$var)[1], n_simu = c(1, 2), ... )

Value

A data-frame, with:

n_simu:

Id for the simulation (total number is n.hist times n.shock)

hist, shock

History and shock used in the nth simulation

n.ahead:

The forecasting horizon. Note the shocks happens at time 0

var:

The variable (on which the shock happens, corresponds hence to the response argument in irf)

sim_1, sim_2

The average (over R times) simulation with the specific shock (sim_1) or with random shocks (sim_2).

girf

The difference between sim_1 and sim_2

Arguments

object

An object of class linear, setar or nlVar (TVAR, TVECM)

n.ahead

The number of steps ahead to compute

seed

optional, the seed for the random numbers

n.hist

The number of past histories to consider. Should be high, ideally size of data (minus lags).

n.shock

The number of actual shocks to consider

R

the number of draws to use for the n.ahead innovations

hist_li

optional, a list of histories (each of same length as lags in the model). If not provided, n.hist histories will be randomly drawn for the original series.

shock_li

optional, a list of innovations. If not provided, n.shock shocks will be randomly drawn from the estimated residuals.

x

output of girf

plot_type

plot: density (for each n.ahead), or line (for multipe n_simu)?

var

plot: which variable to plot?

n_simu

line plot: which simulation to plot?

...

Further arguments passed to specific methods.

Author

Matthieu Stigler

Details

In a nonlinear model, the Impulse response Function (IRF) is not time-, scale- and sign-invariant as in linear models. To address this, Koop et al (1996) introduced the Generalized Impulse response Function (GIRF): $$GIRF(h,\delta,\omega_{t-1})=E[y_{t+h}|\epsilon_{t}=\delta,\epsilon_{t+h}=0,\omega_{t-1}]-E[y_{t+h}|\epsilon_{t}=0,\epsilon_{t+h}=0,\omega_{t-1}]$$

It is the difference between two conditional expectations, one containing the shock of interest, the second one averaging it out. The averaging-out is done by comparing against random innovations (unlike the IRF, which compares against innovation 0), The parameter R corresponds to the number of times this is done.

The GIRF as defined here depends on the particular shock, as well as on the history. Koop et al (1996) suggest to draw multiple combinations of histories and innovations. This is done with arguments n.hist and n.shock (or, alternatively, provide one of, or both, hist_li and hist_li as list of histories and shocks).

The output is a data-frame containing the two average paths for each combinations of shocks and histories.

References

Koop, G, Pesaran, M. H. & Potter, S. M. (1996) Impulse response analysis in nonlinear multivariate models. Journal of Econometrics, 74, 119-147

See Also

irf.nlVar for the IRF, for linear models, or in case of non-linear models, for each regime.

Examples

Run this code

## simulate a SETAR for the example. Higher regime more persistent (AR coef 0.5 instead of 0.2)
set <- setar.sim(B = c(0.5, 0.2, 0.5, 0.5), lag = 1, Thresh = 0.5, n = 500)
set_estim <- setar(set, m = 1)

## regime-specific IRF:
plot(irf(set_estim, regime = "L", boot = FALSE))
plot(irf(set_estim, regime = "H", boot = FALSE))

## GIRF
girf_out <- GIRF(set_estim, n.hist = 10, n.shock = 10) # smaller number for example only

## the GIRF shows a very fast convergence (the shock at n.ahead = 4 is already very close to 0)
plot(girf_out, n.ahead = 1:4)
## investigate a few specific GIRFS:
plot(girf_out, plot_type = "line", n_simu  = 1:5)

Run the code above in your browser using DataLab