hampel_outlier | R Documentation |
Detect outliers in a rolling window using the Hampel identifier.
hampel_outlier(x, k, threshold = 3.5)
x |
A vector of numbers. |
k |
Width of the rolling window (an odd integer). |
threshold |
Threshold for labeling outliers. For normally distributed data this is equivalent to standard deviations. |
The Hampel identifier uses the median absolute deviation (MAD) and a threshold to identify outliers based on their distance from the median \insertCitedavies_identification_1993atmoschem.process. This is a robust alternative to the commonly used thresholds mean +/-3sd to identify outliers \insertCiteleys_detecting_2013atmoschem.process.
Values are classified as outliers when
|X_i - med(X)| / MAD(X) > threshold
When the MAD is zero this equation is undefined. In this case the function returns FALSE.
A vector of boolean values, TRUE if the value is an outlier.
# test a dataset with an outlier x <- rnorm(20) x[3] <- 10 hampel_outlier(x, 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.