Learn R Programming

gmvarkit (version 1.4.1)

simulateGMVAR: Simulate from GMVAR process

Description

simulateGMVAR simulates observations from a GMVAR process.

Usage

simulateGMVAR(
  gmvar,
  nsimu,
  init_values = NULL,
  ntimes = 1,
  drop = TRUE,
  seed = NULL,
  girf_pars = NULL
)

Arguments

gmvar

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

nsimu

number of observations to be simulated.

init_values

a size \((pxd)\) matrix specifying the initial values to be used in the simulation, where d is the number of time series in the system. 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 stationary distribution of the process.

ntimes

how many sets of simulations should be performed?

drop

if TRUE (default) then the components of the returned list are coerced to lower dimension if ntimes==1, i.e., $sample and $mixing_weights will be matrices, and $component will be vector.

seed

set seed for the random number generator?

girf_pars

This argument is used internally in the estimation of generalized impulse response functions (see ?GIRF). You should ignore it.

Value

If drop==TRUE and ntimes==1 (default): $sample, $component, and $mixing_weights are matrices. Otherwise, returns a list with...

$sample

a size (nsimu\( x d x \)ntimes) array containing the samples: the dimension [t, , ] is the time index, the dimension [, d, ] indicates the marginal time series, and the dimension [, , i] indicates the i:th set of simulations.

$component

a size (nsimu\( x \)ntimes) matrix containing the information from which mixture component each value was generated from.

$mixing_weights

a size (nsimu\( x M x \)ntimes) array containing the mixing weights corresponding to the sample: the dimension [t, , ] is the time index, the dimension [, m, ] indicates the regime, and the dimension [, , i] indicates the i:th set of simulations.

Details

The argument ntimes is intended for forecasting: a GMVAR process can be forecasted by simulating its possible future values. One can easily perform a large number simulations and calculate the sample quantiles from the simulated values to obtain prediction intervals (see the forecasting example).

References

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

  • L<U+00FC>tkepohl H. 2005. New Introduction to Multiple Time Series Analysis, Springer.

  • McElroy T. 2017. Computation of vector ARMA autocovariances. Statistics and Probability Letters, 124, 92-96.

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

See Also

fitGMVAR, GMVAR, diagnostic_plot, predict.gmvar, profile_logliks, quantile_residual_tests, GIRF

Examples

Run this code
# NOT RUN {
 # These examples use the data 'eurusd' which comes with the
 # package, but in a scaled form.
 data <- cbind(10*eurusd[,1], 100*eurusd[,2])
 colnames(data) <- colnames(eurusd)

 # GMVAR(1,2), d=2 process, initial values from the stationary
 # distribution
 params122 <- c(0.623, -0.129, 0.959, 0.089, -0.006, 1.006, 1.746,
  0.804, 5.804, 3.245, 7.913, 0.952, -0.037, -0.019, 0.943, 6.926,
  3.982, 12.135, 0.789)
 mod122 <- GMVAR(p=1, M=2, d=2, params=params122)
 set.seed(1)
 sim122 <- simulateGMVAR(mod122, nsimu=500)
 plot.ts(sim122$sample)
 ts.plot(sim122$mixing_weights, col=c("blue", "red"), lty=2)
 plot(sim122$component, type="l")

 # Structural GMVAR(2, 2), d=2 model identified with sign-constraints:
 params222s <- c(-11.964, 155.024, 11.636, 124.988, 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.00, 1.44, 0.742)
 W_222 <- matrix(c(1, 1, -1, 1), nrow=2, byrow=FALSE)
 mod222s <- GMVAR(data, p=2, M=2, params=params222s, parametrization="mean",
   structural_pars=list(W=W_222))
 sim222s <- simulateGMVAR(mod222s, nsimu=100)
 plot.ts(sim222s$sample)

 ## FORECASTING EXAMPLE ##
 # Forecast 5-steps-ahead, 500 sets of simulations with initial
 # values from the data:
 # GMVAR(2,2), d=2 model with mean-parametrization:
 params222 <- c(-11.904, 154.684, 1.314, 0.145, 0.094, 1.292, -0.389,
  -0.070, -0.109, -0.281, 0.920, -0.025, 4.839, 11.633, 124.983, 1.248,
   0.077, -0.040, 1.266, -0.272, -0.074, 0.034, -0.313, 5.855, 3.570,
   9.838, 0.740)
 mod222 <- GMVAR(data, p=2, M=2, params=params222, parametrization="mean")
 sim222 <- simulateGMVAR(mod222, nsimu=5, ntimes=500)

 # Point forecast + 95% prediction intervals:
 apply(sim222$sample, MARGIN=1:2, FUN=quantile, probs=c(0.025, 0.5, 0.972))

 # Similar forecast for the mixing weights:
 apply(sim222$mixing_weights, MARGIN=1:2, FUN=quantile,
       probs=c(0.025, 0.5, 0.972))


 # GMVAR(2,2), d=2 model with AR parameters restricted to be
 # the same for both regimes, custom inital values:
 C_mat <- rbind(diag(2*2^2), diag(2*2^2))
 params222c <- c(1.031, 2.356, 1.786, 3.000, 1.250, 0.060, 0.036,
  1.335, -0.290, -0.083, -0.047, -0.356, 0.934, -0.152, 5.201, 5.883,
  3.560, 9.799, 0.368)
 mod222c <- GMVAR(data, p=2, M=2, params=params222c, constraints=C_mat)
 sim222c <- simulateGMVAR(mod222c, nsimu=100,
              init_values=matrix(c(30, 30, 80, 80), nrow=2))
 plot.ts(sim222c$sample)
 ts.plot(sim222c$mixing_weights, col=c("blue", "red"), lty=2)
 plot(sim222c$component, type="l")
# }

Run the code above in your browser using DataLab