wrm.filter | R Documentation |
Filtering procedure based on a weighted version of Siegel's (1982) repeated median (RM) and a moving time window for robust extraction of low frequency components (the signal) in the presence of outliers and shifts. One of several weight functions can be chosen to weight the observations in each time window.
wrm.filter(y, width, weight.type = 1, del = floor(width/2), extrapolate = TRUE)
y |
a numeric vector or (univariate) time series object. |
width |
a positive integer defining the window width used for fitting. |
weight.type |
Indicates the weight function used.
|
del |
a positve integer (smaller than width) specifying the delay of the signal extraction. |
.
extrapolate |
a logical indicating whether the level
estimations should be extrapolated to the edges of the time series. |
For online signal extraction without time delay, weighted repeated median filtering with triangular weights is recommendable in the presence of isolated outliers and abrupt level shifts since it reacts more quickly to shifts than unweighted repeated median filtering and provides higher efficiencies. The window width should be chosen based on a guess of the minimal time period in which the signal can be approximated by a straight line without abrupt shifts. Better results can be obtained by increasing the delay, but often minimization of the time delay itself is one of the objectives so that one prefers del=0. The procedure replaces missing values by simple extrapolations if these are not within the first time window used for initialization.
For "offline" situations, it is intuitive to set del
roughly
equal to width/2
. If the focus is rather on smoothing than on
signal extraction, the Epanechnikov kernel should be used rather than
the triangular kernel. In this case one can also use directly function wrm.smooth
.
wrm.filter
returns an object of class
wrm.filter
. An
object of class wrm.filter
is a list containing the
following components:
y |
the original input time series. |
level |
the corresponding signal level extracted by the filter. |
slope |
the corresponding slope within each time window. |
del |
the parameter specifying the delay of the signal extraction. |
width |
width of the time window. |
weight.type |
name of the weight function used for the fit. |
The function plot
returns a plot
showing the original time series with the filtered output.
Roland Fried and Jochen Einbeck
These filtering procedures are described and investigated in
Fried, R., Einbeck, J., Gather, U. (2007), Weighted Repeated Median Smoothing and Filtering,
Journal of the American Statistical Association 102, 1300-1308.
Preliminary version available as technical report from https://eldorado.tu-dortmund.de/handle/2003/21637
dw.filter
, hybrid.filter
, wrm.smooth
data(Nile)
nile <- as.numeric(Nile)
obj <- wrm.filter(nile, width=11)
plot(obj)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.