Learn R Programming

uGMAR (version 3.2.2)

predict.gsmar: Forecast GMAR, StMAR, or G-StMAR process

Description

predict.gsmar forecasts the specified GMAR, StMAR, or G-StMAR process by using the given data to simulate its possible future values. For one-step forecasts using the exact formula for conditional mean is supported.

Usage

# S3 method for gsmar
predict(object, ..., n_ahead, nsimu = 10000,
  pi = c(0.95, 0.8), pred_type = c("median", "mean", "cond_mean"),
  pi_type = c("two-sided", "upper", "lower", "none"), nt,
  plotRes = TRUE)

Arguments

object

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

...

additional arguments passed to grid (ignored if plot_res==FALSE).

n_ahead

a positive integer specifying how many steps in the future should be forecasted.

nsimu

a positive integer specifying to how many simulations the forecast should be based on.

pi

a numeric vector specifying confidence levels for the prediction intervals.

pred_type

should the prediction be based on sample "median" or "mean"? Or should it be one-step-ahead forecast based on the exact conditional mean ("cond_mean")? prediction intervals won't be calculated if the exact conditional mean is used.

pi_type

should the prediction intervals be "two-sided", "upper", or "lower"?

nt

a positive integer specifying the number of observations to be plotted along with the prediction. Default is round(length(data)*0.2).

plotRes

a logical argument defining whether the forecast should be plotted or not.

Value

Returns a data frame containing the empirical point prediction and prediction intervals. Or if pred_type=="cond_mean" returns the optimal prediction as (1x1) numeric vector.

Details

predict.gsmar uses the last p values of the data to simulate nsimu possible future values for each step-ahead. The point prediction is then obtained by calculating the sample median or mean for each step and the prediction intervals are obtained from the empirical fractiles.

We encourage directly using the function simulateGSMAR for quantile based forecasting. With simulateGSMAR it's easy to forecast the mixing weights too.

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

  • There are currently no published references for the G-StMAR model, but it's a straightforward generalization with theoretical properties similar to the GMAR and StMAR models.

See Also

simulateGSMAR, condMoments, fitGSMAR, GSMAR, quantileResidualTests, diagnosticPlot

Examples

Run this code
# NOT RUN {
# GMAR model
fit12 <- fitGSMAR(data=logVIX, p=1, M=2, model="GMAR")
pred12 <- predict(fit12, n_ahead=10)
pred12

# Restricted GMAR model, one-step conditional mean prediction
fit12r <- fitGSMAR(logVIX, 1, 2, model="GMAR", restricted=TRUE)
pred12r <- predict(fit12r, pred_type="cond_mean", plotRes=FALSE)
pred12r

# Non-mixture StMAR model, upper prediction intervals
fit11t <- fitGSMAR(logVIX, 1, 1, model="StMAR", ncores=1, ncalls=1)
predict(fit11t, n_ahead=10, pi_type="upper", pi=c(0.99, 0.95, 0.9))

# G-StMAR model, no prediction intervals
fit12gs <- fitGSMAR(logVIX, 1, M=c(1, 1), model="G-StMAR")
pred12gs <- predict(fit12gs, n_ahead=10, pred_type="median",
 pi_type="none", plotRes=FALSE)
pred12gs
plot(pred12gs)

# Such StMAR(3,2) that the AR coefficients are restricted to be
# the same for both regimes and that the second AR coefficients are
# constrained to zero.
fit32rc <- fitGSMAR(logVIX, 3, 2, model="StMAR", restricted=TRUE,
 constraints=matrix(c(1, 0, 0, 0, 0, 1), ncol=2))
predict(fit32rc, n_ahead=3, pi_type="lower")
# }

Run the code above in your browser using DataLab