Learn R Programming

tsforecast (version 1.3.0)

predict.tsarima: Predict Time Series Values

Description

The function `predict` is generic and predicts past/future values of a time series.

Usage

# S3 method for tsarima
predict(
  object,
  n.ahead = 1L,
  newxreg = NULL,
  newxreg.est = c("none", "x", "auto.arima"),
  se.fit = TRUE,
  alpha = 0.05,
  log = NULL,
  ...
)

# S3 method for tsesm predict(object, n.ahead = 1L, se.fit = TRUE, alpha = 0.05, ...)

# S3 method for tspredict print(x, ...)

# S3 method for tslm predict(object, n.ahead = 1L, se.fit = TRUE, alpha = 0.05, ...)

Value

An object of class "tspredict".

The function print is used to obtain and print the prediction results, including the predicted values, the corresponding standard errors, as well as the lower and upper limit of the prediction intervals.

An object of class "tspredict" is a list usually containing the following elements:

x.time

list of time in which the series values were observed.

x.timegap

time gap between the series and forecasted values.

x.name

name of the time series for which forecasts was requested.

pred

predicted past values and forecasted future values.

se

standard errors of the forecasted values.

cil, ciu

lower and upper limits of the prediction interval.

n.ahead

number of forecasting periods.

log

logical. Indicates whether series values are log-transformed for model fitting or not. (Only available for class "tsarima")

alpha

significance level.

Arguments

object

a time series or time series model for which prediction is required.

n.ahead

number of forecasting periods. Default is 1.

newxreg

new values of the regressors. Only necessary if ARIMA model is built with independent variables.

newxreg.est

character strings to indicate how the new values of the regressors in an ARIMAX model should be estimated in case they are not yet available. If newxreg is not NULL, this argument will be ignored. Available options are `none`, `x`, and `auto.arima`. The option `none` means that no estimation is needed, and the regressors will have no effect in future forecasts. The option `x` means that the regressors' value will forecasted based on the same model as `x`. The option `auto.arima` means that the regressors' value will forecasted based on the best model found by auto.arima(). Default is `none`.

se.fit

logical. If TRUE, standard error of each prediction will be calculated and included. Default is TRUE.

alpha

significance level. (1 - alpha) indicates is the confidence level of the prediction interval. Default is 0.05.

log

optional. A logical value indicating whether the forecasted values are log-transformed and should be inverted back to the original series scale. If the object is an tsarima model and this parameter is omitted, the value will be taken over by the settings of the model given in object. Default is NULL here.

...

additional arguments affecting the forecasts produced.

x

a `tspredict` object.

Author

Ka Yui Karl Wu

References

Box, G. E. P., & Jenkins, G. M. (1970). Time series analysis: Forecasting and control. Holden-Day.

Hyndman, R. J., & Athanasopoulos, G. (2021). Forecasting: Principles and practice (3rd ed.). OTexts.
https://otexts.com/fpp3/

Examples

Run this code
predict(tsarima(airport$Travellers, order = c(1, 1, 0), 
                seasonal = c(0, 1, 1), log = TRUE, include.const = TRUE),
        n.ahead = 6, alpha = 0.05)

predict(tsesm(airport$Travellers, order = "holt-winters"), 
        n.ahead = 6, alpha = 0.05)

Run the code above in your browser using DataLab