0

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!!!

mariannaBol
  • 57
  • 1
  • 6
  • $r$ is [directly convertible](http://stats.stackexchange.com/a/36158/3277) to squared Euclidean $d^2=2(1-r)$. – ttnphns Jul 24 '14 at 16:01
  • do you mean that the cosine is directly convertible into squared euclidean distances? what is r in your comment? – mariannaBol Jul 24 '14 at 16:22
  • 1
    Pardon, I ment $cos$. Pearson $r$ is cosine. The formula is correct. Please _read_ details under the link. – ttnphns Jul 24 '14 at 16:29
  • 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? – mariannaBol Jul 24 '14 at 20:28
  • Sorry, I've never user the function. Please consult the documentation – ttnphns Jul 24 '14 at 21:09
  • i know. i think there is a problem with the code. will see. thanks! – mariannaBol Jul 25 '14 at 08:12

0 Answers0