hampel: Hampel test for outliers

Description Usage Arguments Value Examples

Description

Applies a Hampel filter to a vector to detect outliers. An value is defined as an outlier if it is beyond sigma median absolute deviations (MAD) from the vector median.

Usage

1
hampel(v, sigma = 4, na.rm = TRUE)

Arguments

v

numerical vector

sigma

+/- MAD values for the normal range

na.rm

Boolean, whether to remove NA values from median and mad calculations

Value

A vector of numerical values. 0 denotes a normal value, -1 is an outlier below the threshold, 1 is an outlier above the threshold.

Examples

1
2
3
vals <- sample(c(rnorm(1000), rnorm(10, 10), rnorm(10, -5)))
is_outlier <- hampel(vals)
plot(vals, col = as.factor(is_outlier), pch = 20)

Swarchal/focus documentation built on May 9, 2019, 3:25 p.m.