dirichletprocess v0.2.1

0

Monthly downloads

0th

Percentile

Build Dirichlet Process Objects for Bayesian Modelling

Perform nonparametric Bayesian analysis using Dirichlet processes without the need to program the inference algorithms. Utilise included pre-built models or specify custom models and allow the dirichletprocess package to handle the Markov chain Monte Carlo sampling. Our Dirichlet process objects can act as building blocks for a variety of statistical models including and not limited to: density estimation, clustering and prior distributions in hierarchical models. See Teh, Y. W. (2011) <https://www.stats.ox.ac.uk/~teh/research/npbayes/Teh2010a.pdf>, among many other sources.

Readme

dirichletprocess

Travis-CI Build Status AppVeyor Build Status Coverage Status

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)

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
Initialise Initialise a Dirichlet process object
Fit Fit the Dirichlet process object
PosteriorClusters Generate the posterior clusters of a Dirichlet Process
PosteriorFunction Generate the posterior function of the Dirichlet function
PosteriorParameters Calculate the posterior parameters for a conjugate prior.
PriorDensity Calculate the prior density of a mixing distribution
weighted_function_generator Generate a weighted function.
Predictive Calculate how well the prior predicts the data.
MixingDistribution Create a mixing distribution object
Likelihood Mixing Distribution Likelihood
UpdateAlpha Update the Dirichlet process concentration parameter.
PosteriorDraw Draw from the posterior distribution
LikelihoodFunction The Likelihood of a Dirichlet process object.
MvnormalCreate Create a multivariate normal mixing distribution
StickBreaking The Stick Breaking representation of the Dirichlet process.
plot.dirichletprocess Plot the Dirichlet process object
WeibullMixtureCreate Create a Weibull mixing distribution.
rats Tumour incidences in rats
dirichletprocess A flexible package for fitting Bayesian non-parametric models.
DirichletProcessExponential Create a Dirichlet Mixture of Exponentials
ClusterParameterUpdate Update the cluster parameters of the Dirichlet process.
ChangeObservations Change the observations of fitted Dirichlet Process.
ClusterLabelPredict Predict the cluster labels of some new data.
DirichletProcessHierarchicalBeta Create a Hierarchical Dirichlet Mixture of Beta Distributions
ClusterComponentUpdate Update the component of the Dirichlet process
DirichletProcessBeta Dirichlet process mixture of the Beta distribution.
DirichletProcessGaussian Create a Dirichlet Mixture of Gaussians
DirichletProcessCreate Create a Dirichlet Process object
BetaMixtureCreate Create a Beta mixing distribution.
ExponentialMixtureCreate Create a Exponential mixing distribution
DirichletProcessMvnormal Create a Dirichlet mixture of multivariate normal distributions.
DirichletProcessWeibull Create a Dirichlet Mixture of the Weibull distribution
PriorParametersUpdate Update the prior parameters of a mixing distribution
HierarchicalBetaCreate Create a Mixing Object for a hierarchical Beta Dirichlet process object.
GaussianMixtureCreate Create a Normal mixing distribution
PriorDraw Draw from the prior distribution
GlobalParameterUpdate Update the parameters of the hierarchical Dirichlet process object.
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-04-18 13:56:36 UTC; deanmarkwick
Repository CRAN
Date/Publication 2018-04-18 16:36:06 UTC

Include our badge in your README

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