Learn R Programming

pracma (version 0.7.5)

hampel: Hampel Filter

Description

Median absolute deviation (MAD) outlier in Time Series

Usage

hampel(x, k)

Arguments

x
numeric vector representing a time series
k
window length 2*k+1 in indices

Value

  • Returning a list L with L$y the corrected time series and L$ind the indices of outliers in the `median absolut deviation' sense.

Details

The `median absolute deviation' computation is done in the [-k...k] vicinity of each point at least k steps away from the end points of the interval.

References

Pearson, R. K. (1999). ``Data cleaning for dynamic modeling and control''. European Control Conference, ETH Zurich, Switzerland.

See Also

findpeaks

Examples

Run this code
set.seed(8421)
x <- numeric(1024)
z <- rnorm(1024)
x[1] <- z[1]
for (i in 2:1024) {
	x[i] <- 0.4*x[i-1] + 0.8*x[i-1]*z[i-1] + z[i]
}
omad <- hampel(x, k=20)

plot(1:1024, x, type="l")
points(omad$ind, x[omad$ind], pch=21, col="darkred")

Run the code above in your browser using DataLab