Thanks, Dr. Wicklin! I have read the article concerning the calculation of MD within SAS before, but I am so sorry that I don't truly understand what does the "center" mean in SAS. In your blog, the article says"Given an observation x from a multivariate normal distribution with mean μ and covariance matrix Σ, the squared Mahalanobis distance from x to μ is given by the formula d2 = (x - μ)T Σ -1 (x - μ). You can use this definition to define a function that returns the Mahalanobis distance for a row vector x, given a center vector (usually μ or an estimate of μ) and a covariance matrix:" In my word, the center vector in my example is the 10 variable intercepts of the second class, namely 0,0,0,0,0,0,0,0,0,0. I know I am wrong, but don't know what is wrong. I hope that you can help me with my problem. Thank you! proc iml; /* simplest approach: x and center are row vectors */ start mahal1(x, center, cov); y = (x - center)`; /* col vector */ d2 = y` * inv(cov) * y; /* explicit inverse. Not optimal */ return (sqrt(d2)); finish; x = {0.35 -0.2 0.6 -0.75 0.35 -0.2 0.6 -0.75 0.35 -0.2, 0 0 0 0 0 0 0 0 0 0}; /* test it */ center = {0 0 0 0 0 0 0 0 0 0 0}; cov = {0.1225 -0.07 0.21 -0.2625 0.1225 -0.07 0.21 -0.2625 0.1225 -0.07, -0.07 0.04 -0.12 0.15 -0.07 0.04 -0.12 0.15 -0.07 0.04, 0.21 -0.12 0.36 -0.45 0.21 -0.12 0.36 -0.45 0.21 -0.12, -0.2625 0.15 -0.45 0.5625 -0.2625 0.15 -0.45 0.5625 -0.2625 0.15, 0.1225 -0.07 0.21 -0.2625 0.1225 -0.07 0.21 -0.2625 0.1225 -0.07, -0.07 0.04 -0.12 0.15 -0.07 0.04 -0.12 0.15 -0.07 0.04, 0.21 -0.12 0.36 -0.45 0.21 -0.12 0.36 -0.45 0.21 -0.12, -0.2625 0.15 -0.45 0.5625 -0.2625 0.15 -0.45 0.5625 -0.2625 0.15, 0.1225 -0.07 0.21 -0.2625 0.1225 -0.07 0.21 -0.2625 0.1225 -0.07, -0.07 0.04 -0.12 0.15 -0.07 0.04 -0.12 0.15 -0.07 0.04}; md1 = mahal1(x, center, cov); print md1;
... View more