MAD Function
finds the univariate (scaled) medianabsolutedeviation
 MAD( (x<,spt>))
where
 x
 is an n ×p input data matrix.
 spt
 is an optional string argument with the following values:
 "MAD"
 for computing the MAD (which is the default)
 "NMAD"
 for computing the normalized version of MAD
 "SN"
 for computing S_{n}
 "QN"
 for computing Q_{n}
The MAD function can be used for computing one of the following
three robust scale estimates:
 Median Absolute Deviation (MAD) or normalized form of MAD:
where b=1 is the unscaled default and b=1.4826 is used
for the scaled version (consistency with the Gaussian
distribution).
 S_{n} which is a more efficient alternative to MAD:
where the outer median is a low median (order statistic
of rank [[(n+1)/2]]) and the inner median
is a high median (order statistic of rank
[[n/2]+1]), and where c_{n} is a scalar
depending on sample size n.
 Q_{n} is another efficient alternative to MAD. It is based
on the kth order statistic of the
interpoint distances:
where d_{n} is a scalar similar to, but different from c_{n}.
See Rousseeuw and Croux (1993) for more details.
The scalars c_{n} and d_{n} are defined as follows:
Example
This example uses the univariate data set
of Barnett & Lewis (1978) that is used above to
illustrate the univariate LMS and LTS estimates:
b = { 3, 4, 7, 8, 10, 949, 951 };
rmad1 = mad(b);
rmad2 = mad(b,"mad");
rmad3 = mad(b,"nmad");
rmad4 = mad(b,"sn");
rmad5 = mad(b,"qn");
print "Default MAD=" rmad1,
"Common MAD =" rmad2,
"MAD*1.4826 =" rmad3,
"Robust S_n =" rmad4,
"Robust Q_n =" rmad5;
This program produces the following:
Default MAD= 4
Common MAD = 4
MAD*1.4826 = 5.9304089
Robust S_n = 7.143674
Robust Q_n = 5.7125049
References

Barnett, V. and Lewis, T. (1978),
Outliers in Statistical Data,
New York: John Wiley & Sons, Inc.

Rousseeuw, P.J. and Croux, C. (1993),
"Alternatives to the Median Absolute Deviation,"
Journal of the American Statistical Association,
88, 1273 1283.
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.