GIRF_int
in an INTERNAL function that estimates generalized impulse response function for
structural STVAR models.
GIRF_int(
stvar,
which_shocks,
shock_size = 1,
N = 30,
R1 = 250,
R2 = 250,
init_regime = 1,
init_values = NULL,
which_cumulative = numeric(0),
scale = NULL,
scale_type = c("instant", "peak"),
scale_horizon = N,
ci = c(0.95, 0.8),
use_data_shocks = FALSE,
data_girf_pars = c(0, 0.75, 0, 0, 1.5),
ncores = 2,
burn_in = 1000,
exo_weights = NULL,
seeds = NULL,
use_parallel = TRUE,
cfact_pars = NULL
)
Returns a class 'girf'
list with the GIRFs in the first
element ($girf_res
) and the used arguments the rest. The first
element containing the GIRFs is a list with the \(m\)th element
containing the point estimates for the GIRF in $point_est
(the first
element) and confidence intervals in $conf_ints
(the second
element). The first row is for the GIRF at impact \((n=0)\), the second
for \(n=1\), the third for \(n=2\), and so on.
The element $all_girfs
is a list containing results from all the individual GIRFs
obtained from the MC repetitions. Each element is for one shock and results are in
array of the form [horizon, variables, MC-repetitions]
.
an object of class 'stvar'
, created by, e.g., fitSTVAR
or fitSSTVAR
.
a numeric vector of length at most \(d\)
(=ncol(data)
) and elements in \(1,...,d\) specifying the
structural shocks for which the GIRF should be estimated.
a non-zero scalar value specifying the common size for all scalar components of the structural shock. Note that the conditional covariance matrix of the structural shock is normalized to an identity matrix and that the (generalized) impulse responses may not be symmetric with respect to the sign and size of the shock.
a positive integer specifying the horizon how far ahead should the generalized impulse responses be calculated.
the number of repetitions used to estimate GIRF for each initial value.
the number of initial values to use, i.e., to draw from init_regime
if init_values
are not specified. The confidence bounds
will be sample quantiles of the GIRFs based on different initial values.
Ignored if the argument init_value
is specified.
@param init_regime an integer in \(1,...,M\) specifying the regime from which
the initial values should be generated from (see ?simulate.stvar
). If
use_data_shocks=TRUE
this is argument not used and data_girf_pars
should be specified instead.
an integer in \(1,...,M\) specifying the regime from which the initial values should be generated from (using a simulation procedure with a burn-in period). For models with Gaussian conditional distribution, it is also possible to generate the starting values from the stationary distribution of a regime. See the details section.
a size [p, d, R2]
array specifying the initial values in each slice
for each Monte Carlo repetition, where d is the number of time series in the system and R2
is an argument of this function. In each slice, the last row will be used as initial values
for the first lag, the second last row for second lag etc. If not specified, initial values will be
drawn from the regime specified in init_regimes
.
a numeric vector with values in \(1,...,d\)
(d=ncol(data)
) specifying which the variables for which the impulse
responses should be cumulative. Default is none.
should the GIRFs to some of the shocks be scaled so that they
correspond to a specific magnitude of instantaneous or peak response
of some specific variable (see the argument scale_type
)?
Provide a length three vector where the shock of interest
is given in the first element (an integer in \(1,...,d\)), the variable of
interest is given in the second element (an integer in \(1,...,d\)), and
the magnitude of its instantaneous or peak response in the third element
(a non-zero real number). If the GIRFs of multiple shocks should be scaled, provide
a matrix which has one column for each of the shocks with the columns being
the length three vectors described above.
If argument scale
is specified, should the GIRFs be
scaled to match an instantaneous response ("instant"
) or peak response
("peak"
). If "peak"
, the scale is based on the largest magnitude
of peak response in absolute value. Ignored if scale
is not specified.
If scale_type == "peak"
what the maximum horizon up
to which peak response is expected? Scaling won't based on values after this.
a numeric vector with elements in \((0, 1)\) specifying the confidence levels of the "confidence intervals" that do not quantify uncertainty about the true parameter value but only uncertainty about the initial value (and possibly sign and size of the shock) within the given regime.
set TRUE
for a special feature in which for every possible length \(p\) history in the data,
or a subset of them if so specified in the argument data_girf_pars
, the GIRF is estimated for a shock that has the
sign and size of the corresponding structural shock recovered from the data. If used, the argument which_shocks
must specify only one shock. See the details section.
a length five numeric vector with the following elements determining settings for use_data_shocks=TRUE
(concerns the single shock specified in the argument which_shocks
):
An integer between 0
and M
determining the (dominant) regime for which the GIRF should be calculated (0
for all regimes).
A number between 0.5
and 1
determining how large transition weight a regime should have to be considered dominant
in a given time period (i.e., determining which histories are used to calculate the GIRF if the first element is not 0
).
Either 0
, -1
, or 1
, determining whether the GIRF should be calculated using shocks of all signs,
only negative shocks, or only positive shocks, respectively.
Either, 0
, 1
, or 2
, determining whether the GIRF should be calculated using shocks of all sizes,
only small shocks, or only large shocks, respectively.
A strictly positive real number determining what size shocks are considered large and what size small "in the scale of standard
deviations" (for example, if set to 2
, shocks larger than that are considered large and shocks smaller than that are considered
small; note that the standard deviations of the shocks are normalized to unity).
the number CPU cores to be used in parallel computing. Only single core computing is supported if an initial value is specified (and the GIRF won't thus be estimated multiple times).
Burn-in period for simulating initial values from a regime.
if weight_function="exogenous"
, provide a size
\((N+1 \times M)\) matrix of exogenous transition weights for the regimes: [h, m]
for the (after-the-impact) period \(h-1\) and regime \(m\) weight ([1, m]
is for the impact period). Ignored if weight_function != "exogenous"
.
A numeric vector initializing the seeds for the random number generator for estimation of each GIRF. Should have the length of at least (extra seeds are removed from the end of the vector)...
init_regime
:R2
init_values
:dim(init_values)[3]
use_data_shocks=TRUE
:1 (the vector of seeds are generated according on the number of histories
in the data that satisfy the conditions given in the argument data_girf_pars
).
Set NULL
for not initializing the seed.
employ parallel computing? If FALSE
, does not print
anything.
a list parameters used for calculating counterfactual GIRFs (set to NULL
for regular GIRFs).
Contains the elements:
cfact_metatype
should be always "counterfactual_girf"
.
cfact_type
a character string indicating the type of counterfactual to be computed: should the path of the policy
variable be fixed to some hypothetical path (cfact_type="fixed_path"
) in given impulse response horizons or should the responses
of the policy variable to lagged and contemporaneous movements of some given variable be muted (cfact_type="muted_response"
)?
See details for more information.
policy_var
a positive integer between \(1\) and \(d\) indicating the index of the policy variable considered in the
counterfactual scenario. Note that policy_var
is assumed to satisfy !(policy_var %in% which_shocks)
.
mute_var
a positive integer between \(1\) and \(d\) indicating the index of the variable to whose movements the policy variable
specified in the argument policy_var
should not react to in the counterfactual scenario. This indicates also the index of the shock
to which the policy variable should not react to. It is assumed that mute_var != policy_var
. This argument is only used when
cfact_type="muted_response"
.
cfact_start
a positive integer between \(1\) and \(nsteps\) indicating the starting impulse response horizon period for the counterfactual behavior of the specified policy variable.
cfact_end
a positive integer between cfact_start
and \(nsteps\) indicating the ending period for the counterfactual
behavior of the specified policy variable.
cfact_path
a numeric vector of length cfact_end-cfact_start+1
indicating the hypothetical path of the policy variable
specified in the argument policy_var
. This argument is only used when cfact_type="fixed_path"
.
Important: If this is something else than NULL
, it will change how the function behaves!
The "confidence bounds" do not quantify uncertainty about the true parameter
value but only the initial values (and possibly sign and size of the shock) within the given regime.
If initial values are specified, confidence intervals won't be calculated. Note that if the bounds
look weird in the figure produced by plot.girf
, it is probably because the point estimate is not
inside the bounds. In this case, increasing the argument R2
usually fixes the issue.
Note that if the argument scale
is used, the scaled responses of
the transition weights might be more than one in absolute value.
If weight_function="exogenous"
, exogenous transition weights used in
the Monte Carlo simulations for the future sample paths of the process must
the given in the argument exo_weights
. The same weights are used as
the transition weights across the Monte Carlo repetitions.
If use_data_shocks=TRUE
, the GIRF is estimated using all, or a subset of, the length p histories in the data
as the initial values, and using the sign and size of the corresponding structural shock recovered from the fitted model.
The subset of the length p histories are determined based in the settings given in the argument data_girf_pars
.
Note that the arguments shock_size
and init_regime
are ignored if use_data_shocks=TRUE
.
Kilian L., Lütkepohl H. 2017. Structural Vector Autoregressive Analysis. 1st edition. Cambridge University Press, Cambridge.
GFEVD
, linear_IRF
, hist_decomp
, cfact_hist
, cfact_fore
,
cfact_girf
, fitSSTVAR