hybrid.filter: Robust Hybrid Filtering Methods for Univariate Time Series

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


Procedures for robust extraction of low frequency components (the signal) from a univariate time series based on a moving window technique using the median of several one-sided half-window estimates (subfilters) in each step.


hybrid.filter(y, width, method = "all", minNonNAs=3, extrapolate = TRUE)



a numeric vector or (univariate) time series object.


an odd positive integer (>=3) defining the window width used for fitting.


a (vector of) character string(s) containing the method(s) to be used for the estimation of the signal level.
It is possible to specify any combination of "MED", "RM", "MEAN", FMH, "PFMH", "CFMH", "MH", "PRMH", "CRMH", "MMH", "PRMMH", "CRMMH", and "all" (for all of the above). Default is method="all". For a detailed description see the section ‘Methods’ below.


a positive integer defining the minimum number of non-missing observations within each window (half) which is required for a ‘sensible’ estimation. Default: if a window (half) contains less than minNonNAs = 3 observations an NA is returned (for that subfilter).


a logical indicating whether the level estimations should be extrapolated to the edges of the time series. The extrapolation extends the first estimated value to the first time in the first window and the last estimated value to the last time in the last time window. Default is extrapolate=TRUE.


hybrid.filter is suitable for extracting low frequency components (the signal) from a time series which may be contaminated with outliers and can contain level shifts or local extremes. For this, moving window techniques are applied.

Within each time window several subfilters are applied to half-windows (left and right of the centre); the final signal level in the centre of the time window is then estimated by the median of the subfilter outputs.

For the subfilters, both, location-based and regression-based method are available, the former applying means or medians and the idea of a locally constant signal value, the latter using ordinary least squares (LS) regression or Siegel's (1982) repeated median (RM) and the idea of an underlying locally linear trend.

The methods should be chosen based on an a-priori guess of the underlying signal and the data quality. Location based methods (MED, MEAN, FMH, MH, MMH) are recommended in case of a locally (piecewise) constant signal. Regression based and predictive approaches (RM, PFMH, PRMH, PRMMH) in case of locally linear monotone trends. The combined filters (CFMH, CRMH, CRMMH) can be seen as a compromise, but are computationally somewhat more expensive and may be inferior to the predictive filters during steep trends.

The approaches based on the median and RM are robust alternatives to the (in Gaussian samples) more efficient mean and least squares methods. The hybrid filters preserve shifts and local extremes much better than MED, MEAN or RM for the price of decreased robustness and / or Gaussian efficiency.


hybrid.filter returns an object of class hybrid.filter. An object of class hybrid.filter is a list containing the following components:


a data frame containing the signal level extracted by the filter(s) specified in method.


a data frame (possibly) containing RM, RM.left, RM.right, LS.left and LS.right: the slope estimated by Repeated Median regression in the whole window (for method="RM") or in the left and right window half (for any method in "PRMH", "CRMH", "PRMMH" and "CRMMH") or the least squares slope estimated from the left and right window half (for any method in "PRFMH" or "CFMH").
Only those slopes are returned which are required by the filters specified in method. If only location-based filters are applied (i.e. "MED", "MEAN", "FMH", "MH" and /or "MMH") NULL is returned for the slope.

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, method and extrapolate.

Application of the function plot to an object of class hybrid.filter returns a plot showing the original time series with the filtered output.


The following methods are available as method for signal extraction.

Filters applying only one location or regression estimate to the whole window of length width and taking the location (in the centre of the time window) as final signal level estimate:


ordinary running median filter.


ordinary moving average filter.


ordinary repeated median filter.
Applies repeated median regression to each time window.

Filters applying several subfilters within one window, taking the median of the values listed below as the final signal level estimate:


FIR median hybrid filter.
Uses half-window averages and the central observation.


predictive FMH filter.
Uses half-window least squares regression and the central observation.


combined FMH filter.
Uses half-window averages, half-window least squares regression, and the central observation.


median hybrid filter.
Uses half-window medians and the central observation.


predictive repeated median hybrid filter.
Uses half-window repeated median regression and the central observation.


combined repeated median hybrid filter.
Uses half-window medians, half-window repeated median regression, and the central observation.


median/median hybrid filter.
Uses half-window medians and the median of all observations in the window.


predictive repeated median/median filter.
Uses half-window repeated median regression and the median of all observations in the window.


combined repeated median/median filter.
Uses half-window medians, half-window repeated median regression, and the median of all observations in the window.


Missing values are treated by omitting them and thus by reducing the corresponding window width.
The hybrid.filter function only offers filters for signal extraction delayed by (width+1)/2 time units, in contrast to other filters available from the robfilter package which also offer online time series analysis without time delay.


Roland Fried and Karen Schettlinger


Fried, R., Bernholt, T., Gather, U. (2006) Repeated Median and Hybrid Filters, Computational Statistics \& Data Analysis 50, 2313-2338.
(earlier version: http://www.sfb475.uni-dortmund.de/berichte/tr10-04.ps)

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, robust.filter, dw.filter, wrm.filter.


# 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)
# Filtering with all methods:
y.hy <- hybrid.filter(y, width=31)
# Plot:

# Filtering with running median and PRMH only:
y2.hy <- hybrid.filter(y, width=31, method=c("MED","PRMH"))

Example output

Loading required package: robustbase
Loading required package: MASS
Loading required package: lattice

robfilter documentation built on May 2, 2019, 11:10 a.m.