
Rolling-median outlier detection for a time series
Source:R/anomaly_native.R
morie_joseph_ts_outlier_detection.RdA centred rolling median and MAD; the score is the robust z-score \(|y - med| / (1.4826\,MAD)\). Using the median rather than the mean is what keeps trend and seasonality from firing the detector.
Details
The documented failure: a RUN of consecutive outliers longer than half the window becomes the local median itself and is declared normal. The window has to be wider than the longest run one expects to catch.