title: R: clustering with a similarity or dissimilarity matrix? And visualizing the results
body: <p>I have a similarity matrix that I created using <strong>Harry</strong>&mdash;a tool for string similarity, and I wanted to plot some dendrograms out of it to see if I could find some clusters / groups in the data. I'm using the following similarity measures:</p>
  
  <ul>
  <li>Normalized compression distance (NCD)    </li>
  <li>Damerau-Levenshtein distance</li>
  <li>Jaro-Winkler distance    </li>
  <li>Levenshtein distance     </li>
  <li>Optimal string alignment distance (OSA)</li>
  </ul>
  
  <p>("For comparison Harry loads a set of strings from input, computes the specified similarity measure and writes a matrix of similarity values to output")</p>
  
  <p>At first, it was like my first time using R, I didn't pay to much attention on the documentation of <code>hclust</code>, so I used it with a <em>similarity matrix</em>. I know I should have used a <em>dissimilarity matrix</em>, and I know, since my <em>similarity matrix</em> is normalized [0,1], that I could just do <em>dissimilarity = 1 - similarity</em> and then use <code>hclust</code>.</p>
  
  <p>But, the groups that I get using <code>hclust</code>with a <em>similarity matrix</em> are much better than the ones I get using <code>hclust</code>and it's correspondent <em>dissimilarity matrix</em>.</p>
  
  <p>I tried to use the <code>proxy</code> package as well and the same problem, the groups that I get aren't what I expected, happens.</p>
  
  <p>To get the dendrograms using the similarity function I do:</p>
  
  <ol>
  <li><code>plot(hclust(as.dist(""similarityMATRIX""), "average"))</code></li>
  </ol>
  
  <p>With the dissimilarity matrix I tried:</p>
  
  <ol start="2">
  <li><code>plot(hclust(as.dist(""dissimilarityMATRIX""), "average"))</code></li>
  </ol>
  
  <p>and</p>
  
  <ol start="3">
  <li><code>plot(hclust(as.sim(""dissimilarityMATRIX""), "average"))</code></li>
  </ol>
  
  <p>From (1) I get what I believe to be a very good dendrogram, and so I can get very good groups out of it. From (2) and (3) I get the same dendrogram and the groups that I can get out of it aren't as good as the ones I get from (1)</p>
  
  <p>I'm saying that the groups are bad/good because at the moment I have a somewhat little volume of data to analyse, and so I can check them very easily. </p>
  
  <p>Does this that I'm getting makes any sense? There is something that justify this? Some suggestion on how to cluster with a similarity matrizx. Is there a better way to visualize a similarity matrix than a dendrogram?</p>