# ARfilter: Robust Fitting of Autoregressive Models by Robust Filtering In robts: Robust Time Series Analysis

## Description

Robustly fits AR models using a robust filter algorithm. See Dürre et al. (2015) for details.

This is a workhorse function which is called by several other functions in this package.

## Usage

 `1` ```ARfilter(x, order.max, aicpenalty = function(p) {2*p}, psi.l = 2, psi.0 = 3) ```

## Arguments

 `x` univariate numeric vector or time series object. `order.max` integer value determining the maximum order of the AR fit. `psi.l` numeric value determining the psi function used for filtering, see `link{smoothpsi}`. For absolute values lower than `psi.l` the psi function is linear. `psi.0` numeric value determining the psi function used for filtering, see `link{smoothpsi}`. For absolute values larger than `psi.0` the psi function is zero. `aicpenalty` function of the model order, indicating the penalty for a larger model. See Details.

## Details

The function fits AR models of increasing order by a robust version of the Durbin Levinson algorithm as described in Chapter 8 of Maronna et al. (2006). The AR coefficients are estimated by minimizing a robust scale (`scaleTau2`) of one step ahead residuals of robustly filtered predictors. The filter process basically compares the predicted value under the estimated model with the observed one and transforms the corresponding residual with the psi function. The transformed value is then set to the sum of the predicted value and the transformed residual. For more details see Maronna et al. (2006) and Dürre et al. (2015).

Following Maronna et al. (2006), the psi function should fulfill two properties. It should be the identity for small absolute values and zero for large absolute values. Both thresholds can be determined by `psi.l` and `psi.0`. Here the psi function is chosen to be two times continuous differentiable, see `link{smoothpsi}` and Dürre et al. (2015) for a formal definition.

## Value

List containing the following values:

 `pacf` numeric vector representing the successively estimated partial correlations of the model at lags 1,...,`p`. `var` numeric vector containing the estimations of the residual scale for AR models of order 0,...,`p`. `acf` numeric vector of estimated autocorrelations of a model of order `order.max` at lags 1,...,`p`. `aic` numeric vector of AIC values of AR models of order 0,...,`p`. `filtered` numeric matrix containing the robustly filtered time series of AR models of different orders. The first column corresponds to the AR(0) model, the second to the AR(1) model and so on. `ar` list containing the estimated AR coefficients of AR models of different orders. The first list element corresponds to the AR(0) model, the second to the AR(1) model and so on.

## Author(s)

Alexander Dürre, Tobias Liboschik and Jonathan Rathjens

## References

Dürre, A., Fried, R. and Liboschik, T. (2015): Robust estimation of (partial) autocorrelation, Wiley Interdisciplinary Reviews: Computational Statistics, vol. 7, 205–222, doi: wics.1351.

Maronna, R., Martin, D. and Yohai, V. (2006): Robust statistics, Wiley, Chichester, doi: 10.1002/0470010940.

`arrob.filter` for robust fitting of AR models and `acfrob.filter` for robust estimation of the autocorrelation function, both based on robust filtering. `filterrob` for robust filtering of time series.
 ```1 2 3``` ```set.seed(1066) tss <- arima.sim(model = list(ar = 0.3, ma = 5), n = 100) ARfilter(tss, order.max = 5) ```