filterrob: Robust Filtering of Time Series Assuming an Autoregressive...

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Robustly filters a given time series assuming an Autoregressive Model. The filtered series can be applied to improve estimations. Optionally, the coefficients of a fitted AR model can be used. See Chapter 8.6 of Maronna et al. (2006) and Dürre et al. (2015) for details.

Usage

1
2
3
4
5
6
filterrob(x, ar, var.pred, method = c("statespace", "recursive"),
          locfn, psi.l = 2, psi.0 = 3, na.action = na.fail, ...)
filterrob.statespace(x, ar, var.pred, locfn, psi.l = 2, psi.0 = 3,
                     na.action = na.fail)
filterrob.recursive(x, ar, var.pred, locfn, psi.l = 2, psi.0 = 3,
                    na.action = na.fail)

Arguments

x

numeric vector of a univariate time series.

ar

numeric vector of AR coefficients. If missing, the AR coefficients are estimated by robust filtering with arrob.filter.

var.pred

numeric value with the innovation variance of the AR model. This argument needs to be provided unless argument ar is missing as well. In that case its value is taken directly from the fitted AR model.

method

character string specifying the method applied for robust filtering. If method = "statespace" (the default), the procedure by Maronna et al. (2006) is used. If method = "recursive", a somewhat simpler procedure is used, see Details.

locfn

function which calculates a location estimator for previously centering the time series. Its argument must be a vector of the data. One could for example use the function median. Ba default the mean estimation of the function scaleTau2 is used.

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.

na.action

function to be called to handle missing values.

...

additional arguments passed to function arrob.filter. This is only applicable if argument ar is missing.

Details

This function filters a time series in order to detect and shrink potential outliers. This filtering is based on the assumption that the time series follows an AR process with Gaussian innovations.

If the model coefficients are known or have been previously estimated, one can provide the vector of AR coefficients by the argument ar. In that case one additionally need to specify the innovation variance by the argument var.pred. An AR model of order zero (assuming independent innovations) could be specified by ar = NULL.

If the coefficients are not provided, then in a first step an AR model is fitted to the data. Estimation is done by the function arrob.filter for which further arguments can be provided by the ... argument. In this case no additional information on the model fit is returned, e.g. the estimated parameters and the innovation variance. It is difficult to assess the quality of this fit. For this reason it is recommended to fit the model by the function arrob in a separate step before calling this function and then providing the estimated coefficients and the estimated innovation variance, see Examples.

Based on the model, residuals are calculated and smoothed by a psi function which is given by the argument psifunc. By default this is M_psi(x, type="smooth"), a smooth function which is the identity for absolute values smaller than 2 and zero for absolute values larger than 3. See link{smoothpsi} and Dürre et al. (2015) for a formal definition of this psi function.

The procedure used for robust filtering can be specified by the argument method and can be one of the following possibilities:

"statespace"

The approach proposed in Chapter 8.6 of Maronna et al. (2006). It employs a state space representation of the model.

"recursive"

A simple strictly recursive approach, where filtering of the observations is only determined by previous but not by successive observations.

Note that this function can be also used to handle missing values. If one replaces missing values with unusually large ones, the algorithm will replace them by best linear predictions.

Value

Named list of the following elements:

filtered

numeric vector with the robustly filtered version of x.

residuals

residuals of the fitted AR model.

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: 10.1002/wics.1351.

Maronna, R. A., Martin, R. D., and Yohai, V. J. (2006): Robust Statistics: Theory and Methods, Wiley, chapter 8, doi: 10.1002/0470010940.

See Also

The function arrob.filter estimates an AR model using the robust filter algorithm.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
set.seed(1066)
tss <- arima.sim(model = list(ar = 0.6), n = 100)
tss[50] <- 100 # extreme outlier in the data

# With previous model fit:
fit <- arrob(tss, method = "filter")
filterrob(tss, ar = fit$ar, var.pred = fit$var.pred, method = "recursive")

# Without previous model fit:
filterrob(tss, method = "statespace")

robts documentation built on May 2, 2019, 4:55 p.m.