MAD
Description
The MAD function returns the median absolute deviation from the median; like the IQR it is a robust estimator of scale. And like the IQR function, the MAD optionally returns a corrected form instead of the uncorrected value (which is the default).
Syntax
MAD(data, [corrected=FALSE]) where
datais the univariate data (any shape), filtering out non-numeric valuescorrectedis a boolean that determines whether to divide by a correcting factor
The syntax and philosophy are similar to the IQR function: “correction” means dividing by the MAD of the standard normal distribution (which is also the value of the third quartile, ).
Example
Usage is straightforward: pass in the data as the first argument, and if the corrected value is desired pass in a value of TRUE for the second argument. Note that Excel interprets any nonzero number as TRUE and it is common to use syntax like =MAD(data,1) to obtain the corrected MAD for the data.
Source Code
MAD = LAMBDA(
X, // input data (any shape)
[corrected], // apply correction? Default is FALSE.
LET(
corrected, IF(ISOMITTED(corrected), FALSE, corrected),
Xc, TOCOL(X),
Xn, FILTER(Xc, ISNUMBER(Xc)),
MAD, MEDIAN(ABS(Xn - MEDIAN(Xn))),
IF(corrected, MAD / NORM.S.INV(0.75), MAD)
)
);