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

Description Usage Arguments Details Value References See Also Examples

View source: R/predictMethod.R

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## 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 '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"?

plot_res

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

mix_weights

TRUE if forecasts for mixing weights should be plotted, FALSE in not.

nt

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

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 [, , m], m=1,..,M.

References

See Also

simulate.gsmar, cond_moments, fitGSMAR, GSMAR, quantile_residual_tests, diagnostic_plot

Examples

 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.

# 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)

uGMAR documentation built on Jan. 24, 2022, 5:10 p.m.