I recently read a fascinating article describing methods for clustering data without assuming a fixed number of clusters.

The article even includes some sample code, in a mix of Ruby, Python, and R. However, the meat of the analysis is performed using scikit-learn's Dirichlet Process Gaussian Mixture Model to actually find clusters in some sample data taken from McDonald's menu.

Obviously, this a a great excuse to learn some more python, but I'm lazy and would like to find a ready-made R package that can take a dataframe and return clusters, in a manner similar to the kmeans function. A quick search on CRAN reveals the packages dpmixsim and profdpm. Any suggestions for the best place to start?

  • $\begingroup$ Also cran.r-project.org/web/packages/DPpackage which has Dirichlet process clustering I think, and cran.r-project.org/web/packages/bayesm has some DP stuff, don't remember what. $\endgroup$ – scellus May 16 '12 at 16:11
  • $\begingroup$ Whoever voted down- could you please leave a comment? $\endgroup$ – Zach May 16 '12 at 17:07
  • $\begingroup$ I am not the one who downvoted but I wanted to comment that one can simply add the number of clusters to the likelihood of the mixture distribution (often solved using E-M algorithm). It appears from your problem a Gaussian mixture model is assumed ( I don't know how the Dirichlet process fits in). There are some excellent books on mixture distributions. I recommend two by McLachlan. Finite Mixture Models (Wiley Series in Probability and Statistics) [Hardcover] Geoffrey McLachlan (Author), David Peel (Author) and $\endgroup$ – Michael R. Chernick May 16 '12 at 17:46
  • $\begingroup$ Mixture Models (Statistics: A Series of Textbooks and Monographs) [Hardcover] G. J. McLachlan (Author), K. E. Basford (Author) $\endgroup$ – Michael R. Chernick May 16 '12 at 17:47
  • 3
    $\begingroup$ @Michael: maximum likelihood with a varying number of (gaussien) clusters — how do you make it not to overlearn, especially if the cluster width is a parameters as well? $\endgroup$ – scellus May 16 '12 at 18:17

I looked at this more carefully, and the package bayesm has rDPGibbs which does "Density Estimation with Dirichlet Process Prior and Normal Base", a kind of Dirichlet clustering. DPpackage has DPdensity which looks similar. I haven't tried these packages myself, so I have no idea how well they work in practice. Details such as parameterization of the normal base and the possibility to set hyperpriors for the DP parameter may be significant.

  • $\begingroup$ DPpackage is orphaned on CRAN as of August 2019 it looks like $\endgroup$ – alexpghayes Dec 10 '19 at 2: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.