Learn R Programming

uGMAR (version 3.2.4)

simulateGSMAR: Simulate values from GMAR, StMAR, and G-StMAR processes

Description

simulateGSMAR simulates values from the specified GMAR, StMAR, or G-StMAR process. Can be utilized for forecasting future values of the process.

Usage

simulateGSMAR(gsmar, nsimu, initvalues, ntimes = 1, drop = TRUE)

Arguments

gsmar

object of class 'gsmar' created with the function fitGSMAR or GSMAR.

nsimu

a positive integer specifying how many values (ahead from initvalues) will be simulated.

initvalues

a numeric vector with length >=p specifying the initial values for the simulation. The last element will be used as the initial value for the first lag, the second last element will be initial value for the second lag, etc. If not specified, initial values will be simulated from the process's stationary distribution.

ntimes

a positive integer specifying 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 $component will be vectors and $mixing_weights will be matrix.

Value

If drop==TRUE and ntimes==1 (default): $sample and $component are vectors and $mixing_weights is a (nsimu\(xM\)) matrix. Otherwise, returns a list with...

$sample

a size (nsimu\(x\)ntimes) matrix containing the simulated values.

$component

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

$mixing_weights

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

Details

The argument ntimes is intended for forecasting: a GSMAR process can be forecasted by simulating its possible future values. One can perform a large number of sets of simulations and calculate the sample quantiles from the simulated values to obtain prediction intervals. See the forecasting example below for a hand-on demonstration.

References

  • Galbraith, R., Galbraith, J. 1974. On the inverses of some patterned matrices arising in the theory of stationary time series. Journal of Applied Probability 11, 63-71.

  • Kalliovirta L. (2012) Misspecification tests based on quantile residuals. The Econometrics Journal, 15, 358-393.

  • Kalliovirta L., Meitz M. and Saikkonen P. 2015. Gaussian Mixture Autoregressive model for univariate time series. Journal of Time Series Analysis, 36, 247-266.

  • Meitz M., Preve D., Saikkonen P. 2018. A mixture autoregressive model based on Student's t-distribution. arXiv:1805.04010 [econ.EM].

  • Virolainen S. 2020. A mixture autoregressive model based on Gaussian and Student's t-distribution. arXiv:2003.05221 [econ.EM].

See Also

fitGSMAR, GSMAR, predict.gsmar, add_data, condMoments, mixingWeights

Examples

Run this code
# NOT RUN {
 
# }
# NOT RUN {
 # GMAR model
 params13 <- c(1.4, 0.88, 0.26, 2.46, 0.82, 0.74, 5.0, 0.68, 5.2, 0.72, 0.2)
 gmar13 <- GSMAR(p=1, M=3, params=params13, model="GMAR")
 sim13 <- simulateGSMAR(gmar13, nsimu=500)
 ts.plot(sim13$sample)
 ts.plot(sim13$component)
 ts.plot(sim13$mixing_weights, col=rainbow(3), lty=2)

 # FORECASTING EXAMPLE:
 # Restricted GMAR model, 10000 sets of simulations with initial values 6 and 6.2.
 params22r <- c(1.4, 1.8, 0.8, -0.1, 0.29, 3.18, 0.84)
 gmar22r <- GSMAR(p=2, M=2, params=params22r, model="GMAR",
  restricted=TRUE)
 sim22r <- simulateGSMAR(gmar22r, nsimu=5, initval=c(6, 6.2), ntimes=10000)
 apply(sim22r$sample, 1, median) # Point forecast
 apply(sim22r$sample, 1, quantile, probs=c(0.025, 0.975)) # 95% interval
 apply(sim22r$mixing_weights, MARGIN=1:2, FUN=median) # mix.weight point forecast
 apply(sim22r$mixing_weights, MARGIN=1:2, FUN=quantile,
  probs=c(0.025, 0.975)) # mix.weight 95% intervals

 # G-StMAR model, with initial values
 params12gs <- c(1.38, 0.88, 0.27, 3.8, 0.74, 3.15, 0.8, 3.6)
 gstmar12 <- GSMAR(p=1, M=c(1, 1), params=params12gs,
 model="G-StMAR")
 sim12gs <- simulateGSMAR(gstmar12, nsimu=500, initvalues=5:6)
 ts.plot(sim12gs$sample)
 ts.plot(sim12gs$component)
 ts.plot(sim12gs$mixing_weights, col=rainbow(3), lty=2)
# }

Run the code above in your browser using DataLab