03-07-2015 05:04 PM
I need to compute Mahalanobis distance for a dataset with about 200 observations and 17 variables. The goal is to identify 10 closest observations for each row. Variables have very different scales, and there are no missing values. Variables are of un-equal 'importance'.
As recommended in: 30662 - Mahalanobis distance: from each observation to the mean, from each observation to a specific..., I used Proc PRINCOMP with std option and used prin1rin17 for computing Euclidean distance. As expected first three components accounted for most of the variance. In particular, the first two were correlated highly with the key variables.
It seems that the weight option in the var statement could be used to assign greater importance to the first three components. However, there does not seem to be a rational basis for picking reasonable weight values.
Any feedback, suggestions will be greatly appreciated.
03-09-2015 03:37 AM
IML function ?
MAHALANOBIS(x, < , center > < , cov > );
The MAHALANOBIS function is part of the IMLMLIB library. The MAHALANOBIS function returns the
Mahalanobis distance between center and the rows of x, measured according to the Mahalanobis metric. The
03-10-2015 09:45 PM
I have already computed Mahalanobis distance - as the Euclidean distance with principal components. My questions pertains to the use of the 'weight' option in 'var' statement in PROC DISTANCE. Particularly, I am trying to find out if it is possible and reasonable to 'weight' the first principal component more heavily.
03-11-2015 12:24 PM
I 'm not sure what you want us to say. You want to weight the variables. The WEIGHTS= option in the VARS statement enables you to do it. From a SAS sytax point of view, your problem is solved.
If you are asking what relative weights you should use, then that depends on what you are trying to accomplish, and we don't have that information.
Are you trying to compute the distance in the PCA system? If so, you can use the distance between the PCA scores, which are the coordinates in the basis for the PCA vectors.
One possible interpretation of your request is "how do I assign relative importance to the PCA vectors?" You can use the "proportion of variance explained". Geometrically, I think that would undo the standardization and result in a coordinate system that is orthogonal but not orthonormal.
03-11-2015 07:21 PM
Thank you Dr. Wicklin,
I indeed meant the last interpretation. The goal is to find observations that are similar to each other, considering redundancy among variables as well importance from a substantive perspective. From a data-reduction view point, distance using first 4-5 scores could be used, which would be equivalent to assigning zero weight to the rest of the variable. Proportion of variance seems more justifiable. In the end, the two may result in fairly similar values given that the first five factors explain over 80% of variance.
I have not seen any examples of weighting. Are there concrete examples that you could point me to.
03-18-2015 10:07 AM
I think you can just use the Euclidean distance between coordinates of the first 4-5 PCA scores. A simple way to do this is to specify N=4 or N=5 in the PROC PRINCOMP statement. No need to use the WEIGHTS= option at all.