anomaly_hampel: Hampel Filter

Description Usage Arguments Value Examples

View source: R/anomaly.r

Description

Anomaly detection using a Hampel filter, i.e., MAD outlier detection over a moving window.

Usage

1
anomaly_hampel(x, mask = !is.na(x), size = c(5L, 5L), ...)

Arguments

x

A vector of data.

mask

A logical vector that defines which values in x will used when computing statistics. Useful when a subset of quality-assured data is available. Default mask is non-NA Values.

size

A two-element integer vector specifying the number of points before and after the current data point to include in the moving window. Default is c(5L, 5L), i.e., an 11-element centered moving window.

...

Additional arguments to pass to outlier_mad().

Value

A vector of flags or scores.

Examples

1
2
3
4
5
6
x = seq(0, 34, by = 0.25)*pi
noise = rnorm(length(x), mean = 1, sd = 3)
y = sin(x) + noise
mask = noise < 1

anomaly_hampel(y, mask)

mkoohafkan/wqptools documentation built on May 2, 2021, 8:12 p.m.