ar
Fit Autoregressive Models to Time Series

Description

Fits autoregressive models to time series.

Usage

ar(x, aic = TRUE, order.max = NULL, method = c("yule-walker",
    "burg", "ols", "mle", "yw"), na.action = na.fail, series = deparse(substitute(x)), ...)
ar.yw(x, aic = TRUE, order.max = NULL, na.action = na.fail,
     demean = TRUE, series = NULL, ...)
## S3 method for class 'ar':
print(x, digits = max(3, getOption("digits") - 3), ...)
## S3 method for class 'ar':
predict(object, newdata, n.ahead = 1, se.fit = TRUE, ...)

Arguments

x Can be:
  • a univariate or multivariate time series inheriting from class "ts".
  • a vector.
  • a matrix with columns representing univariate components of a multivariate time series.
The latter types are converted to a "ts" object by as.ts(x).

In print.ar method, x is an object of class "ar".

aic a logical flag. if TRUE (the default), use the Akaike information criterion to choose the best order not greater than order.max. If FALSE, order.max is the order of the fitted model.
order.max the maximum order of autoregression to fit to the time series.
  • In ar.yw.default, the default value is the smaller one of N-1 and the floor of 10 * log10(N).
  • In ar.yw.mts, the default value is the floor of 10 * log10(N).
In the above cases, N is the number of the observations.
method this argument is currently ignored. Only the Yule-Walker method is implemented.
na.action a function that handles missing values. See na.action for details. For na.action = na.omit, NAs are allowed only at the beginning or end of time series.
series a character string specifying the name of time series. The default is deparse(substitute(x)).
demean a logical value. If TRUE (the default), the column means are subtracted before fitting the model.
var.method this argument is ignored.
digits the number of significant digits to print.
object an object of class "ar".
newdata data at which predictions are required. This argument can be missing, in which case predictions are made at the same values used to compute the object.
n.ahead an integer (must be at least 1) specifying the number of predictions ahead to make.
se.fit a logical value. If TRUE (the default), the standard errors of the predictions are returned along with the predictions. For multivariate models, these are always NA.
... other optional arguments pass to or from methods.

Details

Value
ar and its methods ar.* returns a list of class "ar" with the following components:

order The order of the autoregression fitted. If aic=TRUE, then this is the order less than or equal to order.max which minimizes the AIC, otherwise, it is order.max.
ar The autoregressive coefficients. These are in an order by "nser" by "nser" array. where "nser" is the number of univariate components of x.

If order is 0, ar will have dimensions 0 by "nser" by "nser" and will be filled with zeros. The first level of the first dimension corresponds to one observation back in time, the second level corresponds to two observations back, etc. The second dimension corresponds to the predicted series, and the third corresponds to the predicting series.

var.pred The estimated prediction variance ("nser" by "nser" matrix) of the process with AR coefficients ar.
x.mean The estimated column means of the time series used for fitting.
aic A vector of the values of the Akaike information criterion for orders 0 through order.max. These have the minimum value subtracted from all of them so the minimum is always zero.
n.used The length of the nonmissing part(observations) of the input time series.
order.max The input or default value of order.max.
partialacf A vector of the partial autocorrelation coefficients, useful for choosing the proper order of the autoregression.
resid a time series representing the estimate of residuals for the model. The estimates contained in ar are used in the forward direction on the series with mean(s) removed.
method A character string representing the method used to fit.
series The names used for the input x. It includes transformations.
frequency The frequency of the time series.
call The matched call.
asy.var.coef The current code returns NAs for this. It should contain the asymptotic-theory variance matrix of the coefficient.
print.ar returns invisible "ar" object x itself.
predict.ar returns a time series of prediction, or if se.fit is TRUE, a list of object with two time series component:
pred a time series of prediction.
se a time series of estimated standard errors.
References
Brockwell, P. J. and Davis, R. A. 1996. Introduction to Time Series and Forecasting. New York, NY: Springer. Sections 5.1 and 7.6.
Brockwell, P. J. and Davis, R. A. 1991. Time Series and Forecasting Methods. Second Edition. New York, NY: Springer Section 11.4.
Burg, J. P. 1967. Maximum entropy spectral analysis. Paper presented at the 37th Annual International S.E.G. Meeting, Oklahoma City, OK Tulsa, OK: Society of Exploration Geophysicists.
Percival, D. P. and Walden, A. T. 1998. Spectral Analysis for Physical Applications. Cambridge, UK: Cambridge University Press.
Whittle, P. 1963. On the fitting of multivariate autoregressions and the approximate canonical factorization of a spectral density matrix. Biometrika. Volume 40. 129-134.
Whittle, P. 1983. Prediction and Regulation by Linear Least-Squares Methods. Second Edition. Minneapolis, MN: University of Minnesota Press.
Statistical Sciences. 1995. Analyzing time series. S-PLUS Guide to Statistical and Mathematical Analysis. Version 3. Seattle, WA: StatSci.
See Also
acf, filter.
Examples
a <- ar(log(Sdatasets::lynx))   # "yule-walker" method
predict(a, n.ahead = 5)

# multivariate time series. a2 <- ar(ts.intersect(Sdatasets::co2, sqrt(Sdatasets::sunspots)))

Package stats version 6.1.1-7
Package Index