8. MAD(中位数绝对偏差)

标签:
madprocimllinearregression |
分类: 统计分享 |
Summary:
From WIKI: For a univariate data set X1, X2, ..., Xn, the MAD is defined as the median of the absolute deviations from the data's median:
http://s8/middle/a3a92636gbc53f7d0a917&690MAD(中位数绝对偏差)" TITLE="8.
that is, starting with the residuals (deviations) from the data's median, the MAD is the median of their absolute values.
The
calculation of MAD statistic is very straightforward in proc IML.
The Scale factor K, i.e.,
以上定义从Wiki上引用。MAD的计算非常简单,虽然许多人也许并没有注意到这个统计量值。SAS语句是在IML/Studio上编写。不言而喻,就这段语句而言,和PROC IML语句没有任何的区别。只是放入PROC IML即可。K = STD/MAD, 是有理论依据的。所以对K的检测可归结为随机数特性的检查。
Results:
How MAD
was calculated:
<direct
MAD from SAS function>
<original
vector>
Regression
test if K correct:
<Scale
factor K> Estimated value <P
value:Estimated = K?>
SAS code (from IML/Studio):
*compute MAD statistic;
c = {1, 1, 2, 2, 4, 6, 9};
mad0 = mad(c);
median0 = median(c);
c1 = abs(c-median(c));
mad2 = median(c1);
print "How MAD was calculated:",,
*simulate and calculate Scale factor K;
x = j(1000, 1000);
m = j(ncol(x),2);
do i =1 to ncol(x);
end;
k = 1/quantile('normal', 3/4);
x = m[, 1]; y = m[, 2];
start
Regress;
finish
Regress;
run Regress;