Learn R Programming

uGMAR (version 3.1.0)

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 of conditional mean is supported.

Usage

# S3 method for gsmar
predict(object, ..., n_ahead, nsimu = 10000,
  ci = c(0.95, 0.8), pred_type = c("median", "mean", "cond_mean"),
  ci_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.

ci

a numeric vector specifying the confidence levels of the confidence intervals.

pred_type

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

ci_type

should the confidence 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 best prediction and confidence intervals accordingly to ci. 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. The best prediction is then obtained by calculating the sample median (or mean) of each step and the confidence 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., 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 confidence intervals
fit11t <- fitGSMAR(logVIX, 1, 1, model="StMAR", ncores=1, ncalls=1)
predict(fit11t, n_ahead=10, ci_type="upper", ci=c(0.99, 0.95, 0.9))

# G-StMAR model, no confidence intervals
fit12gs <- fitGSMAR(logVIX, 1, M=c(1, 1), model="G-StMAR")
pred12gs <- predict(fit12gs, n_ahead=10, pred_type="median",
 ci_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, ci_type="lower")
# }

Run the code above in your browser using DataLab