GIRF | R Documentation |
Generates a GIRF for multiple innovations and histories
GIRF(object, n.ahead, seed = NULL, ...)
## S3 method for class '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 class '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 class '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 class '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),
...
)
object |
An object of class |
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, |
shock_li |
optional, a list of innovations.
If not provided, |
x |
output of girf |
plot_type |
plot: density (for each |
var |
plot: which variable to plot? |
n_simu |
line plot: which simulation to plot? |
... |
Further arguments passed to specific methods. |
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.
A data-frame, with:
Id for the simulation (total number is n.hist times n.shock)
History and shock used in the nth simulation
The forecasting horizon. Note the shocks happens at time 0
The variable (on which the shock happens, corresponds hence to the response
argument in irf
)
The average (over R times) simulation with the specific shock (sim_1) or with random shocks (sim_2).
The difference between sim_1 and sim_2
Matthieu Stigler
Koop, G, Pesaran, M. H. & Potter, S. M. (1996) Impulse response analysis in nonlinear multivariate models. Journal of Econometrics, 74, 119-147
irf.nlVar
for the IRF, for linear models, or in case of non-linear models, for each regime.
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.