predict.gsmar {uGMAR} | R Documentation |
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 class '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"),
plot_res = TRUE,
mix_weights = TRUE,
nt
)
Arguments
object |
object of class |
... |
additional arguments passed to |
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 ( |
pi_type |
should the prediction intervals be "two-sided", "upper", or "lower"? |
plot_res |
a logical argument defining whether the forecast should be plotted or not. |
mix_weights |
|
nt |
a positive integer specifying the number of observations to be plotted
along with the prediction. Default is |
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.
The function simulate.gsmar
can also be used directly for quantile based forecasting.
Value
Returns a class 'gsmarpred'
object containing, among the specifications,...
$pred |
Point forecasts |
$pred_ints |
Prediction intervals |
$mix_pred |
Point forecasts for mixing weights |
mix_pred_ints |
Individual prediction intervals for mixing weights, as |
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(2), 247-266.
Meitz M., Preve D., Saikkonen P. 2023. A mixture autoregressive model based on Student's t-distribution. Communications in Statistics - Theory and Methods, 52(2), 499-515.
Virolainen S. 2022. A mixture autoregressive model based on Gaussian and Student's t-distributions. Studies in Nonlinear Dynamics & Econometrics, 26(4) 559-580.
See Also
simulate.gsmar
, cond_moments
, fitGSMAR
, GSMAR
,
quantile_residual_tests
, diagnostic_plot
Examples
## These examples take approximately 30 seconds to run.
# G-StMAR model with one GMAR type and one StMAR type regime
fit42gs <- fitGSMAR(M10Y1Y, p=4, M=c(1, 1), model="G-StMAR",
ncalls=1, seeds=4)
# Forecast 12 steps ahead based on 10000 simulated sample paths, prediction
# interval confidence levels 0.95 and 0.8, prediction based on sample median,
# and two-sided prediction intevals:
mypred <- predict(fit42gs, n_ahead=12, nsimu=10000, pi=c(0.95, 0.8),
pred_type="median", pi_type="two-sided")
mypred
plot(mypred)
# Forecast 24 steps ahead based on 1000 simulated sample paths, prediction
# interval confidence level 0.99 and 0.9, prediction based on sample mean,
# and upper prediction intevals:
mypred2 <- predict(fit42gs, n_ahead=24, nsimu=1000, pi=c(0.99, 0.9),
pred_type="mean", pi_type="upper")
# Forecast 24 steps ahead based on 1000 simulated sample paths, prediction
# interval confidence level 0.99, 0.95, 0.9 and 0.8, prediction based on
# sample median, and lower prediction intevals:
mypred3 <- predict(fit42gs, n_ahead=24, nsimu=1000, pi=c(0.99, 0.95, 0.9, 0.8),
pred_type="median", pi_type="lower")
# GMAR model
params12 <- c(1.70, 0.85, 0.30, 4.12, 0.73, 1.98, 0.63)
gmar12 <- GSMAR(data=simudata, p=1, M=2, params=params12, model="GMAR")
pred12 <- predict(gmar12, n_ahead=10, nsimu=1000, pi=c(0.95, 0.9, 0.8),
pred_type="median", pi_type="two-sided")
pred12
plot(pred12)
# One-step prediction based on the exact conditional mean:
predict(gmar12, n_ahead=1, pred_type="cond_mean", plot_res=FALSE)