0
$\begingroup$

My data is a table of cosines and I want to analyze it with hclust, which works on squared Euclidean distances.

shall I do:

d <- dist(mydata, method = "euclidean") fit <- hclust(d, method="ward")

or rather:

d=(dist(mydata))^2
fit <- hclust(d, method="ward")

I don't know how to treat my cosines with hclust, which needs squared Euclidean distances.

thanks!!!

$\endgroup$
6
  • $\begingroup$ $r$ is directly convertible to squared Euclidean $d^2=2(1-r)$. $\endgroup$
    – ttnphns
    Jul 24, 2014 at 16:01
  • $\begingroup$ do you mean that the cosine is directly convertible into squared euclidean distances? what is r in your comment? $\endgroup$ Jul 24, 2014 at 16:22
  • 1
    $\begingroup$ Pardon, I ment $cos$. Pearson $r$ is cosine. The formula is correct. Please read details under the link. $\endgroup$
    – ttnphns
    Jul 24, 2014 at 16:29
  • $\begingroup$ thanks! ok. But have you ever tried hclust in R? it should work with Euclidean square distances when the ward method is called, but instead it gives error. do you have experience with R and with the hclust function there? $\endgroup$ Jul 24, 2014 at 20:28
  • $\begingroup$ Sorry, I've never user the function. Please consult the documentation $\endgroup$
    – ttnphns
    Jul 24, 2014 at 21:09

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.