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, ...)
x |
Can be:
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.
|
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. |
The function ar is a wrapper for the functions ar.yw, ar.burg, ar.mle and ar.ols. Only the first of those is currently implemented.
The estimation is performed using the sample mean of each univariate series as the estimate of the mean. Remember that the coefficients in ar are for the series with the mean(s) removed if demean is TRUE.
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. |
pred | a time series of prediction. |
se | a time series of estimated standard errors. |
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)))