{"action":"created","issue":{"url":"https://api.github.com/repos/nolanlab/Rclusterpp/issues/4","repository_url":"https://api.github.com/repos/nolanlab/Rclusterpp","labels_url":"https://api.github.com/repos/nolanlab/Rclusterpp/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/nolanlab/Rclusterpp/issues/4/comments","events_url":"https://api.github.com/repos/nolanlab/Rclusterpp/issues/4/events","html_url":"https://github.com/nolanlab/Rclusterpp/issues/4","id":191154678,"number":4,"title":"Odd results from Rclusterpp.hclust()","user":{"login":"michaelwhammer","id":23129139,"avatar_url":"https://avatars.githubusercontent.com/u/23129139?v=3","gravatar_id":"","url":"https://api.github.com/users/michaelwhammer","html_url":"https://github.com/michaelwhammer","followers_url":"https://api.github.com/users/michaelwhammer/followers","following_url":"https://api.github.com/users/michaelwhammer/following{/other_user}","gists_url":"https://api.github.com/users/michaelwhammer/gists{/gist_id}","starred_url":"https://api.github.com/users/michaelwhammer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaelwhammer/subscriptions","organizations_url":"https://api.github.com/users/michaelwhammer/orgs","repos_url":"https://api.github.com/users/michaelwhammer/repos","events_url":"https://api.github.com/users/michaelwhammer/events{/privacy}","received_events_url":"https://api.github.com/users/michaelwhammer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-11-22T23:38:00Z","updated_at":"2016-11-23T16:46:01Z","closed_at":null,"body":"I started using Rclusterpp.hclust(), but have found that it gives odd / incorrect results with some data sets that I've used it on. Of note, the returned object is not the same as that of hclust() {identical(h.fit$merge, r.fit$merge) && all.equal(h.fit$height, r.fit$height)} returns FALSE for several distances and methods. Even more strangely when I cut the resulting object with cutree I get more or less segments than requested (e.g. table(cutree(r.fit, k = 2)) shows I get WAY more than 2 segment solutions).\r\n\r\nBelow is a link to an .Rdata file with 4 matrices (mydata1, mydata2, mydata3, mydata4) that all exhibit these problems with Rclusterpp.hclust().\r\n\r\nhttps://app.box.com/s/8gmv7rsqoetl8owchd3bi9j33q735jzy\r\n\r\nThe problems I'm seeing are produced using the below code, although I also experience issues with other distances and methods available in Rclusterpp.hclust():\r\n\r\nh.fit <- hclust(d =   dist(mydata4, method =   \"manhattan\"), method = \"complete\")\r\nr.fit <- Rclusterpp.hclust(mydata4, distance = \"manhattan\",  method = \"complete\")\r\n\r\nidentical(h.fit$merge, r.fit$merge) && all.equal(h.fit$height, r.fit$height)\r\n\r\napply(cutree(h.fit, k = 2:10), 2, table)\r\napply(cutree(r.fit, k = 2:10), 2, table)\r\n\r\nMy R session info is as follows:\r\nR version 3.3.1 (2016-06-21)\r\nPlatform: x86_64-w64-mingw32/x64 (64-bit)\r\nRunning under: Windows 7 x64 (build 7601) Service Pack 1\r\n\r\nlocale:\r\n[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252\r\n[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    \r\n\r\nattached base packages:\r\n[1] stats     graphics  grDevices utils     datasets  methods   base     \r\n\r\nother attached packages:\r\n[1] Rclusterpp_0.2.3    RcppEigen_0.3.2.9.0 Rcpp_0.12.8        \r\n\r\nloaded via a namespace (and not attached):\r\n[1] Matrix_1.2-7.1  tools_3.3.1     grid_3.3.1      lattice_0.20-34\r\n"},"comment":{"url":"https://api.github.com/repos/nolanlab/Rclusterpp/issues/comments/262568660","html_url":"https://github.com/nolanlab/Rclusterpp/issues/4#issuecomment-262568660","issue_url":"https://api.github.com/repos/nolanlab/Rclusterpp/issues/4","id":262568660,"user":{"login":"michaelwhammer","id":23129139,"avatar_url":"https://avatars.githubusercontent.com/u/23129139?v=3","gravatar_id":"","url":"https://api.github.com/users/michaelwhammer","html_url":"https://github.com/michaelwhammer","followers_url":"https://api.github.com/users/michaelwhammer/followers","following_url":"https://api.github.com/users/michaelwhammer/following{/other_user}","gists_url":"https://api.github.com/users/michaelwhammer/gists{/gist_id}","starred_url":"https://api.github.com/users/michaelwhammer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaelwhammer/subscriptions","organizations_url":"https://api.github.com/users/michaelwhammer/orgs","repos_url":"https://api.github.com/users/michaelwhammer/repos","events_url":"https://api.github.com/users/michaelwhammer/events{/privacy}","received_events_url":"https://api.github.com/users/michaelwhammer/received_events","type":"User","site_admin":false},"created_at":"2016-11-23T16:46:01Z","updated_at":"2016-11-23T16:46:01Z","body":"Thank you for your take on this issue. The criteria I used for comparing the results I pulled from the author's paper which can be [found here](http://www2.uaem.mx/r-mirror/web/packages/Rclusterpp/vignettes/Rclusterpp.pdf). \r\nYou make a good point in that there are duplicates in the data sets I provided, which is often the case in the field in which I work (survey analysis and marketing). The handling of duplicates is an important aspect of any algorithm, especially in clustering. One thing to note is that mydata3 does not contain any duplicates, yet Rclusterpp.hclust() still gives weird results and returns more clusters than requested.\r\n\r\n`# No dupes in data`\r\n`any(duplicated(mydata3))`\r\n`dist.fit3 <- dist(mydata3, method =   \"manhattan\", diag = T, upper = T)`\r\n`r.fit <- Rclusterpp.hclust(mydata3, distance = \"manhattan\",  method = \"average\")`\r\n`# Gives odd results`\r\n`apply(cutree(r.fit, k = 2:10), 2, table)`\r\n\r\nThese data sets are only snippets of the full data which cause memory issues when calculating the distance matrix which is why I have enjoyed using this package, as the operation is no longer an O(N^2) operation.\r\n"}}
{"actor":{"display_login":"michaelwhammer"}}