Description Usage Arguments Details Value References See Also Examples
View source: R/predictMethod.R
predict.gsmar
forecasts the specified GMAR, StMAR, or GStMAR process by using the given
data to simulate its possible future values. For onestep forecasts using the exact formula for conditional
mean is supported.
1 2 3 4 5 6 7 8 9 10 11 12 13 
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 onestepahead forecast based on the exact conditional mean ( 
pi_type 
should the prediction intervals be "twosided", "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 
predict.gsmar
uses the last p
values of the data to simulate nsimu
possible future values for each stepahead. 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.
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 
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, 6371.
Kalliovirta L. (2012) Misspecification tests based on quantile residuals. The Econometrics Journal, 15, 358393.
Kalliovirta L., Meitz M. and Saikkonen P. 2015. Gaussian Mixture Autoregressive model for univariate time series. Journal of Time Series Analysis, 36, 247266.
Meitz M., Preve D., Saikkonen P. 2021. A mixture autoregressive model based on Student's tdistribution. Communications in Statistics  Theory and Methods, doi: 10.1080/03610926.2021.1916531
Virolainen S. 2021. A mixture autoregressive model based on Gaussian and Student's tdistributions. Studies in Nonlinear Dynamics & Econometrics,doi: 10.1515/snde20200060
simulate.gsmar
, cond_moments
, fitGSMAR
, GSMAR
,
quantile_residual_tests
, diagnostic_plot
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36  ## These examples take approximately 30 seconds to run.
# GStMAR model with one GMAR type and one StMAR type regime
fit42gs < fitGSMAR(M10Y1Y, p=4, M=c(1, 1), model="GStMAR",
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 twosided prediction intevals:
mypred < predict(fit42gs, n_ahead=12, nsimu=10000, pi=c(0.95, 0.8),
pred_type="median", pi_type="twosided")
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="twosided")
pred12
plot(pred12)
# Onestep prediction based on the exact conditional mean:
predict(gmar12, n_ahead=1, pred_type="cond_mean", plot_res=FALSE)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.