adore.filter | R Documentation |
Procedure for robust online extraction of low frequency components (the signal) from a univariate time series by a moving window technique with adaptive window width selection (ADaptive Online REpeated median FILTER).
adore.filter(y,
p.test=15, minNonNAs=5,
min.width=10, max.width=200,
width.search="geometric",
rtr=2, extrapolate=FALSE,
calc.qn=FALSE, sign.level=0.1)
y |
a numeric vector or (univariate) time series object. |
p.test |
defines the number of most recent Repeated Median residuals within each window used to test the goodness of fit of the online signal level. |
minNonNAs |
a positive integer |
min.width |
a positive integer |
max.width |
a positive integer |
width.search |
a character string defining the search algorithm used for finding an adequate window width at each point in time.
|
rtr |
a value in 0, 1, 2 specifying whether a 'restrict to range' rule should be applied.
|
extrapolate |
a logical indicating whether the level estimations should be extrapolated to the beginning of the time series. The extrapolation consists of all fitted values within the first time window. |
calc.qn |
a logical indicating whether the Qn scale (Rousseeuw, Croux, 1993) should also be calculated along with the signal level
as an estimate of the standard deviation in each window.
Here, the |
sign.level |
significance level of the test procedure; must be a value in |
The adore.filter
works by applying Repeated Median (RM)
regression (Siegel, 1982) to a moving time window with a length varying between
min.width
and max.width
.
For each point in time, the window width is adapted to the current data situation by a goodness of fit test for
the most recent signal level estimation.
The test uses the absolute value of the sum of the RM residuals in the subset specified by p.test
.
The critical value for the test decision corresponds to a slightly modified 0.95-quantile of the
distribution of the test statistic and is stored in the data set critvals
.
A more detailed description of the filter can be found in Schettlinger, Fried, Gather (2010).
adore.filter
returns an object of class adore.filter
.
An object of class adore.filter
is a list containing the
following components:
level |
a numeric vector containing the signal level extracted by the RM filter with adaptive window width. |
slope |
a numeric vector containing the corresponding slope within each time window. |
width |
a numeric vector containing the corresponding window width used for the level and slope estimations. |
level.list |
a list which contains with as many elements as the length of the input time series.
If at time |
slope.list |
a list containing the slope estimations corresponding to the values in |
width.list |
a list containing the window widths used for the estimations in |
sigma |
a numeric vector containing the corresponding scale within each time window estimated by the robust Qn estimator
(only calculated if |
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 min.width
, max.width
, width.search
,
p.test
, minNonNAs
, rtr
, extrapolate
, and calc.qn
.
Application of the function plot
to an object of class
aoRM
returns a plot showing the original time series
with the filtered output.
Karen Schettlinger
Rousseeuw, P. J., Croux, C. (1993) Alternatives to the Median Absolute Deviation, Journal of the American Statistical Association 88, 1273-1283.
Schettlinger, K., Fried, R., Gather, U. (2010)
Real Time Signal Processing by Adaptive Repeated Median Filters,
International Journal of Adaptive Control and Signal Processing 24(5), 346-362.
Siegel, A.F. (1982)
Robust Regression Using Repeated Medians,
Biometrika 69 (1),
242-244.
robreg.filter
, wrm.filter
, madore.filter
, scarm.filter
.
# # # # # # # # # #
# Short and noise-free time series
series <- c(rep(0,30),rep(10,30),seq(10,5,length=20),seq(5,15,length=20))
# Adaptive online signal extraction without & with 'restrict to range' rule
t.without.rtr <- adore.filter(series, rtr=0)
plot(t.without.rtr)
t.with.rtr1 <- adore.filter(series, rtr=1)
lines(t.with.rtr1$level, col="blue")
t.with.rtr2 <- adore.filter(series)
lines(t.with.rtr2$level, col="green3",lty=2)
legend("top",c("Signal with rtr=1","Signal with rtr=2"),col=c("blue","green3"),lty=c(1,2),bty="n")
# # # # # # # # # #
# Short and noise-free time series + 1 outlier
ol.series <- series
ol.series[63] <- 3
# Adaptive online signal extraction without & with 'restrict to range' rule
t.without.rtr <- adore.filter(ol.series, rtr=0)
plot(t.without.rtr)
t.with.rtr1 <- adore.filter(ol.series, rtr=1)
lines(t.with.rtr1$level, col="blue")
t.with.rtr2 <- adore.filter(ol.series)
lines(t.with.rtr2$level, col="green3",lty=2)
legend("top",c("Signal with rtr=1","Signal with rtr=2"),col=c("blue","green3"),lty=c(1,2),bty="n")
# # # # # # # # # #
# Noisy time series with level shifts, trend changes and shifts in the scale of the error term
true.signal <- c(rep(0,150),rep(10,150),seq(10,5,length=100),seq(5,15,length=100))
series2 <- true.signal + c(rnorm(250,sd=1), rnorm(200,sd=3), rnorm(50,sd=1))
# Adaptive online signal extraction with additional Qn scale estimation
s2 <- adore.filter(series2, calc.qn=TRUE)
par(mfrow=c(3,1))
plot(s2)
plot(s2$sigma,type="l",main="Corresponding Qn Scale Estimation",ylab="sigma",xlab="time")
lines(c(rep(1,250),rep(3,200),rep(1,150)),col="grey")
legend("topleft",c("True scale","Qn"),lty=c(1,1),col=c("grey","black"),bty="n")
plot(s2$width,type="l",main="Corresponding Window Width",ylab="width",xlab="time")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.