GIRF function

Estimate generalized impulse response function for structural STVAR models.

Estimate generalized impulse response function for structural STVAR models.

GIRF estimates generalized impulse response function for structural STVAR models.

GIRF( 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 ) ## S3 method for class 'girf' plot(x, margs, ...) ## S3 method for class 'girf' print(x, ..., digits = 2, N_to_print)

Arguments

  • stvar: an object of class 'stvar', created by, e.g., fitSTVAR or fitSSTVAR.

  • which_shocks: a numeric vector of length at most dd

    (=ncol(data)) and elements in 1,...,d1,...,d specifying the structural shocks for which the GIRF should be estimated.

  • shock_size: 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.

  • N: a positive integer specifying the horizon how far ahead should the generalized impulse responses be calculated.

  • R1: the number of repetitions used to estimate GIRF for each initial value.

  • R2: 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,...,M1,...,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.

  • init_regime: an integer in 1,...,M1,...,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.

  • init_values: 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.

  • which_cumulative: a numeric vector with values in 1,...,d1,...,d

    (d=ncol(data)) specifying which the variables for which the impulse responses should be cumulative. Default is none.

  • scale: 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,...,d1,...,d), the variable of interest is given in the second element (an integer in 1,...,d1,...,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.

  • scale_type: 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.

  • scale_horizon: If scale_type == "peak" what the maximum horizon up to which peak response is expected? Scaling won't based on values after this.

  • ci: a numeric vector with elements in (0,1)(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.

  • use_data_shocks: set TRUE for a special feature in which for every possible length pp 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.

  • data_girf_pars: 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):

    1. An integer between 0 and M determining the (dominant) regime for which the GIRF should be calculated (0

      for all regimes).

    2. 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).

    3. 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.

    4. 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.

    5. 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).

  • ncores: 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: Burn-in period for simulating initial values from a regime.

  • exo_weights: if weight_function="exogenous", provide a size (N+1×M)(N+1 \times M) matrix of exogenous transition weights for the regimes: [h, m]

    for the (after-the-impact) period h1h-1 and regime mm weight ([1, m]

    is for the impact period). Ignored if weight_function!="exogenous".

  • seeds: 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)...

    • If initial values are drawn using init_regime:: R2
    • If initial values are specified in init_values:: dim(init_values)[3]
    • If 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.

  • use_parallel: employ parallel computing? If FALSE, does not print anything.

  • x: object of class 'girf' generated by the function GIRF.

  • margs: numeric vector of length four that adjusts the [bottom_marginal, left_marginal, top_marginal, right_marginal]

    as the relative sizes of the marginals to the figures of the responses.

  • ...: graphical parameters passed to plot method plotting the GIRFs

  • digits: the number of decimals to print

  • N_to_print: an integer specifying the horizon how far to print the estimates and confidence intervals. The default is that all the values are printed.

Returns

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 mmth 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)(n=0), the second for n=1n=1, the third for n=2n=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].

Details

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.

Functions

  • plot(girf): plot method
  • print(girf): print method

Examples

# These are long-running examples that use parallel computing. # It takes approximately 30 seconds to run all the below examples. # Note that larger R1 and R2 should be used for more reliable results; # small R1 and R2 are used here to shorten the estimation time. # Recursively identified logistic Student's t STVAR(p=3, M=2) model with the first # lag of the second variable as the switching variable: params32logt <- c(0.5959, 0.0447, 2.6279, 0.2897, 0.2837, 0.0504, -0.2188, 0.4008, 0.3128, 0.0271, -0.1194, 0.1559, -0.0972, 0.0082, -0.1118, 0.2391, 0.164, -0.0363, -1.073, 0.6759, 3e-04, 0.0069, 0.4271, 0.0533, -0.0498, 0.0355, -0.4686, 0.0812, 0.3368, 0.0035, 0.0325, 1.2289, -0.047, 0.1666, 1.2067, 7.2392, 11.6091) mod32logt <- STVAR(gdpdef, p=3, M=2, params=params32logt, weight_function="logistic", weightfun_pars=c(2, 1), cond_dist="Student", identification="recursive") # GIRF for one-standard-error positive structural shocks, N=30 steps ahead, # with the inital values drawn from the first regime. girf1 <- GIRF(mod32logt, which_shocks=1:2, shock_size=1, N=30, R1=50, R2=50, init_regime=2) print(girf1) # Print the results plot(girf1) # Plot the GIRFs # GIRF for one-standard-error positive structural shocks, N=30 steps ahead, # with the inital values drawn from the second regime. The responses of the # GDP and GDP deflator growth rates are accumulated. girf2 <- GIRF(mod32logt, which_shocks=1:2, which_cumulative=1:2, shock_size=1, N=30, R1=50, R2=50, init_regime=2) plot(girf2) # Plot the GIRFs # GIRF for two-standard-error negative structural shock - the first shock only. # N=50 steps ahead with the inital values drawn from the first regime. The responses # are scaled to correspond an instantanous increase of 0.5 of the first variable. girf3 <- GIRF(mod32logt, which_shocks=1, shock_size=-2, N=50, R1=50, R2=50, init_regime=1, scale_type="instant", scale=c(1, 1, 0.5)) plot(girf3) # Plot the GIRFs # GIRFs for the first shock, using the length p histories in the data where # the first regime is dominant (its transition weight is at least 0.75), # the shock is negative, and the size of the shock is less than 1.5. # The responses are scaled to correspond a unit instantanous increase of the # first variable. girf4 <- GIRF(mod32logt, which_shocks=1, N=30, R1=10, use_data_shocks=TRUE, data_girf_pars=c(1, 0.75, -1, 1, 1.5), scale_type="instant", scale=c(1, 1, 0.5)) plot(girf4) # Plot the GIRFs

See Also

GFEVD, linear_IRF, fitSSTVAR

  • Kilian L., Lütkepohl H. 20017. Structural Vector Autoregressive Analysis. 1st edition. Cambridge University Press, Cambridge.
  • Maintainer: Savi Virolainen
  • License: GPL-3
  • Last published: 2025-02-27