# Median absolute deviation only can be used for anomaly detection for time series without a trend?

I think MAD only can be used to detect anomalies for time series without a trend because it relies only a stable median to detect anomalies. It should be OK for time series with seasonality. Just seek confirmation here. This question is limited to when MAD is used as a standalone algorithm without coupling with other methods for anomaly detection.

Suppose we have a set of observations: $$(x_1,...,x_n)$$
$$Median = median(x_1,...,x_n)$$ $$MAD = median(|x_1- Median|, |x_2- Median|,...,|x_n- Median|)$$

Then we can use $$Median$$ +/- 3*$$MAD$$ as thresholds to detect anomalies.

• Well, Median Absolute Deviation from what? Oct 28, 2020 at 19:07
• @StephanKolassa This post describes MAD: towardsdatascience.com/… Oct 28, 2020 at 19:26
• Thank you. Do you have a source that does not require registration? Also, can you simply answer the question here, so later visitors to this thread do not need to rely on information elsewhere (links may rot)? Oct 28, 2020 at 19:29
• The MAD is conceptually for i.i.d. data, as are other scale functionals such as the standard deviation. It will not take into account time series dependence structure. You mention time series but don't really explain why you want to use MAD for them - it only makes sense (in the given standard form) if you ignore that it's a time series. Oct 28, 2020 at 20:56
• There are several common flavors of MAD, such as median absolute deviation from the mean. Regardless, in any time series not known to be stationary, use of the MAD (or any univariate statistic) to screen for "anomalies" sounds like an inferior strategy because it is more or less likely to confound the non-stationary behavior with anomalous behavior. An appropriate windowed form of a MAD, though, may indeed be useful.
– whuber
Oct 28, 2020 at 21:08