robfilter (version 3.0)

robust.filter: Robust Filtering Methods for Univariate Time Series

Description

Procedure for robust (online) extraction of low frequency components (the signal) from a univariate time series with optional rules for outlier replacement and shift detection.

Usage

robust.filter(y, width, trend = "RM", scale = "QN", outlier = "T", 
                        shiftd = 2, wshift = floor(width/2), lbound = 0.1, p = 0.9,
                        adapt = 0, max.width = width, 
                        online = FALSE, extrapolate = TRUE)

Arguments

Value

robust.filter returns an object of class robust.filter. An object of class robust.filter is a list containing the following components:levela numeric vector containing the signal level extracted by the (regression) filter specified by trend, scale and outlier.slopea numeric vector containing the corresponding slope within each time window.sigmaa numeric vector containing the corresponding scale within each time window.olan outlier indicator. 0: no outlier, +1: positive outlier, -1: negative outlierlevel.shifta level shift indicator. 0: no level shift, t: positive level shift detected at processing time t, -t: negative level shift detected at processing time t (the position in the vector gives an estimate of the point in time before which the shift has occurred).In addition, the original input time series is returned as list member y, and the settings used for the analysis are returned as the list members width, trend, scale, outlier, shiftd, wshift, lbound, p, adapt, max.width, online and extrapolate. Application of the function plot to an object of class robust.filter returns a plot showing the original time series with the filtered output.

Details

robust.filter works by applying the methods specified by trend and scale to a moving time window of length width. Before moving the time window, it is checked whether the next (incoming) observation is considered an 'outlier' by applying the rule specified by outlier. Therefore, the trend in the current time window is extrapolated to the next point in time and the residual of the incoming observation is standardised by the current scale estimate. After moving the time window, it can be tested whether a level shift has occurred within the window: If more than half of the residuals in the right part of the window are larger than shiftd$\cdot\sigma_t$, a shift is detected and appropriate actions are taken. In the online mode, the number of the rightmost residuals can be chosen by wshift to regulate the resistance of the detection rule against outliers, its power and the time delay of detection. A more detailed description of the filter can be found in Fried (2004). The adaption of the window width is described by Gather and Fried (2004). For more explanations on shift detection, see Fried and Gather (2007).

References

Fried, R. (2004), Robust Filtering of Time Series with Trends, Journal of Nonparametric Statistics 16, 313-328. (earlier version: http://www.sfb475.uni-dortmund.de/berichte/tr30-03.ps) Fried, R., Gather, U. (2007), On Rank Tests for Shift Detection in Time Series, Computational Statistics and Data Analysis, Special Issue on Machine Learning and Robust Data Mining 52, 221-233. (earlier version: http://www.sfb475.uni-dortmund.de/berichte/tr48-06.pdf) Gather, U., Fried, R. (2004), Methods and Algorithms for Robust Filtering, COMPSTAT 2004: Proceedings in Computational Statistics, J. Antoch (eds.), Physika-Verlag, Heidelberg, 159-170. Schettlinger, K., Fried, R., Gather, U. (2006) Robust Filters for Intensive Care Monitoring: Beyond the Running Median, Biomedizinische Technik 51(2), 49-56.

See Also

robreg.filter, hybrid.filter, dw.filter, wrm.filter.

Examples

Run this code
# Generate random time series:
y <- cumsum(runif(500)) - .5*(1:500)
# Add jumps:
y[200:500] <- y[200:500] + 5
y[400:500] <- y[400:500] - 7
# Add noise:
n <- sample(1:500, 30)
y[n] <- y[n] + rnorm(30)

# Delayed Filtering of the time series with window width 23:
y.rf <- robust.filter(y, width=23)
# Plot:
plot(y.rf)

# Delayed Filtering with different settings and fixed window width 31:
y.rf2 <- robust.filter(y, width=31, trend="LMS", scale="QN", outlier="W")
plot(y.rf2)

# Online Filtering with fixed window width 24:
y.rf3 <- robust.filter(y, width=24, online=TRUE)
plot(y.rf3)

# Delayed Filtering with adaptive window width (minimal width 11, maximal width 51):
y.rf4 <- robust.filter(y, width=11, adapt=0.7, max.width=51)
plot(y.rf4)

Run the code above in your browser using DataLab