Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The general solutions suggested in the comments by @Chase and @bill_080 need a little bit of enhancement to (partially) fulfil the needs of the OP.</p> <p>A reproducible example:</p> <pre><code>require(MASS) set.seed(1) dat &lt;- data.frame(mvrnorm(100, mu = c(2,6,3), Sigma = matrix(c(10, 2, 4, 2, 3, 0.5, 4, 0.5, 2), ncol = 3))) </code></pre> <p>Compute the dissimilarity matrix of the standardised data using Eucildean distances</p> <pre><code>dij &lt;- dist(scale(dat, center = TRUE, scale = TRUE)) </code></pre> <p>and then calculate a hierarchical clustering of these data using the group average method</p> <pre><code>clust &lt;- hclust(dij, method = "average") </code></pre> <p>Next we compute the ordering of the samples on basis of forming 3 ('k') groups from the dendrogram, but we could have chosen something else here.</p> <pre><code>ord &lt;- order(cutree(clust, k = 3)) </code></pre> <p>Next compute the dissimilarities between samples based on dendrogram, the cophenetic distances:</p> <pre><code>coph &lt;- cophenetic(clust) </code></pre> <p>Here are 3 image plots of:</p> <ol> <li>The original dissimilarity matrix, sorted on basis of cluster analysis groupings,</li> <li>The cophenetic distances, again sorted as above</li> <li>The difference between the original dissimilarities and the cophenetic distances</li> <li>A Shepard-like plot comparing the original and cophenetic distances; the better the clustering at capturing the original distances the closer to the 1:1 line the points will lie</li> </ol> <p>Here is the code that produces the above plots</p> <pre><code>layout(matrix(1:4, ncol = 2)) image(as.matrix(dij)[ord, ord], main = "Original distances") image(as.matrix(coph)[ord, ord], main = "Cophenetic distances") image((as.matrix(coph) - as.matrix(dij))[ord, ord], main = "Cophenetic - Original") plot(coph ~ dij, ylab = "Cophenetic distances", xlab = "Original distances", main = "Shepard Plot") abline(0,1, col = "red") box() layout(1) </code></pre> <p>Which produces this on the active device:</p> <p><img src="https://i.stack.imgur.com/9AvaA.png" alt="plots of original and cophenetic distances"></p> <p>Having said all that, however, only the Shepard plot shows the "correlation between clustered data and [dis]similarity matrix", and that is not an image plot (levelplot). How would you propose to compute the correlation between two numbers for all pairwise comparisons of cophenetic and original [dis]similarities?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload