GFEVD function

Estimate generalized forecast error variance decomposition for structural STVAR models.

Estimate generalized forecast error variance decomposition for structural STVAR models.

GFEVD estimates generalized forecast error variance decomposition for structural STVAR models.

GFEVD( stvar, N = 30, shock_size = 1, initval_type = c("data", "random", "fixed"), which_cumulative = numeric(0), use_data_shocks = FALSE, data_gfevd_pars = c(0, 0.75), init_regime = 1, init_values = NULL, R1 = 250, R2 = 250, ncores = 2, burn_in = 1000, exo_weights = NULL, seeds = NULL, use_parallel = TRUE ) ## S3 method for class 'gfevd' plot(x, ..., data_shock_pars = NULL) ## S3 method for class 'gfevd' print(x, ..., digits = 2, N_to_print)

Arguments

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

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

  • shock_size: What sign and size should be used for all shocks? By the normalization, the conditional covariance matrix of the structural error is an identity matrix.

  • initval_type: What type initial values are used for estimating the GIRFs that the GFEVD is based on?

    • "data":: Estimate the GIRF for all the possible length pp histories in the data.
    • "random":: Estimate the GIRF for several random initial values generated from the a specific regime specified by the argument init_regimes. The number of initial values is set with the argument R2.
    • "fixed":: Estimate the GIRF for the initial values specified with the argument init_values.
  • 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.

  • use_data_shocks: set TRUE (recommended ) 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_gfevd_pars, the GFEVD is estimated for a shock that has the sign and size of the corresponding structural shock recovered from the data. See the details section.

  • data_gfevd_pars: a length two numeric vector with the following elements determining settings for initval_type="data"

    and use_data_shocks=TRUE:

    1. An integer between 0 and M determining the (dominant) regime for which the GFEVD 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 GFEVD if the first element is not 0).

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

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

  • R2: the number of initial values to be drawn/used if initval_type="random" or "fixed".

  • 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 containing the random number generator seed for estimation of each GIRF. Should have the length of at least...

    • ...nrow(data) - p + 1 if initval_type="data" or use_data_shocks=TRUE.
    • ...R2 if initval_type="random".
    • ...1 if initval_type="fixed.".

    If the length of the vector is greater than what is needed, the extra seeds are dropped from the end of the seeds vector. Set to NULL for not initializing the seed.

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

  • x: object of class 'gfevd' generated by the function GFEVD.

  • ...: graphical parameters passed to the 'ts' plot method when using data_shock_pars.

  • data_shock_pars: if use_data_shocks, alternative plot method can be used that plots the relative contribution of a given shock to the forecast error variance of each variable at a given horizon. Should be a length two numeric vector with the number of the shock (1,..,d) in the first element and the horizon (0,1,2,...,N) in the second element.

  • digits: the number of decimals to print

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

Returns

Returns and object of class 'gfevd' containing the GFEVD for all the variables and to the transition weights. Note that the decomposition does not exist at horizon zero for transition weights because the related GIRFs are always zero at impact. Also contains the individual GFEVDs for each used initial length pp initial value (history) as 4D array with dimensions [horizon, variable, shock, time].

Details

The GFEVD is a forecast error variance decomposition calculated with the generalized impulse response function (GIRF). See Lanne and Nyberg (2016) for details.

If use_data_shocks=TRUE, each GIRF in the GFEVD is estimated for a shock that has the sign and size of the corresponding structural shock recovered from the fitted model. This is done for every possible length pp history in the data, or to a subset of the histories based in the settings given in the argument data_gfevd_pars. The GFEVD is then calculated as the average of the GFEVDs obtained from the GIRFs estimated for the data shocks. The plot and print methods can be used as usual for this GFEVD, but there is also a special feature that allows to plot the contribution of each shock to the variance of the forecast errors at various horizons in specific historical points of time. This can be done by using the plot method with the argument data_shock_pars. Note that the arguments shock_size, initval_type, and init_regime are ignored if use_data_shocks=TRUE.

Functions

  • plot(gfevd): plot method
  • print(gfevd): 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 identifed 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") # GFEVD for one-standard-error positive structural shocks, N=30 steps ahead, # with fix initial values assuming all possible histories in the data. gfevd1 <- GFEVD(mod32logt, shock_size=1, N=30, initval_type="data", R1=10, seeds=1:(nrow(mod32logt$data)-2)) print(gfevd1) # Print the results plot(gfevd1) # Plot the GFEVD # GFEVD for one-standard-error positive structural shocks, N=30 steps ahead, # with fix initial values that are the last p observations of the data. gfevd2 <- GFEVD(mod32logt, shock_size=1, N=30, initval_type="fixed", R1=100, R2=1, init_values=array(mod32logt$data[(nrow(mod32logt$data) - 2):nrow(mod32logt$data),], dim=c(3, 2, 1)), seeds=1) plot(gfevd2) # Plot the GFEVD # GFEVD for two-standard-error negative structural shocks, N=50 steps ahead # with the inital values drawn from the first regime. The responses of both # variables are accumulated. gfevd3 <- GFEVD(mod32logt, shock_size=-2, N=50, initval_type="random", R1=50, R2=50, init_regime=1) plot(gfevd3) # Plot the GFEVD # GFEVD calculated for each lenght p history in the data in such a way that # for each history, the structural shock recovered from the fitted model is # used. gfevd4 <- GFEVD(mod32logt, N=20, use_data_shocks=TRUE, R1=10) plot(gfevd4) # The usual plot method # Plot the contribution of the first to the variance of the forecast errors at # the historial points of time using the structural shocks recovered from the data: plot(gfevd4, data_shock_pars=c(1, 0)) # Contribution at impact plot(gfevd4, data_shock_pars=c(1, 2)) # Contribution after two periods plot(gfevd4, data_shock_pars=c(1, 4)) # Contribution after four periods # GFEVD calculated for each length p history in the data in such a way that # for each history, the structural shock recovered from the fitted model is # used, and only include the histories in which Regime 1 is dominant (its # transition weight is at least 0.75): gfevd5 <- GFEVD(mod32logt, N=20, use_data_shocks=TRUE, data_gfevd_pars=c(1, 0.75), R1=10) plot(gfevd5) # Plot the GFEVD

References

  • Lanne M. and Nyberg H. 2016. Generalized Forecast Error Variance Decomposition for Linear and Nonlineae Multivariate Models. Oxford Bulletin of Economics and Statistics, 78 , 4, 595-603.

See Also

GIRF, linear_IRF, fitSSTVAR

  • Maintainer: Savi Virolainen
  • License: GPL-3
  • Last published: 2025-02-27