title: Clustering with a Distance Matrix via Mahalanobis distance
body: <p>I have a set of pairwise distances (in a matrix) between objects that I would like to cluster. I currently use k-means clustering (computing distance from the centroid as the average distance to all members of the given cluster, since I do not have coordinates), with k chosen by the best Davies-Bouldin index over an interval.</p>
  
  <p>However, I have three separate metrics (more in the future, potentially) describing the difference between the data, each fairly different in terms of magnitude and spread. Currently, I compute the distance matrix with the Euclidean distance across the three metrics, but I am fairly certain that the difference between the metrics is messing it up (e.g. the largest one is overpowering the other ones). </p>
  
  <p>I thought a good way to deal with this is to use the Mahalanobis distance to combine the metrics. However, I obviously cannot compute the covariance matrix between the coordinates, but I can compute it for the distance metrics. Does this make sense? That is, if I get the distance between two objects <em>i</em> and <em>j</em> as:</p>
  
  <pre><code>D(i,j) = sqrt( dt S^-1 d )
  </code></pre>
  
  <p>where d is the 3-vector of the different distance metrics between i and j, dt is the transpose of d, and S is the covariance matrix of the <em>distances</em>, would D be a good, normalized metric for clustering? </p>
  
  <p>I have also thought of normalizing the metrics (i.e. subtracting the mean and dividing out the variance) and then simply staying with the euclidean distance (in fact it would seem that this essentially is Mahalanobis distance, at least in some cases), or of switching to something like DBSCAN or EM, and have not ruled them out (though MDS then clustering might be a bit excessive). As a sidenote, any packages able to do all of this would be greatly appreciated. Thanks!</p>