A robust smoothing tool using a kernel weighted version of Siegel's (1982) repeated median. It can be seen as an alternative to local linear L1 regression.
wrm.smooth(x, y, h, xgrid, weight = 2)
wrm.smooth
returns an object of class
wrm.smooth
. An
object of class wrm.smooth
is a list containing the
following components:
the original input time series.
the corresponding signal level extraceted by the weighted Repeated Median filter.
the corresponding WRM slope within each time window.
bandwidth.
vector with grid values.
name of the weight function used for the fit.
The function plot
returns a plot
showing the original data with the smoothed output.
Vector of predictors.
Vector of responses, needs to have the same length as x
.
Bandwidth, measured in the same units as the explanatory (independent) variable x:
(x[0]-h
,x[0]+h
) is the range of x-values to be included in the local smoothing at x[0]. Needs to be a positive number.
Grid on which fitted values are to be evaluated. The default is here to take the input
values x
for a sample size of at most 100, and seq(min(x),max(x), l=100)
otherwise.
Indicates the weight function used.
weight=1
triangular weights
weight=2
Epanechnikov weights (default)
weight=3
Gaussian weights
weight=4
Biweight
weight=5
Uniform weights
Jochen Einbeck and Roland Fried
Weighted repeated median (WRM) smoothing was suggested in a signal extraction framework by Fried, Einbeck & Gather (2007). It combines the advantages of weighted and repeated medians, i.e. the WRM smoother is robust to outliers and adapts to linear trends (through the slope parameter of the repeated median, which is calculated by applying two consecutive weighted medians onto the pairwise slopes). The theory and simulations provided by Fried, Einbeck & Gather focus on online signal extraction from time series. Warning: The case of a kernel weighted repeated median smoother for arbitraty non-equidistant design (as implemented here) is not fully investigated yet.
The procedure copes with missing values by omitting them.
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
Siegel, A.F. (1982). Robust regression using repeated medians. Biometrika 68, 242-244.
wrm.filter
data(faithful) # Old Faithful Geyser data
faith.WRM <- wrm.smooth(faithful$w, faithful$e,h=4)
plot(faith.WRM)
Run the code above in your browser using DataLab