Forecast a Time Series Using an ARIMA Model

DESCRIPTION:
Forecasts a univariate time series using an ARIMA model. Under the assumption that the model is known, predicted values and their standard errors are computed for future values.

USAGE:
arima.forecast(x, model, n, end, sigma2=<<see below>>, xreg=NULL,
               reg.coef=NULL)

REQUIRED ARGUMENTS:
x:
a univariate time series or a vector.
Missing values (NA) are allowed.
model:
a list specifying an ARIMA model as in arima.mle. Note that the coefficients must be provided through the elements ar and ma (otherwise the coefficients are set to zero).

Either end or n must be specified. If both are specified, they must agree.


OPTIONAL ARGUMENTS:
n:
the number of time periods to forecast beyond the end of the series (optional if end is provided).
end:
the last date for which forecasts should be produced. Forecasts will be produced for every time period between end(x) and end.
sigma2:
the estimated innovations variance. If omitted, sigma2 will be the concentrated prediction error variance computed from the model.
xreg:
a univariate or multivariate time series or a vector or matrix with univariate time series per column. These will be used as additive regression variables. xreg must be consistent with the number of time periods forecast: e.g., if n=10 and length(x)=20, then the number of rows of xreg should be 30.
reg.coef:
a vector of regression coefficients corresponding to xreg.

VALUE:
a list with the following elements:
mean:
the estimated mean of the forecasts.
std.err:
the approximate forecast error. In a Gaussian series with known ARIMA model structure, then each row of the matrix tsmatrix(mean-1.96*std.err, mean+1.96*std.err) is a 95% (non-simultaneous) confidence interval for the forecast in that time period. Note that std.err does not take into account the variability due to estimation of the ARIMA model.

DETAILS:
The ARIMA model is put into state space form and the Kalman filter is applied to obtain the forecast intervals. This is done using the function arima.filt.

REFERENCES:
Harvey, A. C. (1981). Time Series Models. Wiley, New York.

SEE ALSO:
arima.mle , arima.filt .

EXAMPLES:
# Fit an ARIMA model to the ship data and forecast one year beyond the end of
# the data.  Plot the series along with forecast means +/- two standard errors
model <- list(list(order=c(0,1,1)),list(order=c(0,1,1),period=12))
ship.fit <- arima.mle(ship,model=model)
ship.fore <- arima.forecast(ship,n=12,model=ship.fit$model)
tsplot(ship,ship.fore$mean,ship.fore$mean+2*ship.fore$std.err,
        ship.fore$mean-2*ship.fore$std.err)