Learn R Programming

dirichletprocess

The dirichletprocess package provides tools for you to build custom Dirichlet process mixture models. You can use the pre-built Normal/Weibull/Beta distributions or create your own following the instructions in the vignette. In as little as four lines of code you can be modelling your data nonparametrically.

Installation

You can install the stable release of dirichletprocess from CRAN:

install.packages("dirichletprocess")

You can also install the development build of dirichletprocess from github with:

# install.packages("devtools")
devtools::install_github("dm13450/dirichletprocess")

For a full guide to the package and its capabilities please consult the vignette:

browseVignettes(package = "dirichletprocess")

Examples

Density Estimation

Dirichlet processes can be used for nonparametric density estimation.

faithfulTransformed <- faithful$waiting - mean(faithful$waiting)
faithfulTransformed <- faithfulTransformed/sd(faithful$waiting)
dp <- DirichletProcessGaussian(faithfulTransformed)
dp <- Fit(dp, 100, progressBar = FALSE)
plot(dp)

Clustering

Dirichlet processes can also be used to cluster data based on their common distribution parameters.

faithfulTrans <- scale(faithful)
dpCluster <-  DirichletProcessMvnormal(faithfulTrans)
dpCluster <- Fit(dpCluster, 2000, progressBar = FALSE)
plot(dpCluster)

For more detailed explanations and examples see the vignette.

Tutorials

I’ve written a number of tutorials:

and some case studies:

Copy Link

Version

Install

install.packages('dirichletprocess')

Monthly Downloads

387

Version

0.4.2

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Last Published

August 25th, 2023

Functions in dirichletprocess (0.4.2)

Fit.markov

Fit a Hidden Markov Dirichlet Process Model
DirichletProcessHierarchicalMvnormal2

Create a Hierarchical Dirichlet Mixture of semi-conjugate Multivariate Normal Distributions
DirichletProcessCreate

Create a Dirichlet Process object
PosteriorFunction

Generate the posterior function of the Dirichlet function
GlobalParameterUpdate

Update the parameters of the hierarchical Dirichlet process object.
GaussianMixtureCreate

Create a Normal mixing distribution
DirichletProcessBeta2

Dirichlet process mixture of Beta distributions with a Uniform Pareto base measure.
PosteriorFrame

Calculate the posterior mean and quantiles from a Dirichlet process object.
Predictive.exponential

Calculate how well the prior predicts the data.
PosteriorParameters

Calculate the posterior parameters for a conjugate prior.
PenalisedLikelihood.beta

Calculate the parameters that maximise the penalised likelihood.
GaussianFixedVarianceMixtureCreate

Create a Gaussian Mixing Distribution with fixed variance.
MvnormalCreate

Create a multivariate normal mixing distribution
PriorDraw.beta

Draw from the prior distribution
DirichletProcessWeibull

Create a Dirichlet Mixture of the Weibull distribution
DirichletProcessExponential

Create a Dirichlet Mixture of Exponentials
PriorClusters

Draw prior clusters and weights from the Dirichlet process
MixingDistribution

Create a mixing distribution object
Initialise

Initialise a Dirichlet process object
Mvnormal2Create

Create a multivariate normal mixing distribution with semi conjugate prior
plot.dirichletprocess

Plot the Dirichlet process object
Likelihood.beta

Mixing Distribution Likelihood
DirichletProcessHierarchicalBeta

Create a Hierarchical Dirichlet Mixture of Beta Distributions
PriorDensity.beta

Calculate the prior density of a mixing distribution
DirichletProcessMvnormal

Create a Dirichlet mixture of multivariate normal distributions.
DirichletProcessGaussian

Create a Dirichlet Mixture of Gaussians
ExponentialMixtureCreate

Create a Exponential mixing distribution
rats

Tumour incidences in rats
PriorFunction

Generate the prior function of the Dirichlet process
HierarchicalBetaCreate

Create a Mixing Object for a hierarchical Beta Dirichlet process object.
HierarchicalMvnormal2Create

Create a Mixing Object for a hierarchical semi-conjugate Multivariate Normal Dirichlet process object.
print.dirichletprocess

Print the Dirichlet process object
true_cluster_labels

Identifies the correct clusters labels, in any dimension, when cluster parameters and global parameters are matched.
UpdateAlpha

Update the Dirichlet process concentration parameter.
Fit

Fit the Dirichlet process object
LikelihoodFunction

The Likelihood function of a Dirichlet process object.
weighted_function_generator

Generate a weighted function.
LikelihoodDP

The likelihood of the Dirichlet process object
PosteriorClusters

Generate the posterior clusters of a Dirichlet Process
PriorParametersUpdate.beta

Update the prior parameters of a mixing distribution
dirichletprocess

A flexible package for fitting Bayesian non-parametric models.
WeibullMixtureCreate

Create a Weibull mixing distribution.
PosteriorDraw.exponential

Draw from the posterior distribution
StickBreaking

The Stick Breaking representation of the Dirichlet process.
UpdateAlphaBeta

Update the \(\alpha\) and \(\beta\) parameter of a hidden Markov Dirichlet process model.
BetaMixture2Create

Create a Beta mixture with zeros at the boundaries.
DiagnosticPlots

Diagnostic plots for dirichletprocess objects
Burn

Add burn-in to a dirichletprocess object
DirichletHMMCreate

Create a generic Dirichlet process hidden Markov Model
ClusterParameterUpdate

Update the cluster parameters of the Dirichlet process.
ChangeObservations

Change the observations of fitted Dirichlet Process.
ClusterComponentUpdate

Update the component of the Dirichlet process
ClusterLabelPredict

Predict the cluster labels of some new data.
BetaMixtureCreate

Create a Beta mixing distribution.
DirichletProcessMvnormal2

Create a Dirichlet mixture of multivariate normal distributions with semi-conjugate prior.
DirichletProcessBeta

Dirichlet process mixture of the Beta distribution.
DirichletProcessGaussianFixedVariance

Create a Dirichlet Mixture of the Gaussian Distribution with fixed variance.