-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathREADME.Rmd
96 lines (66 loc) · 3.46 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r echo=FALSE, message=FALSE}
set.seed(2020)
require(dirichletprocess)
require(ggplot2)
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "vignettes/img/"
)
```
# dirichletprocess
[![R build status](https://github.com/dm13450/dirichletprocess/workflows/R-CMD-check/badge.svg)](https://github.com/dm13450/dirichletprocess/actions)
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/dm13450/dirichletprocess?branch=master&svg=true)](https://ci.appveyor.com/project/dm13450/dirichletprocess)
[![Coverage Status](https://codecov.io/gh/dm13450/dirichletprocess/branch/master/graph/badge.svg)](https://app.codecov.io/gh/dm13450/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:
```{r, eval=FALSE}
install.packages("dirichletprocess")
```
You can also install the development build of dirichletprocess from github with:
```{r gh-installation, eval = FALSE}
# install.packages("devtools")
devtools::install_github("dm13450/dirichletprocess")
```
For a full guide to the package and its capabilities please consult the vignette:
```{r vignette, eval=FALSE}
browseVignettes(package = "dirichletprocess")
```
## Examples
### Density Estimation
Dirichlet processes can be used for nonparametric density estimation.
```{r density, eval=FALSE}
faithfulTransformed <- faithful$waiting - mean(faithful$waiting)
faithfulTransformed <- faithfulTransformed/sd(faithful$waiting)
dp <- DirichletProcessGaussian(faithfulTransformed)
dp <- Fit(dp, 100, progressBar = FALSE)
plot(dp)
```
<img src=https://github.com/dm13450/dirichletprocess/raw/master/vignettes/img/density-1.png width=50% />
### Clustering
Dirichlet processes can also be used to cluster data based on their common distribution parameters.
```{r clustering, eval=FALSE}
faithfulTrans <- scale(faithful)
dpCluster <- DirichletProcessMvnormal(faithfulTrans)
dpCluster <- Fit(dpCluster, 2000, progressBar = FALSE)
plot(dpCluster)
```
<img src=https://github.com/dm13450/dirichletprocess/raw/master/vignettes/img/clustering-1.png width=50% />
For more detailed explanations and examples see the vignette.
### Tutorials
I've written a number of tutorials:
* [Non parametric priors](https://dm13450.github.io/2019/02/22/Nonparametric-Prior.html)
* [Calculating cluster probabilities](https://dm13450.github.io/2018/11/21/Cluster-Probabilities.html)
* [Clustering](https://dm13450.github.io/2018/05/30/Clustering.html)
* [Point processes](https://dm13450.github.io/2018/03/08/dirichletprocess-pointprocess.html)
* [Custom mixtures](https://dm13450.github.io/2018/02/21/Custom-Distributions-Conjugate.html)
* [Density estimation](https://dm13450.github.io/2018/02/01/Dirichlet-Density.html)
* [Checking convergence](https://dm13450.github.io/2020/01/11/Dirichlet-Convergence.html)
and some case studies:
* [State of the Market - Infinite State Hidden Markov Models](https://dm13450.github.io/2020/06/03/State-of-the-Market.html)
* [Palmer Penguins and an Introduction to Dirichlet Processes](https://dm13450.github.io/2020/09/28/PriorToPosterior.html)