Fit an autoregressive time series model to the data by ordinary least squares, by default selecting the complexity by AIC.
1 2 
x 
A univariate or multivariate time series. 
aic 
Logical flag. If 
order.max 
Maximum order (or order) of model to fit. Defaults to 10*log10(N) where N is the number of observations. 
na.action 
function to be called to handle missing values. 
demean 
should the AR model be for 
intercept 
should a separate intercept term be fitted? 
series 
names for the series. Defaults to

... 
further arguments to be passed to or from methods. 
ar.ols
fits the general AR model to a possibly nonstationary
and/or multivariate system of series x
. The resulting
unconstrained least squares estimates are consistent, even if
some of the series are nonstationary and/or cointegrated.
For definiteness, note that the AR coefficients have the sign in
(x[t]  m) = a[0] + a[1]*(x[t1]  m) + … + a[p]*(x[tp]  m) + e[t]
where a[0] is zero unless intercept
is true, and
m is the sample mean if demean
is true, zero
otherwise.
Order selection is done by AIC if aic
is true. This is
problematic, as ar.ols
does not perform
true maximum likelihood estimation. The AIC is computed as if
the variance estimate (computed from the variance matrix of the
residuals) were the MLE, omitting the determinant term from the
likelihood. Note that this is not the same as the Gaussian
likelihood evaluated at the estimated parameter values.
Some care is needed if intercept
is true and demean
is
false. Only use this is the series are roughly centred on
zero. Otherwise the computations may be inaccurate or fail entirely.
A list of class "ar"
with the following elements:
order 
The order of the fitted model. This is chosen by
minimizing the AIC if 
ar 
Estimated autoregression coefficients for the fitted model. 
var.pred 
The prediction variance: an estimate of the portion of the variance of the time series that is not explained by the autoregressive model. 
x.mean 
The estimated mean (or zero if 
x.intercept 
The intercept in the model for

aic 
The differences in AIC between each model and the
bestfitting model. Note that the latter can have an AIC of 
n.used 
The number of observations in the time series. 
order.max 
The value of the 
partialacf 

resid 
residuals from the fitted model, conditioning on the
first 
method 
The character string 
series 
The name(s) of the time series. 
frequency 
The frequency of the time series. 
call 
The matched call. 
asy.se.coef 
The asymptotictheory standard errors of the coefficient estimates. 
Adrian Trapletti, Brian Ripley.
Luetkepohl, H. (1991): Introduction to Multiple Time Series Analysis. Springer Verlag, NY, pp. 368–370.
ar
1 2 3 4 5 6 7 8 
Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
Please suggest features or report bugs with the GitHub issue tracker.
All documentation is copyright its authors; we didn't write any of that.