dirichletprocess v0.2.0

0

Monthly downloads

0th

Percentile

Build Dirichlet Process Objects for Bayesian Modelling

Create Dirichlet process objects that can be used as infinite mixture models in a variety of ways. Some examples include; density estimation, Poisson process intensity inference, hierarchical modelling and clustering. See Teh, Y. W. (2011) <https://www.stats.ox.ac.uk/~teh/research/npbayes/Teh2010a.pdf>, among many other sources.

Readme

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 non-parametrically.

Installation

You can install 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 non-parametric density estimation.

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

data.frame(Weight=dp$weights, Mean=c(dp$clusterParameters[[1]]), SD=c(dp$clusterParameters[[1]]))
#>        Weight       Mean         SD
#> 1 0.371323529 -1.1756510 -1.1756510
#> 2 0.625000000  0.6597522  0.6597522
#> 3 0.003676471  0.1061095  0.1061095

Clustering

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

faithfulTrans <- as.matrix(apply(faithful, 2, function(x) (x-mean(x))/sd(x)))
dpCluster <-  DirichletProcessMvnormal(faithfulTrans)
dpCluster <- Fit(dpCluster, 1000, progressBar = FALSE)

To plot the results we take the cluster labels contained in the dp object and assign them a colour

For more detailed explanations and examples see the vignette.

Functions in dirichletprocess

Name Description
BetaMixtureCreate Create a Beta mixing distribution.
ChangeObservations Change the observations of fitted Dirichlet Process.
DirichletProcessHierarchicalBeta Create a Hierarchical Dirichlet Mixture of Beta Distributions
DirichletProcessMvnormal Create a Dirichlet mixture of multivariate normal distributions.
GaussianMixtureCreate Create a Normal mixing distribution
GlobalParameterUpdate Update the parameters of the hierarchical Dirichlet process object.
PriorDraw Draw from the prior distribution
PriorParametersUpdate Update the prior parameters of a mixing distribution
DirichletProcessCreate Create a Dirichlet Process object
DirichletProcessGaussian Create a Dirichlet Mixture of Gaussians
PosteriorClusters Generate the posterior clusters of a Dirichlet Process
PosteriorDraw Draw from the posterior distribution
DirichletProcessWeibull Create a Dirichlet Mixture of the Weibull distribution
Fit Fit the Dirichlet process object
PosteriorFunction Generate the posterior function of the Dirichlet function
PosteriorParameters Calculate the posterior parameters for a conjugate prior.
WeibullMixtureCreate Create a Weibull mixing distribution.
ClusterParameterUpdate Update the cluster parameters of the Dirichlet process.
DirichletProcessBeta Dirichlet process mixture of the Beta distribution.
MixingDistribution Create a mixing distribution object
ClusterComponentUpdate Update the component of the Dirichlet process
ClusterLabelPredict Predict the cluster labels of some new data.
Likelihood Mixing Distribution Likelihood
MvnormalCreate Create a multivariate normal mixing distribution
StickBreaking The Stick Breaking representation of the Dirichlet process.
UpdateAlpha Update the Dirichlet process concentration parameter.
plot.dirichletprocess Plot the Dirichlet Process
LikelihoodFunction The Likelihood of a Dirichlet process object.
Predictive Calculate how well the prior predicts the data.
PriorDensity Calculate the prior density of a mixing distribution
HierarchicalBetaCreate Create a Mixing Object for a hierarchical Beta Dirichlet process object.
Initialise Initialise a Dirichlet process object
weighted_function_generator Generate a weighted function.
dirichletprocess A flexible package for fitting Bayesian non-parametric models.
rats Tumour incidences in rats
No Results!

Vignettes of dirichletprocess

Name
img/betaGraph.aux
img/betaGraph.fdb_latexmk
img/betaGraph.fls
img/betaGraph.log
img/betaGraph.pdf
img/betaGraph.tex
img/clustering_fit_plot.aux
img/clustering_fit_plot.dvi
img/clustering_fit_plot.fdb_latexmk
img/clustering_fit_plot.fls
img/clustering_fit_plot.log
img/clustering_fit_plot.pdf
img/clustering_fit_plot.tex
img/clustering_initial_plot.aux
img/clustering_initial_plot.dvi
img/clustering_initial_plot.fdb_latexmk
img/clustering_initial_plot.fls
img/clustering_initial_plot.log
img/clustering_initial_plot.pdf
img/clustering_initial_plot.tex
img/clusteringplot-1.png
img/density-1.png
img/density_bounded_plot.aux
img/density_bounded_plot.dvi
img/density_bounded_plot.fdb_latexmk
img/density_bounded_plot.fls
img/density_bounded_plot.log
img/density_bounded_plot.pdf
img/density_bounded_plot.tex
img/faithful_multi_plot.pdf
img/faithful_pred_plot.pdf
img/gamma_mixture_plot.aux
img/gamma_mixture_plot.dvi
img/gamma_mixture_plot.fdb_latexmk
img/gamma_mixture_plot.fls
img/gamma_mixture_plot.log
img/gamma_mixture_plot.pdf
img/gamma_mixture_plot.tex
img/hierBetaGraph.aux
img/hierBetaGraph.fdb_latexmk
img/hierBetaGraph.fls
img/hierBetaGraph.log
img/hierBetaGraph.pdf
img/hierBetaGraph.tex
img/old_faithful_plot.aux
img/old_faithful_plot.dvi
img/old_faithful_plot.fdb_latexmk
img/old_faithful_plot.fls
img/old_faithful_plot.log
img/old_faithful_plot.pdf
img/old_faithful_plot.tex
img/poissonStickBreaking.aux
img/poissonStickBreaking.fdb_latexmk
img/poissonStickBreaking.fls
img/poissonStickBreaking.log
img/poissonStickBreaking.pdf
img/poissonStickBreaking.tex
img/poisson_intensity_plot.aux
img/poisson_intensity_plot.dvi
img/poisson_intensity_plot.fdb_latexmk
img/poisson_intensity_plot.fls
img/poisson_intensity_plot.log
img/poisson_intensity_plot.pdf
img/poisson_intensity_plot.tex
img/poisson_mixture_plot.aux
img/poisson_mixture_plot.fdb_latexmk
img/poisson_mixture_plot.fls
img/poisson_mixture_plot.log
img/poisson_mixture_plot.pdf
img/poisson_mixture_plot.tex
img/ratsDirichletPrior.aux
img/ratsDirichletPrior.fdb_latexmk
img/ratsDirichletPrior.fls
img/ratsDirichletPrior.log
img/ratsDirichletPrior.pdf
img/ratsDirichletPrior.tex
img/ratsImpericalDistribution.aux
img/ratsImpericalDistribution.fdb_latexmk
img/ratsImpericalDistribution.fls
img/ratsImpericalDistribution.log
img/ratsImpericalDistribution.pdf
img/ratsImpericalDistribution.tex
img/rats_dirichlet_model.aux
img/rats_dirichlet_model.fdb_latexmk
img/rats_dirichlet_model.fls
img/rats_dirichlet_model.log
img/rats_dirichlet_model.pdf
img/rats_dirichlet_model.tex
img/rats_parameteric_model.aux
img/rats_parameteric_model.fdb_latexmk
img/rats_parameteric_model.fls
img/rats_parameteric_model.log
img/rats_parameteric_model.pdf
img/rats_parameteric_model.tex
img/weibull_censor_graph.aux
img/weibull_censor_graph.fdb_latexmk
img/weibull_censor_graph.fls
img/weibull_censor_graph.log
img/weibull_censor_graph.pdf
img/weibull_censor_graph.tex
dirichletprocess.Rnw
dirichletprocess.bib
No Results!

Last month downloads

Details

Type Package
License GPL-3
Encoding UTF-8
LazyData true
URL https://github.com/dm13450/dirichletprocess
BugReports https://github.com/dm13450/dirichletprocess/issues
RoxygenNote 6.0.1
NeedsCompilation no
Packaged 2018-01-29 10:03:39 UTC; deanmarkwick
Repository CRAN
Date/Publication 2018-01-29 18:23:55 UTC

Include our badge in your README

[![Rdoc](http://www.rdocumentation.org/badges/version/dirichletprocess)](http://www.rdocumentation.org/packages/dirichletprocess)