6
$\begingroup$

I am clustering a dataset using the pam command (from {cluster} package), and I wish to decide on the number of clusters to use.

I was able to implement The_Elbow_Method in R (see wiki) for doing that. But that doesn't provide me with any solid criteria (like AIC, for example) for decision.

I came by the {clValid} package which looks promising, but I wanted to know if there are any other R solutions (you know of) for choosing the number of clusters for pam?

Here's some dummy code if someone wants to show examples:

data(iris)
head(iris)
require(cluster)
pam(iris[,1:4], 3)
$\endgroup$
  • $\begingroup$ I came across a package recently that is supposed to help with this and they reference using it with pam. I haven't tried it yet but it looks promising. Check out the vignette. cran.r-project.org/web/packages/clues/index.html $\endgroup$ – Robert Nov 18 '10 at 20:58
3
$\begingroup$

You may find an answer to a similar question useful. I have also used clValid but, as I recall, it was rather slow (at least for relatively large datasets).

$\endgroup$
  • 3
    $\begingroup$ @Tal Galili You are welcome Tal! If you find out some other method for choosing the number of clusters, share it with us. $\endgroup$ – George Dontas Sep 16 '10 at 21:12
4
$\begingroup$

The fpc package provides a few clustering statistics. If you're looking for information criteria in particular, the cluster.stats method provides an information based distance. For mixture models based on clustering, the BIC is available.

$\endgroup$
  • $\begingroup$ fpc also has pamk, which can detect the number of clusters. $\endgroup$ – Sam Brightman Dec 30 '13 at 12:02
3
$\begingroup$

What about silhouette?

$\endgroup$
  • $\begingroup$ pam actually gives that out of the box (when using plot on the pam). I'm still open for other solutions :) $\endgroup$ – Tal Galili Sep 16 '10 at 15:53
  • 1
    $\begingroup$ @Tal I know, but you haven't mentioned it. $\endgroup$ – user88 Sep 16 '10 at 16:07
  • $\begingroup$ True, I simply forgot: +1 :) $\endgroup$ – Tal Galili Sep 16 '10 at 19:20
  • 2
    $\begingroup$ Also I still think that this is a very good method. $\endgroup$ – user88 Sep 16 '10 at 19:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.