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$
1
  • $\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, 2010 at 20:58

3 Answers 3

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$
1
  • 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$
    – gd047
    Sep 16, 2010 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$
1
  • $\begingroup$ fpc also has pamk, which can detect the number of clusters. $\endgroup$ Dec 30, 2013 at 12:02
3
$\begingroup$

What about silhouette?

$\endgroup$
4
  • $\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, 2010 at 15:53
  • 1
    $\begingroup$ @Tal I know, but you haven't mentioned it. $\endgroup$
    – user88
    Sep 16, 2010 at 16:07
  • $\begingroup$ True, I simply forgot: +1 :) $\endgroup$
    – Tal Galili
    Sep 16, 2010 at 19:20
  • 2
    $\begingroup$ Also I still think that this is a very good method. $\endgroup$
    – user88
    Sep 16, 2010 at 19:39

Your Answer

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

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