Learn R Programming

gmvarkit (version 1.4.1)

GIRF: Estimate generalized impulse response function for a structural GMVAR model.

Description

GIRF estimate generalized impulse response function for a structural GMVAR model.

Usage

GIRF(
  gmvar,
  which_shocks,
  shock_size,
  N = 30,
  R1 = 250,
  R2 = 250,
  init_regimes = 1:gmvar$model$M,
  init_values = NULL,
  which_cumulative,
  ci = c(0.95, 0.8),
  include_mixweights = TRUE,
  ncores = min(2, parallel::detectCores()),
  plot = TRUE,
  seeds = NULL
)

# S3 method for girf plot(x, add_grid = FALSE, ...)

# S3 method for girf print(x, ..., digits = 2, N_to_print)

Arguments

gmvar

an object of class 'gmvar' created with fitGMVAR or GMVAR.

which_shocks

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.

shock_size

a vector with the same length as which_shocks specifying the size of each structural shock. Alternatively, is a scalar value that specifies a common shock size for all structural shocks. By default, the shock size is one, which is then amplified by the B-matrix according to the conditional standard deviation of the model.

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 be drawn from a stationary distribution of the process or of a specific regime? The confidence bounds will be sample quantiles of the GIRFs based on different initial values. Ignored if the argument init_value is specified.

init_regimes

a numeric vector of length at most \(M\) and elements in \(1,...,M\) specifying the regimes from which the initial values should be generated from. The initial values will be generated from a mixture distribution with the mixture components being the stationary distributions of the specific regimes and the (proportional) mixing weights given by the mixing weight parameters of those regimes. Note that if init_regimes=1:M, the initial values are generated from the stationary distribution of the process and if init_regimes=m, the initial value are generated from the stationary distribution of the \(m\)th regime. Ignored if init_value is specified.

init_values

a matrix or a multivariate class 'ts' object with \(d\) columns and at least \(p\) rows specifying an initial value for the GIRF. The last \(p\) rows are taken to be the initial value assuming that the last row is the most recent observation.

which_cumulative

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.

ci

a numeric vector with elements in \((0, 1)\) specifying the confidence levels of the confidence intervals.

include_mixweights

should the generalized impulse response be calculated for the mixing weights as well? TRUE or FALSE.

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

plot

TRUE if the results should be plotted, FALSE if not.

seeds

a length R2 vector containing the random number generator seed for estimation of each GIRF. A single number of an initial value is specified. or NULL for not initializing the seed. Exists for creating reproducible results.

x

object of class 'girf' generated by the function GIRF.

add_grid

should grid be added to the plots?

...

arguments passed to grid which plots grid to the figure.

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 (N_to_print=N).

Value

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.

Methods (by generic)

  • plot: plot method

  • print: print method

Details

The model needs to be structural in order for this function to be applicable. A structural GMVAR model can be estimated by specifying the argument structural_pars in the function fitGMVAR.

The confidence bounds reflect uncertainty about the initial state (but currently not about the parameter estimates) if initial values are not specified. If initial values are specified, there won't currently be confidence intervals. See the cited paper by Virolainen (2020) for details about the algorithm.

References

  • Kalliovirta L., Meitz M. and Saikkonen P. 2016. Gaussian mixture vector autoregression. Journal of Econometrics, 192, 485-498.

  • Virolainen S. 2020. Structural Gaussian mixture vector autoregressive model. Unpublished working paper, available as arXiv:2007.04713.

See Also

fitGMVAR, GMVAR, gmvar_to_sgmvar, reorder_W_columns, swap_W_signs, simulateGMVAR, predict.gmvar, profile_logliks, quantile_residual_tests, LR_test, Wald_test

Examples

Run this code
# NOT RUN {
 
# }
# NOT RUN {
 # These are long-running examples that use parallel computing.
 # It takes approximately 30 seconds to run all the below examples.

 data(eurusd, package="gmvarkit")
 data <- cbind(10*eurusd[,1], 100*eurusd[,2])
 colnames(data) <- colnames(eurusd)

 # Structural GMVAR(2, 2), d=2 model identified with sign-constraints:
 params22s <- c(1.386, -0.766, 1.005, 5.928, 1.314, 0.145, 0.094, 1.292,
  -0.389, -0.07, -0.109, -0.281, 1.248, 0.077, -0.04, 1.266, -0.272, -0.074,
   0.034, -0.313, 0.903, 0.718, -0.324, 2.079, 7.001, 1.44, 0.741)
 W_22 <- matrix(c(1, 1, -1, 1), nrow=2, byrow=FALSE)
 mod22s <- GMVAR(data, p=2, M=2, params=params22s,
  structural_pars=list(W=W_22))
 mod22s
 # Alternatively, use:
 # fit22s <- fitGMVAR(data, p=2, M=2, structural_pars=list(W=W_22),
 #                    ncalls=40, seeds=1:40)
 # To obtain an estimated version of the same model.

 # Estimating the GIRFs of both structural shocks with default arguments
 # (initial values are drawn from the stationary distribution of the process,
 # 30 periods ahead, confidence levels 0.95 and 0.8):
 girf1 <- GIRF(mod22s, N=12, R1=100, R2=100)
 girf1
 plot(girf1)

 # Estimating the GIRF of the second shock only, 36 periods ahead
 # and shock size 1, initial values drawn from the stationary distribution
 # of the first regime, confidence level 0.9:
 girf2 <- GIRF(mod22s, which_shocks=2, shock_size=1, N=12, init_regimes=1,
               ci=0.9, R1=100, R2=100)
 plot(girf2)

 # Estimating the GIRFs of both structural shocks, shock sizes 1 and 3, N=20
 # periods ahead, estimation based on 200 Monte Carlo simulations, and fixed
 # initial values given by the last p observations of the data:
 girf3 <- GIRF(mod22s, shock_size=c(1, 3), N=20, R1=200,
               init_values=mod22s$data)
 plot(girf3)
 
# }

Run the code above in your browser using DataLab