hampel | R Documentation |
Smoothes a series by removing outliers. Outliers are detected by being more than a standard deviations from the median absolute deviation. Non-outliers aren't affected. The a parameter scales the standard deviations to have the CDF of a normal distribution.
hampel(x, window_size, a = 3, k = 1.4826, recentre = TRUE, miss = "single")
x |
Input time-series as a vector. |
window_size |
Window size as an integer |
a |
Threshold number of standard deviations from the median absolute deviation to classify outliers as. |
k |
Tuning parameter to convert standard deviations to a normal CDF. |
recentre |
Whether to recentre the window around the middle point in the window so as to avoid adding lag. I.e. for an odd window_length y[i] = mean(x[(i - floor(window_length/2)) : (i + floor(window_length/2))]) For an even window length the output is located more closely to earlier points, i.e. y[i] = mean(x[(i - window_length/2 + 1) : (i + window_length/2)]) |
miss |
How to handle missing values. 'single' only returns NA for y[i] if x[i] = NA. 'all' returns NA for y[i] if any value in the window is missing, and 'none' omits NAs from the window, so will only return NA for y[i] if all windowed values are also NA. |
A filtered time-series the same length as x.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.