Apply an ARIMA Filter to a Time Series

DESCRIPTION:
Computes the one-step predictions and filtered values and their variances for an ARIMA model applied to a univariate time series. The log-likelihood is also computed. This function is primarily used by the S-PLUS functions arima.diag and arima.forecast.

USAGE:
arima.filt(x, model, n.cond=<<see below>>, xreg=NULL, reg.coef=NULL)

REQUIRED ARGUMENTS:
x:
a univariate time series or a vector. Missing values (NAs) 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).

OPTIONAL ARGUMENTS:
n.cond:
the number of observations to condition the likelihood on. n.cond must be at least P+D (the default), where P and D are the orders of the expanded autoregressive and differencing polynomials.
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.
reg.coef:
a vector of regression coefficients corresponding to xreg.

VALUE:
a list with the following elements:
loglik:
-2 times the log likelihood of the model (up to a constant factor).
aic:
Akaike's information criteria, which is loglik plus 2 times the number of parameters fit.
sigma2:
the estimated innovations variance.
n.used:
the number of observations used to compute the likelihood.
n.cond:
the number of observations on which the likelihood is conditioned.
pred:
the one-step ahead predictions of the data.
var.pred:
the variance of the one-step ahead predictions of the data.
filt:
the filtered values of the data. If no missing values are present, then filt is the same as x.
var.filt:
vector giving the variance of each filtered value. If no missing values are present, then var.filt is 0 except possibly at the beginning where there may be NAs.

DETAILS:
The ARIMA model is put into state space form and the Kalman filter is applied to obtain the predicted and filtered values. No predicted or filtered values are produced for the first P+D observations, where P and D are the orders of the expanded autoregressive and differencing polynomials.

In particular, the state space form implies that the filtering is more complex than might be expected. For example in an MA(1) model, the predicted value is not merely the moving average coefficient times the last residual, see Harvey (1981, page 112).


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

The chapter "Analyzing Time Series" of the S-PLUS Guide to Statistical and Mathematical Analysis.


SEE ALSO:
arima.diag , arima.forecast , arima.mle .

EXAMPLES:
# Append missing values to the end of the ship data and
# use arima.filt to produce forecast values.
# Note: this could be done more directly using arima.forecast.
model <- list(list(order=c(0,1,1)),list(order=c(0,1,1),period=12))
fit <- arima.mle(ship,model=model)
ship.fore <- ts(c(ship,rep(NA,12)),start=start(ship),frequency=frequency(ship))
forecast <- arima.filt(ship.fore,model=fit$model)$pred