Learn R Programming

gmvarkit (version 1.1.1)

predict.gmvar: Predict method for class 'gmvar' objects

Description

Forecast GMVAR process defined by object of class 'gmvar'. Forecasts are computed by performing independent simulations and using the sample means or medians as predictions and empirical quantiles as prediction intervals. For one-step-ahead predictions using the exact conditional mean is also supported.

Usage

# S3 method for gmvar
predict(object, ..., n_ahead, n_simu = 2000,
  pi = c(0.95, 0.8), pi_type = c("two-sided", "upper", "lower",
  "none"), pred_type = c("median", "mean", "cond_mean"),
  plot_res = TRUE, nt)

Arguments

object

object of class 'gmvar', generated by function fitGMVAR or GMVAR.

...

additional arguments passed to grid (ignored if plot_res==FALSE) which plots grid to the figure.

n_ahead

how many steps ahead should be predicted?

n_simu

to how many simulations should the forecast be based on?

pi

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

pi_type

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

pred_type

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

plot_res

should the results be plotted?

nt

a positive integer specifying the number of observations to be plotted along with the prediction (ignored if plot_res==FALSE). Default is round(nrow(data)*0.2).

Value

Returns an object of class 'gmvarpred' which contains the predictions and the prediction intervals. It has it's own print and plot methods print.gmvarped and plot.gmvarped.

References

  • Kalliovirta L., Meitz M. and Saikkonen P. 2016. Gaussian mixture vector autoregression. Journal of Econometrics, 192, 485-498.

Examples

Run this code
# NOT RUN {
## These are long running examples that use parallel computing!

# These examples use the data 'eurusd' which comes with the
# package, but in a scaled form.
data <- cbind(10*eurusd[,1], 100*eurusd[,2])
colnames(data) <- colnames(eurusd)

# GMVAR(2,2) model
fit22 <- fitGMVAR(data, p=2, M=2)
p1 <- predict(fit22, n_ahead=20, pred_type="median")
p1
p2 <- predict(fit22, n_ahead=10, nt=20, lty=1)
p2
p3 <- predict(fit22, n_ahead=10, pi=c(0.99, 0.90, 0.80, 0.70),
              nt=30, lty=0)
p3

# GMVAR(1,2) model
fit12 <- fitGMVAR(data, p=1, M=2)
p1 <- predict(fit12, n_ahead=1, pred_type="cond_mean",
              plot_res=FALSE)
p1
p2 <- predict(fit12, n_ahead=10, pred_type="mean")
p2
p3 <- predict(fit12, n_ahead=10, pi_type="upper")
p3
# }

Run the code above in your browser using DataLab