diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index ccce1ed..688ad90 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -1,39 +1,60 @@ -# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag. -# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help on: push: - branches: - - main - - master + branches: [main, master] pull_request: - branches: - - main - - master -name: R-CMD-check +name: R-CMD-check.yaml + +permissions: read-all jobs: R-CMD-check: - runs-on: macOS-latest + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + + strategy: + fail-fast: false + matrix: + config: + - {os: macos-latest, r: 'release'} + - {os: windows-latest, r: 'release'} + - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-latest, r: 'release'} + - {os: ubuntu-latest, r: 'oldrel-1'} + env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes + steps: - - uses: actions/checkout@v2 - - uses: r-lib/actions/setup-tinytex@v2 + - uses: actions/checkout@v6 + - uses: r-lib/actions/setup-pandoc@v2 + - uses: r-lib/actions/setup-r@v2 - - name: Install dependencies + with: + r-version: ${{ matrix.config.r }} + http-user-agent: ${{ matrix.config.http-user-agent }} + + - uses: r-lib/actions/setup-tinytex@v2 + + - name: Install additional LaTeX packages run: | - install.packages(c("remotes", "rcmdcheck", "tinytex", - "ggplot2", "gtools", "mvtnorm", - "testthat", "knitr", "rmarkdown", - "tidyr", "dplyr")) - tinytex::tlmgr_install(pkgs = c("ae", "thumbpdf", - "multirow", "listings", - "caption", "subcaption", - "tcolorbox", "pgf", - "environ", "babel-english", - "grfext", "hyperref")) - shell: Rscript {0} - - name: Check - run: rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "error") + install.packages("tinytex") + tinytex::tlmgr_install(c( + "thumbpdf", "multirow", "listings", "caption", "subcaption", + "tcolorbox", "pgf", "environ", "babel-english", "grfext", "hyperref" + )) shell: Rscript {0} + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::rcmdcheck + needs: check + + - uses: r-lib/actions/check-r-package@v2 + with: + upload-snapshots: true + build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")' diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml new file mode 100644 index 0000000..5e820d3 --- /dev/null +++ b/.github/workflows/test-coverage.yaml @@ -0,0 +1,60 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [main, master] + pull_request: + +name: test-coverage.yaml + +permissions: read-all + +jobs: + test-coverage: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v6 + + - uses: r-lib/actions/setup-r@v2 + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::covr, any::xml2 + needs: coverage + + - name: Test coverage + run: | + cov <- covr::package_coverage( + quiet = FALSE, + clean = FALSE, + install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") + ) + print(cov) + covr::to_cobertura(cov) + shell: Rscript {0} + + - uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7 + with: + # Fail if error if not on PR, or if on PR and token is given + fail_ci_if_error: ${{ github.event_name != 'pull_request' || secrets.CODECOV_TOKEN }} + files: ./cobertura.xml + plugins: noop + disable_search: true + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Show testthat output + if: always() + run: | + ## -------------------------------------------------------------------- + find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true + shell: bash + + - name: Upload test results + if: failure() + uses: actions/upload-artifact@v7 + with: + name: coverage-test-failures + path: ${{ runner.temp }}/package diff --git a/.gitignore b/.gitignore index 29120ad..1d5bb0f 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ inst/doc .Rhistory clean_bib.sh tests/testthat/Rplots.pdf +.DS_Store diff --git a/DESCRIPTION b/DESCRIPTION index 303b985..ef306a1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: dirichletprocess Type: Package Title: Build Dirichlet Process Objects for Bayesian Modelling -Version: 0.4.2 +Version: 0.4.2.9000 Authors@R: c( person("Gordon", "J. Ross", email="gordon@gordonjross.co.uk", role=c("aut")), person("Dean", "Markwick", email="dean.markwick@talk21.com", role=c("aut", "cre")), @@ -36,4 +36,4 @@ Imports: gtools, mvtnorm URL: https://github.com/dm13450/dirichletprocess, https://dm13450.github.io/dirichletprocess/ BugReports: https://github.com/dm13450/dirichletprocess/issues -RoxygenNote: 7.2.3 +Config/roxygen2/version: 8.0.0 diff --git a/NAMESPACE b/NAMESPACE index 221c0a3..af52ea6 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -123,6 +123,7 @@ export(plot_dirichletprocess_multivariate) export(plot_dirichletprocess_univariate) export(true_cluster_labels) export(weighted_function_generator) +importFrom(ggplot2,.data) importFrom(stats,dbeta) importFrom(stats,dbinom) importFrom(stats,dexp) diff --git a/NEWS.md b/NEWS.md index 83ea935..85492fb 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,10 @@ -# dirichletprocess 0.4.0.9000 +# dirichletprocess 0.4.2.9000 + +* Updated GitHub Actions +* Fixed ggplot deprecation +* Added some missing tests + +# dirichletprocess 0.4.2 * Added PriorFunction and PriorClusters to draw from the base measure. * Fixed a bug in the likelihood calculation (#21) by Filippo Fiocchi. diff --git a/R/diagnostic_plots.R b/R/diagnostic_plots.R index 97b64bd..f21b817 100644 --- a/R/diagnostic_plots.R +++ b/R/diagnostic_plots.R @@ -36,16 +36,15 @@ DiagnosticPlots <- function(dpobj, gg = FALSE) { } - - #' @export -#' @describeIn DiagnosticPlots Trace plot of alpha. +#' @describeIn DiagnosticPlots Trace plot of alpha. +#' @importFrom ggplot2 .data AlphaTraceplot <- function(dpobj, gg = TRUE) { if (gg) { p <- ggplot2::ggplot(data.frame(Alpha = dpobj$alphaChain, Index = seq_along(dpobj$alphaChain)), - ggplot2::aes_string("Index", "Alpha")) + + ggplot2::aes(x=.data$Index, y=.data$Alpha)) + ggplot2::geom_line() + ggplot2::ggtitle("Traceplot of alpha") return(p) @@ -58,6 +57,7 @@ AlphaTraceplot <- function(dpobj, gg = TRUE) { #' @export #' @describeIn DiagnosticPlots Plot of the prior and posterior of alpha. +#' @importFrom ggplot2 .data AlphaPriorPosteriorPlot <- function(dpobj, prior_color = "#2c7fb8", post_color = "#d95f02", gg = TRUE) { dap <- dpobj$alphaPriorParameters @@ -69,14 +69,17 @@ AlphaPriorPosteriorPlot <- function(dpobj, prior_color = "#2c7fb8", post_color = p <- ggplot2::ggplot() + ggplot2::geom_histogram(data = data.frame(Alpha = dpobj$alphaChain), - mapping = ggplot2::aes_string("Alpha", - "..density..", - colour = "'Posterior'", fill = "'Posterior'"), + mapping = ggplot2::aes(x=.data$Alpha, + ggplot2::after_stat(.data$density), + colour = "'Posterior'", + fill = "'Posterior'"), bins = min(its / 10, 100)) + ggplot2::stat_function(fun = prior_fun, - mapping = ggplot2::aes_string(colour = "'Prior'")) + + mapping = ggplot2::aes(colour = "'Prior'")) + ggplot2::ggtitle("Prior and posterior of alpha") + - ggplot2::scale_colour_manual(labels = c("Posterior", "Prior"), values = c(prior_color, post_color), aesthetics = c("colour", "fill"), name = " ") + ggplot2::scale_colour_manual(labels = c("Posterior", "Prior"), + values = c(prior_color, post_color), + aesthetics = c("colour", "fill"), name = " ") return(p) } else { graphics::hist(dpobj$alphaChain, freq = FALSE, breaks = min(its / 10, 100), @@ -90,6 +93,7 @@ AlphaPriorPosteriorPlot <- function(dpobj, prior_color = "#2c7fb8", post_color = #' @export #' @describeIn DiagnosticPlots Trace plot of the number of clusters. +#' @importFrom ggplot2 .data ClusterTraceplot <- function(dpobj, gg = TRUE) { n_clust <- vapply(dpobj$labelsChain, function(x) length(unique(x)), numeric(1)) @@ -97,7 +101,7 @@ ClusterTraceplot <- function(dpobj, gg = TRUE) { if (gg) { p <- ggplot2::ggplot(data.frame(nclust = n_clust, Index = seq_along(n_clust)), - ggplot2::aes_string("Index", "nclust")) + + ggplot2::aes(x=.data$Index, y=.data$nclust)) + ggplot2::geom_line() + ggplot2::ylab("Number of clusters") + ggplot2::ggtitle("Traceplot of the number of clusters") @@ -117,7 +121,7 @@ LikelihoodTraceplot <- function(dpobj, gg = TRUE) { if (gg) { p <- ggplot2::ggplot(data.frame(Lik = dpobj$likelihoodChain, Index = seq_along(dpobj$likelihoodChain)), - ggplot2::aes_string("Index", "Lik")) + + ggplot2::aes(x=.data$Index, y=.data$Lik)) + ggplot2::geom_line() + ggplot2::ylab("Log-likelihood") + ggplot2::ggtitle("Traceplot of the log-likelihood") diff --git a/R/dirichletprocess-package.R b/R/dirichletprocess-package.R new file mode 100644 index 0000000..a65cf64 --- /dev/null +++ b/R/dirichletprocess-package.R @@ -0,0 +1,6 @@ +#' @keywords internal +"_PACKAGE" + +## usethis namespace: start +## usethis namespace: end +NULL diff --git a/R/plot_dirichletprocess.R b/R/plot_dirichletprocess.R index 9a15b66..2db5634 100644 --- a/R/plot_dirichletprocess.R +++ b/R/plot_dirichletprocess.R @@ -32,6 +32,7 @@ plot_dirichletprocess.mvnormal <- function(x, ...) { #' @export #' @rdname plot.dirichletprocess +#' @importFrom ggplot2 .data plot_dirichletprocess_univariate <- function(x, likelihood = FALSE, single = TRUE, @@ -43,15 +44,17 @@ plot_dirichletprocess_univariate <- function(x, quant_pts = 100, xlim = NA) { - graph <- ggplot2::ggplot(data.frame(dt = x$data), ggplot2::aes_(x = ~dt)) + + graph <- ggplot2::ggplot(data.frame(dt = x$data), ggplot2::aes(x = .data$dt)) + ggplot2::theme(axis.title = ggplot2::element_blank()) if (data_method == "density") { graph <- graph + ggplot2::geom_density(fill = data_fill, - bw = ifelse(is.null(data_bw), "nrd0", data_bw)) + bw = ifelse(is.null(data_bw), + "nrd0", + data_bw)) } else if (data_method == "hist" | data_method == "histogram") { - graph <- graph + ggplot2::geom_histogram(ggplot2::aes_(x = ~dt, - y = ~..density..), + graph <- graph + ggplot2::geom_histogram(ggplot2::aes(x = .data$dt, + ggplot2::after_stat(.data$density)), fill = data_fill, binwidth = data_bw) } else if (data_method != "none") { @@ -76,9 +79,9 @@ plot_dirichletprocess_univariate <- function(x, quantile, probs = c(ci_size/2, 0.5, 1 - ci_size/2), na.rm = TRUE) - graph <- graph + ggplot2::geom_line(data=data.frame(x=x_grid, y=posteriorCI[1,]), ggplot2::aes_(x=~x,y=~y, colour="Posterior"), linetype=2) - graph <- graph + ggplot2::geom_line(data=data.frame(x=x_grid, y=posteriorCI[2,]), ggplot2::aes_(x=~x,y=~y, colour="Posterior")) - graph <- graph + ggplot2::geom_line(data=data.frame(x=x_grid, y=posteriorCI[3,]), ggplot2::aes_(x=~x,y=~y, colour="Posterior"), linetype=2) + graph <- graph + ggplot2::geom_line(data=data.frame(x=x_grid, y=posteriorCI[1,]), ggplot2::aes(x=.data$x,y=.data$y, colour="Posterior"), linetype=2) + graph <- graph + ggplot2::geom_line(data=data.frame(x=x_grid, y=posteriorCI[2,]), ggplot2::aes(x=.data$x,y=.data$y, colour="Posterior")) + graph <- graph + ggplot2::geom_line(data=data.frame(x=x_grid, y=posteriorCI[3,]), ggplot2::aes(x=.data$x,y=.data$y, colour="Posterior"), linetype=2) if (likelihood) { graph <- graph + ggplot2::stat_function(fun = function(z) LikelihoodFunction(x)(z), @@ -93,11 +96,17 @@ plot_dirichletprocess_univariate <- function(x, #' @export #' @rdname plot.dirichletprocess +#' @importFrom ggplot2 .data plot_dirichletprocess_multivariate <- function(x) { - plotFrame <- data.frame(x1=x$data[,1], x2=x$data[,2], Cluster=as.factor(x$clusterLabel)) + plotFrame <- data.frame(x1=x$data[,1], + x2=x$data[,2], + Cluster=as.factor(x$clusterLabel)) - graph <- ggplot2::ggplot(plotFrame, ggplot2::aes_(x=~x1, y=~x2, colour=~Cluster)) + + graph <- ggplot2::ggplot(plotFrame, + ggplot2::aes(x=.data$x1, + y=.data$x2, + colour=.data$Cluster)) + ggplot2::geom_point() return(graph) } diff --git a/README.Rmd b/README.Rmd index bd14981..20a2d78 100644 --- a/README.Rmd +++ b/README.Rmd @@ -17,10 +17,12 @@ knitr::opts_chunk$set( # dirichletprocess -[![R build status](https://github.com/dm13450/dirichletprocess/workflows/R-CMD-check/badge.svg)](https://github.com/dm13450/dirichletprocess/actions) + +[![R-CMD-check](https://github.com/dm13450/dirichletprocess/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/dm13450/dirichletprocess/actions/workflows/R-CMD-check.yaml) [![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) - +[![Codecov test coverage](https://codecov.io/gh/dm13450/dirichletprocess/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. diff --git a/docs/404.html b/docs/404.html index a2eda44..20aba5f 100644 --- a/docs/404.html +++ b/docs/404.html @@ -1,62 +1,33 @@ - - - - + + + + - Page not found (404) • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - + + + - -
-
- + +
+ + + - - -
+
+
-
- - - + + + diff --git a/docs/authors.html b/docs/authors.html index 7daad34..152e3b8 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -1,62 +1,18 @@ - - - - - - - -Authors • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Authors and Citation • dirichletprocess - + - - -
-
-
-
+
- @@ -135,22 +101,20 @@

Authors

-
- +
+ + - - - + diff --git a/docs/index.html b/docs/index.html index f0b025a..871b215 100644 --- a/docs/index.html +++ b/docs/index.html @@ -6,29 +6,27 @@ Build Dirichlet Process Objects for Bayesian Modelling • dirichletprocess - + - + + + +
-
- - +
+ +

R 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

+
+

Installation +

You can install the stable release of dirichletprocess from CRAN:

-
-install.packages("dirichletprocess")
-
+
+install.packages("dirichletprocess")

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

-
-# install.packages("devtools")
-devtools::install_github("dm13450/dirichletprocess")
-
+
+# 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

+
+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)
-
+
+faithfulTransformed <- faithful$waiting - mean(faithful$waiting)
+faithfulTransformed <- faithfulTransformed/sd(faithful$waiting)
+dp <- DirichletProcessGaussian(faithfulTransformed)
+dp <- Fit(dp, 100, progressBar = FALSE)
+plot(dp)

-
-

-Clustering

+
+

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)
-
+
+faithfulTrans <- scale(faithful)
+dpCluster <-  DirichletProcessMvnormal(faithfulTrans)
+dpCluster <- Fit(dpCluster, 2000, progressBar = FALSE)
+plot(dpCluster)

For more detailed explanations and examples see the vignette.

- @@ -154,55 +142,60 @@

-

Site built with pkgdown 1.6.1.

+

+

Site built with pkgdown 2.2.0.

- + + + diff --git a/docs/news/index.html b/docs/news/index.html index 2026dfb..44149ff 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -1,62 +1,18 @@ - - - - - - - -Changelog • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Changelog • dirichletprocess + - - -
-
- - -
-
+
-
-

-dirichletprocess 0.4.0.9000 Unreleased -

-
    -
  • Added PriorFunction and PriorClusters to draw from the base measure.
  • -
-
-
-

-dirichletprocess 0.4.0 2020-06-13 -

-
    -
  • Hierarchical Normal Models added by Giovanni Sighinolfi
  • +
    + +
    • Updated GitHub Actions
    • +
    • Fixed ggplot deprecation
    • +
    • Added some missing tests
    • +
    +
    + +
    • Added PriorFunction and PriorClusters to draw from the base measure.
    • +
    • Fixed a bug in the likelihood calculation (#21) by Filippo Fiocchi.
    • +
    • Added hierarchical print statement method.
    • +
    +
    + +
    • Hierarchical Normal Models added by Giovanni Sighinolfi
    • Added Giovanni Sighinolfi as a contributor.
    • Added params chain to Hidden Markov Models
    • Updated the vignette for hierarchical normal models.
    • -
    -
    -
    -

    -dirichletprocess 0.3.1 2019-12-11 -

    -
      -
    • Fixed matrix class checking for R 4.0.0
    • +
    +
    + +
    • Fixed matrix class checking for R 4.0.0
    • Corrected typos in vignette
    • Added a parameter for the number of initial clusters in DirichletProcessMvnormal.
    • Various refactoring.
    • -
    -
    -
    -

    -dirichletprocess 0.3.0 2019-05-03 -

    -
      -
    • Added Hidden Markov models.
    • +
    +
    + +
    • Added Hidden Markov models.
    • Fixed bug in PosteriorClusters and PosteriorFunction.
    • Added in new Beta mixture model for avoiding boundary.
    • Fixed a bug in ChangeObservations when using more than one dimension.
    • Added in Burn, Print and Diagnostic Plots.
    • -
    -
    -
    -

    -dirichletprocess 0.2.2 2018-11-23 -

    -
      -
    • Added a likelihood variable for the dirichletprocess class that is calculate with each fit iteration.
    • +
    +
    + +
    • Added a likelihood variable for the dirichletprocess class that is calculate with each fit iteration.
    • Added option to change how many Metropolis-Hasting steps are used in each iteration.
    • Added a likelihood calculation with each iteration.
    • Added and refactored some tests.
    • Updated vignette.
    • Additional options to univariate plotting.
    • Added Kees Mulder as a contributor.
    • -
    -
    -
    -

    -dirichletprocess 0.2.1 2018-04-18 -

    -
      -
    • Added AppVeyor, Travis-CI and codecov.io badges.
    • +
    +
    + +
    • Added AppVeyor, Travis-CI and codecov.io badges.
    • Added penalised log-likelihood step for posterior cluster parameter inference.
    • Added exponential mixture model DirichletProcessExponential.
    • Updated plot. Multivariate Gaussian models can now be plotted.
    • Various bug fixes.
    • Updated description.
    • -
    -
    -
    -

    -dirichletprocess 0.2.0 2018-01-29 -

    -
      -
    • First public release.
    • +
    +
    + +
    • First public release.
    • Added a NEWS.md file to track changes to the package.
    • -
    -
    +
+
-
- +
+ + - - - + diff --git a/docs/pkgdown.css b/docs/pkgdown.css index 1273238..80ea5b8 100644 --- a/docs/pkgdown.css +++ b/docs/pkgdown.css @@ -56,8 +56,10 @@ img.icon { float: right; } -img { +/* Ensure in-page images don't run outside their container */ +.contents img { max-width: 100%; + height: auto; } /* Fix bug in bootstrap (only seen in firefox) */ @@ -78,11 +80,10 @@ dd { /* Section anchors ---------------------------------*/ a.anchor { - margin-left: -30px; - display:inline-block; - width: 30px; - height: 30px; - visibility: hidden; + display: none; + margin-left: 5px; + width: 20px; + height: 20px; background-image: url(./link.svg); background-repeat: no-repeat; @@ -90,17 +91,15 @@ a.anchor { background-position: center center; } -.hasAnchor:hover a.anchor { - visibility: visible; -} - -@media (max-width: 767px) { - .hasAnchor:hover a.anchor { - visibility: hidden; - } +h1:hover .anchor, +h2:hover .anchor, +h3:hover .anchor, +h4:hover .anchor, +h5:hover .anchor, +h6:hover .anchor { + display: inline-block; } - /* Fixes for fixed navbar --------------------------*/ .contents h1, .contents h2, .contents h3, .contents h4 { @@ -264,31 +263,26 @@ table { /* Syntax highlighting ---------------------------------------------------- */ -pre { - word-wrap: normal; - word-break: normal; - border: 1px solid #eee; -} - -pre, code { +pre, code, pre code { background-color: #f8f8f8; color: #333; } +pre, pre code { + white-space: pre-wrap; + word-break: break-all; + overflow-wrap: break-word; +} -pre code { - overflow: auto; - word-wrap: normal; - white-space: pre; +pre { + border: 1px solid #eee; } -pre .img { +pre .img, pre .r-plt { margin: 5px 0; } -pre .img img { +pre .img img, pre .r-plt img { background-color: #fff; - display: block; - height: auto; } code a, pre a { @@ -305,9 +299,8 @@ a.sourceLine:hover { .kw {color: #264D66;} /* keyword */ .co {color: #888888;} /* comment */ -.message { color: black; font-weight: bolder;} -.error { color: orange; font-weight: bolder;} -.warning { color: #6A0366; font-weight: bolder;} +.error {font-weight: bolder;} +.warning {font-weight: bolder;} /* Clipboard --------------------------*/ @@ -365,3 +358,27 @@ mark { content: ""; } } + +/* Section anchors --------------------------------- + Added in pandoc 2.11: https://github.com/jgm/pandoc-templates/commit/9904bf71 +*/ + +div.csl-bib-body { } +div.csl-entry { + clear: both; +} +.hanging-indent div.csl-entry { + margin-left:2em; + text-indent:-2em; +} +div.csl-left-margin { + min-width:2em; + float:left; +} +div.csl-right-inline { + margin-left:2em; + padding-left:1em; +} +div.csl-indent { + margin-left: 2em; +} diff --git a/docs/pkgdown.js b/docs/pkgdown.js index 7e7048f..6f0eee4 100644 --- a/docs/pkgdown.js +++ b/docs/pkgdown.js @@ -80,7 +80,7 @@ $(document).ready(function() { var copyButton = ""; - $(".examples, div.sourceCode").addClass("hasCopyButton"); + $("div.sourceCode").addClass("hasCopyButton"); // Insert copy buttons: $(copyButton).prependTo(".hasCopyButton"); @@ -91,7 +91,7 @@ // Initialize clipboard: var clipboardBtnCopies = new ClipboardJS('[data-clipboard-copy]', { text: function(trigger) { - return trigger.parentNode.textContent; + return trigger.parentNode.textContent.replace(/\n#>[^\n]*/g, ""); } }); diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index dba4b4c..73f839b 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -1,6 +1,5 @@ -pandoc: 2.3.1 -pkgdown: 1.6.1 +pandoc: 3.8.3 +pkgdown: 2.2.0 pkgdown_sha: ~ articles: {} -last_built: 2020-09-25T06:58Z - +last_built: 2026-08-07T04:37Z diff --git a/docs/reference/BetaMixture2Create.html b/docs/reference/BetaMixture2Create.html index 1f32d8f..af1f0a9 100644 --- a/docs/reference/BetaMixture2Create.html +++ b/docs/reference/BetaMixture2Create.html @@ -1,66 +1,18 @@ - - - - - - - -Create a Beta mixture with zeros at the boundaries. — BetaMixture2Create • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Create a Beta mixture with zeros at the boundaries. — BetaMixture2Create • dirichletprocess + - - -
-
- - -
-
+
-

Create a Beta mixture with zeros at the boundaries.

-
-
BetaMixture2Create(priorParameters = 2, mhStepSize = c(1, 1),
-  maxT = 1)
- -

Arguments

- - - - - - - - - - - - - - -
priorParameters

The prior parameters for the base measure.

mhStepSize

The Metropolis Hastings step size. A numeric vector of length 2.

maxT

The upper bound of the Beta distribution. Defaults to 1 for the standard Beta distribution.

- -

Value

+
+
BetaMixture2Create(priorParameters = 2, mhStepSize = c(1, 1), maxT = 1)
+
+ +
+

Arguments

+ + +
priorParameters
+

The prior parameters for the base measure.

+ +
mhStepSize
+

The Metropolis Hastings step size. A numeric vector of length 2.

+ + +
maxT
+

The upper bound of the Beta distribution. Defaults to 1 for the standard Beta distribution.

+ +
+
+

Value

A mixing distribution object.

- +
+
-
- +
+ + - - - + diff --git a/docs/reference/BetaMixtureCreate.html b/docs/reference/BetaMixtureCreate.html index 238755c..954ef1f 100644 --- a/docs/reference/BetaMixtureCreate.html +++ b/docs/reference/BetaMixtureCreate.html @@ -1,66 +1,18 @@ - - - - - - - -Create a Beta mixing distribution. — BetaMixtureCreate • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Create a Beta mixing distribution. — BetaMixtureCreate • dirichletprocess - + - -
-
- - -
-
+
- -

See DirichletProcessBeta for the default prior and hyper prior distributions.

- +

See DirichletProcessBeta for the default prior and hyper prior distributions.

-
BetaMixtureCreate(priorParameters = c(2, 8), mhStepSize = c(1, 1),
-  maxT = 1, hyperPriorParameters = c(1, 0.125))
- -

Arguments

- - - - - - - - - - - - - - - - - - -
priorParameters

The prior parameters for the base measure.

mhStepSize

The Metropolis Hastings step size. A numeric vector of length 2.

maxT

The upper bound of the Beta distribution. Defaults to 1 for the standard Beta distribution.

hyperPriorParameters

The parameters for the hyper prior.

- -

Value

+
+
BetaMixtureCreate(
+  priorParameters = c(2, 8),
+  mhStepSize = c(1, 1),
+  maxT = 1,
+  hyperPriorParameters = c(1, 0.125)
+)
+
+ +
+

Arguments

+ + +
priorParameters
+

The prior parameters for the base measure.

+ +
mhStepSize
+

The Metropolis Hastings step size. A numeric vector of length 2.

+ + +
maxT
+

The upper bound of the Beta distribution. Defaults to 1 for the standard Beta distribution.

+ + +
hyperPriorParameters
+

The parameters for the hyper prior.

+ +
+
+

Value

A mixing distribution object.

- +
+
-
- +
+ + - - - + diff --git a/docs/reference/Burn-1.png b/docs/reference/Burn-1.png index 174dc8a..3830202 100644 Binary files a/docs/reference/Burn-1.png and b/docs/reference/Burn-1.png differ diff --git a/docs/reference/Burn-2.png b/docs/reference/Burn-2.png index 62d1553..780fe0b 100644 Binary files a/docs/reference/Burn-2.png and b/docs/reference/Burn-2.png differ diff --git a/docs/reference/Burn.html b/docs/reference/Burn.html index 8fa5ea9..0f56636 100644 --- a/docs/reference/Burn.html +++ b/docs/reference/Burn.html @@ -1,66 +1,18 @@ - - - - - - - -Add burn-in to a dirichletprocess object — Burn • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Add burn-in to a dirichletprocess object — Burn • dirichletprocess + - - -
-
- - -
-
+
-

Add burn-in to a dirichletprocess object

-
-
Burn(dpobj, niter)
- -

Arguments

- - - - - - - - - - -
dpobj

A dirichletprocess object.

niter

Number of iterations to burn.

- -

Value

+
+
Burn(dpobj, niter)
+
+ +
+

Arguments

+ + +
dpobj
+

A dirichletprocess object.

+ +
niter
+

Number of iterations to burn.

+ +
+
+

Value

A dirichletprocess object where all chain objects have the first niter iterations are removed.

- - -

Examples

-
burned_dp <- Burn(dp, 50) -DiagnosticPlots(burned_dp) -
+
+ +
+

Examples

+
dp <- Fit(DirichletProcessGaussian(rnorm(10)), 100)
+DiagnosticPlots(dp)
+
+burned_dp <- Burn(dp, 50)
+DiagnosticPlots(burned_dp)
+
+
+
+
-
- +
+ + - - - + diff --git a/docs/reference/ChangeObservations.html b/docs/reference/ChangeObservations.html index 1a15f83..01554fc 100644 --- a/docs/reference/ChangeObservations.html +++ b/docs/reference/ChangeObservations.html @@ -1,66 +1,18 @@ - - - - - - - -Change the observations of fitted Dirichlet Process. — ChangeObservations • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Change the observations of fitted Dirichlet Process. — ChangeObservations • dirichletprocess + - - -
-
- - -
-
+
-

Using a fitted Dirichlet process object include new data. The new data will be assigned to the best fitting cluster for each point.

-
-
ChangeObservations(dpobj, newData)
- -

Arguments

- - - - - - - - - - -
dpobj

The Dirichlet process object.

newData

New data to be included

- -

Value

+
+
ChangeObservations(dpobj, newData)
+
-

Changed Dirichlet process object

- +
+

Arguments

+ + +
dpobj
+

The Dirichlet process object.

-

Examples

-
-y <- rnorm(10) -dp <- DirichletProcessGaussian(y) -dp <- ChangeObservations(dp, rnorm(10)) -
+
newData
+

New data to be included

+ +
+
+

Value

+

Changed Dirichlet process object

+
+ +
+

Examples

+

+y <- rnorm(10)
+dp <- DirichletProcessGaussian(y)
+dp <- ChangeObservations(dp, rnorm(10))
+
+
+
+
-
- +
+ + - - - + diff --git a/docs/reference/ClusterComponentUpdate.html b/docs/reference/ClusterComponentUpdate.html index 3719e51..62b9deb 100644 --- a/docs/reference/ClusterComponentUpdate.html +++ b/docs/reference/ClusterComponentUpdate.html @@ -1,66 +1,18 @@ - - - - - - - -Update the component of the Dirichlet process — ClusterComponentUpdate • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Update the component of the Dirichlet process — ClusterComponentUpdate • dirichletprocess - + - -
-
- - -
-
+
-

Update the cluster assignment for each data point.

-
-
ClusterComponentUpdate(dpObj)
-
-# S3 method for conjugate
-ClusterComponentUpdate(dpObj)
-
-# S3 method for hierarchical
-ClusterComponentUpdate(dpObj)
- -

Arguments

- - - - - - -
dpObj

Dirichlet Process object

- -

Value

+
+
ClusterComponentUpdate(dpObj)
+
+# S3 method for class 'conjugate'
+ClusterComponentUpdate(dpObj)
+
+# S3 method for class 'hierarchical'
+ClusterComponentUpdate(dpObj)
+
-

Dirichlet process object with update components.

- +
+

Arguments

-

Examples

-
dp <- DirichletProcessGaussian(rnorm(10)) -dp <- ClusterComponentUpdate(dp) -
+
dpObj
+

Dirichlet Process object

+ +
+
+

Value

+

Dirichlet process object with update components.

+
+ +
+

Examples

+
dp <- DirichletProcessGaussian(rnorm(10))
+dp <- ClusterComponentUpdate(dp)
+
+
+
+
-
- +
+ + - - - + diff --git a/docs/reference/ClusterLabelPredict.html b/docs/reference/ClusterLabelPredict.html index d74979d..9d366f4 100644 --- a/docs/reference/ClusterLabelPredict.html +++ b/docs/reference/ClusterLabelPredict.html @@ -1,66 +1,18 @@ - - - - - - - -Predict the cluster labels of some new data. — ClusterLabelPredict • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Predict the cluster labels of some new data. — ClusterLabelPredict • dirichletprocess + - - -
-
- - -
-
+
-

Given a fitted Dirichlet process object and some new data use this function to predict what clusters the new data belong to and associated cluster parameters.

-
-
ClusterLabelPredict(dpobj, newData)
- -

Arguments

- - - - - - - - - - -
dpobj

Fitted Dirichlet Process

newData

New data to have cluster labels predicted.

- -

Value

+
+
ClusterLabelPredict(dpobj, newData)
+
-

A list of the predicted cluster labels of some new unseen data.

- +
+

Arguments

+ + +
dpobj
+

Fitted Dirichlet Process

-

Examples

-
y <- rnorm(10) -dp <- DirichletProcessGaussian(y) -dp <- Fit(dp, 5) -newY <- rnorm(10, 1) -pred <- ClusterLabelPredict(dp, newY) -
+
newData
+

New data to have cluster labels predicted.

+ +
+
+

Value

+

A list of the predicted cluster labels of some new unseen data.

+
+ +
+

Examples

+
y <- rnorm(10)
+dp <- DirichletProcessGaussian(y)
+dp <- Fit(dp, 5)
+newY <- rnorm(10, 1)
+pred <- ClusterLabelPredict(dp, newY)
+
+
+
+
-
- +
+ + - - - + diff --git a/docs/reference/ClusterParameterUpdate.html b/docs/reference/ClusterParameterUpdate.html index d599447..2907378 100644 --- a/docs/reference/ClusterParameterUpdate.html +++ b/docs/reference/ClusterParameterUpdate.html @@ -1,67 +1,19 @@ - - - - - - - -Update the cluster parameters of the Dirichlet process. — ClusterParameterUpdate • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Update the cluster parameters of the Dirichlet process. — ClusterParameterUpdate • dirichletprocess - + - -
-
- - -
-
+
-

Update the parameters of each individual cluster using all the data assigned to the particular cluster. A sample is taken from the posterior distribution using a direct sample if the mixing distribution is conjugate or the Metropolis Hastings algorithm for non-conjugate mixtures.

-
-
ClusterParameterUpdate(dpObj)
- -

Arguments

- - - - - - -
dpObj

Dirichlet process object

- -

Value

+
+
ClusterParameterUpdate(dpObj)
+
-

Dirichlet process object with update cluster parameters

- +
+

Arguments

-

Examples

-
dp <- DirichletProcessGaussian(rnorm(10)) -dp <- ClusterParameterUpdate(dp) -
+
dpObj
+

Dirichlet process object

+ +
+
+

Value

+

Dirichlet process object with update cluster parameters

+
+ +
+

Examples

+
dp <- DirichletProcessGaussian(rnorm(10))
+dp <- ClusterParameterUpdate(dp)
+
+
+
+
-
- +
+ + - - - + diff --git a/docs/reference/DiagnosticPlots-1.png b/docs/reference/DiagnosticPlots-1.png index ed2e96e..8bc602c 100644 Binary files a/docs/reference/DiagnosticPlots-1.png and b/docs/reference/DiagnosticPlots-1.png differ diff --git a/docs/reference/DiagnosticPlots.html b/docs/reference/DiagnosticPlots.html index e0a42f5..b814e93 100644 --- a/docs/reference/DiagnosticPlots.html +++ b/docs/reference/DiagnosticPlots.html @@ -1,69 +1,21 @@ - - - - - - - -Diagnostic plots for dirichletprocess objects — DiagnosticPlots • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Diagnostic plots for dirichletprocess objects — DiagnosticPlots • dirichletprocess - - - - - - - - - - + - - -
-
- - -
-
+
-

Plot several diagnostic plots for dirichletprocess objects. Because the dimension of the dirichletprocess mixture is constantly changing, it is not simple to create meaningful plots of the sampled parameters. Therefore, the plots focus on the likelihood, alpha, and the number of clusters.

-
-
DiagnosticPlots(dpobj, gg = FALSE)
+    
+
DiagnosticPlots(dpobj, gg = FALSE)
+
+AlphaTraceplot(dpobj, gg = TRUE)
+
+AlphaPriorPosteriorPlot(
+  dpobj,
+  prior_color = "#2c7fb8",
+  post_color = "#d95f02",
+  gg = TRUE
+)
+
+ClusterTraceplot(dpobj, gg = TRUE)
+
+LikelihoodTraceplot(dpobj, gg = TRUE)
+
+ +
+

Arguments

-AlphaTraceplot(dpobj, gg = TRUE) -AlphaPriorPosteriorPlot(dpobj, prior_color = "#2c7fb8", - post_color = "#d95f02", gg = TRUE) +
dpobj
+

A dirichletprocess object that was fit.

-ClusterTraceplot(dpobj, gg = TRUE) -LikelihoodTraceplot(dpobj, gg = TRUE)
- -

Arguments

- - - - - - - - - - - - - - - - - - -
dpobj

A dirichletprocess object that was fit.

gg

Logical; whether to create a ggplot or base R plot (if gg = +

gg
+

Logical; whether to create a ggplot or base R plot (if gg = FALSE). For DiagnosticPlots, this means that the plots will be -given one-by-one, while base plots can be arranged in a grid.

prior_color

For AlphaPriorPosteriorPlot, the color of the prior -function.

post_color

For AlphaPriorPosteriorPlot, the color of the -posterior histogram.

- -

Value

+given one-by-one, while base plots can be arranged in a grid.

+ + +
prior_color
+

For AlphaPriorPosteriorPlot, the color of the prior +function.

+ +
post_color
+

For AlphaPriorPosteriorPlot, the color of the +posterior histogram.

+ +
+
+

Value

If gg = TRUE, a ggplot2 object. Otherwise, nothing is returned and a base plot is plotted.

- -

Functions

- - -
    -
  • AlphaTraceplot: Trace plot of alpha.

  • -
  • AlphaPriorPosteriorPlot: Plot of the prior and posterior of alpha.

  • -
  • ClusterTraceplot: Trace plot of the number of clusters.

  • -
  • LikelihoodTraceplot: Trace plot of the likelihood of the data for +

+
+

Functions

+ +
  • AlphaTraceplot(): Trace plot of alpha.

  • +
  • AlphaPriorPosteriorPlot(): Plot of the prior and posterior of alpha.

  • +
  • ClusterTraceplot(): Trace plot of the number of clusters.

  • +
  • LikelihoodTraceplot(): Trace plot of the likelihood of the data for each iteration.

  • -
- - -

Examples

-
dp <- Fit(DirichletProcessGaussian(rnorm(10)), 100) -DiagnosticPlots(dp) -
-
+
+ +
+

Examples

+
dp <- Fit(DirichletProcessGaussian(rnorm(10)), 100)
+DiagnosticPlots(dp)
+
+
+
+
+
-
- +
+ + - - - + diff --git a/docs/reference/DirichletHMMCreate.html b/docs/reference/DirichletHMMCreate.html index 1d14ec9..f2d31d0 100644 --- a/docs/reference/DirichletHMMCreate.html +++ b/docs/reference/DirichletHMMCreate.html @@ -1,66 +1,18 @@ - - - - - - - -Create a generic Dirichlet process hidden Markov Model — DirichletHMMCreate • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Create a generic Dirichlet process hidden Markov Model — DirichletHMMCreate • dirichletprocess - + - -
-
- - -
-
+
-

Create a hidden Markov model where the data is believed to be generated from the mixing object distribution.

-
-
DirichletHMMCreate(x, mdobj, alpha, beta)
- -

Arguments

- - - - - - - - - - - - - - - - - - -
x

Data to be modelled

mdobj

Mixing disitribution object

alpha

Alpha parameter

beta

Beta parameter

- +
+
DirichletHMMCreate(x, mdobj, alpha, beta)
+
+ +
+

Arguments

+ + +
x
+

Data to be modelled

+ + +
mdobj
+

Mixing disitribution object

+ + +
alpha
+

Alpha parameter

+ + +
beta
+

Beta parameter

+ +
+
-
- +
+ + - - - + diff --git a/docs/reference/DirichletProcessBeta.html b/docs/reference/DirichletProcessBeta.html index d0c1794..71c5847 100644 --- a/docs/reference/DirichletProcessBeta.html +++ b/docs/reference/DirichletProcessBeta.html @@ -1,66 +1,18 @@ - - - - - - - -Dirichlet process mixture of the Beta distribution. — DirichletProcessBeta • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Dirichlet process mixture of the Beta distribution. — DirichletProcessBeta • dirichletprocess + - - -
-
- - -
-
+
-

Create a Dirichlet process object using the mean and scale parameterisation of the Beta distribution bounded on \((0, maxY)\).

-
-
DirichletProcessBeta(y, maxY, g0Priors = c(2, 8), alphaPrior = c(2, 4),
-  mhStep = c(1, 1), hyperPriorParameters = c(1, 0.125),
-  verbose = TRUE, mhDraws = 250)
- -

Arguments

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
y

Data for which to be modelled.

maxY

End point of the data

g0Priors

Prior parameters of the base measure \((\alpha _0, \beta _0)\).

alphaPrior

Prior parameters for the concentration parameter. See also UpdateAlpha.

mhStep

Step size for Metropolis Hastings sampling algorithm.

hyperPriorParameters

Hyper-prior parameters for the prior distributions of the base measure parameters \((a, b)\).

verbose

Logical, control the level of on screen output.

mhDraws

Number of Metropolis-Hastings samples to perform for each cluster update.

- -

Value

+
+
DirichletProcessBeta(
+  y,
+  maxY,
+  g0Priors = c(2, 8),
+  alphaPrior = c(2, 4),
+  mhStep = c(1, 1),
+  hyperPriorParameters = c(1, 0.125),
+  verbose = TRUE,
+  mhDraws = 250
+)
+
+ +
+

Arguments

+ + +
y
+

Data for which to be modelled.

+ + +
maxY
+

End point of the data

+ + +
g0Priors
+

Prior parameters of the base measure \((\alpha _0, \beta _0)\).

+ + +
alphaPrior
+

Prior parameters for the concentration parameter. See also UpdateAlpha.

+ + +
mhStep
+

Step size for Metropolis Hastings sampling algorithm.

-

Dirichlet process object

- -

Details

+
hyperPriorParameters
+

Hyper-prior parameters for the prior distributions of the base measure parameters \((a, b)\).

+ + +
verbose
+

Logical, control the level of on screen output.

+ + +
mhDraws
+

Number of Metropolis-Hastings samples to perform for each cluster update.

+ +
+
+

Value

+

Dirichlet process object

+
+
+

Details

\(G_0 (\mu , \nu | maxY, \alpha _0 , \beta _0) = U(\mu | 0, maxY) \mathrm{Inv-Gamma} (\nu | \alpha _0, \beta _0)\).

-

The parameter \(\beta _0\) also has a prior distribution \(\beta _0 \sim \mathrm{Gamma} (a, b)\) if the user selects Fit(...,updatePrior=TRUE).

- +

The parameter \(\beta _0\) also has a prior distribution \(\beta _0 \sim \mathrm{Gamma} (a, b)\) if the user selects Fit(...,updatePrior=TRUE).

+
+
-
- +
+ + - - - + diff --git a/docs/reference/DirichletProcessBeta2.html b/docs/reference/DirichletProcessBeta2.html index f56dcba..aee0ce7 100644 --- a/docs/reference/DirichletProcessBeta2.html +++ b/docs/reference/DirichletProcessBeta2.html @@ -1,67 +1,19 @@ - - - - - - - -Dirichlet process mixture of Beta distributions with a Uniform Pareto base measure. — DirichletProcessBeta2 • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Dirichlet process mixture of Beta distributions with a Uniform Pareto base measure. — DirichletProcessBeta2 • dirichletprocess + - - -
-
- - -
-
+
-

Create a Dirichlet process object using the mean and scale parameterisation of the Beta distribution bounded on \((0, maxY)\). The Pareto distribution is used as a prior on the scale parameter to ensure that the likelihood is 0 at the boundaries.

-
-
DirichletProcessBeta2(y, maxY, g0Priors = 2, alphaPrior = c(2, 4),
-  mhStep = c(1, 1), verbose = TRUE, mhDraws = 250)
- -

Arguments

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
y

Data for which to be modelled.

maxY

End point of the data

g0Priors

Prior parameters of the base measure \((\gamma\).

alphaPrior

Prior parameters for the concentration parameter. See also UpdateAlpha.

mhStep

Step size for Metropolis Hastings sampling algorithm.

verbose

Logical, control the level of on screen output.

mhDraws

Number of Metropolis-Hastings samples to perform for each cluster update.

- -

Value

+
+
DirichletProcessBeta2(
+  y,
+  maxY,
+  g0Priors = 2,
+  alphaPrior = c(2, 4),
+  mhStep = c(1, 1),
+  verbose = TRUE,
+  mhDraws = 250
+)
+
+ +
+

Arguments

+ + +
y
+

Data for which to be modelled.

+ + +
maxY
+

End point of the data

+ + +
g0Priors
+

Prior parameters of the base measure \((\gamma\).

+ + +
alphaPrior
+

Prior parameters for the concentration parameter. See also UpdateAlpha.

-

Dirichlet process object

- -

Details

+
mhStep
+

Step size for Metropolis Hastings sampling algorithm.

+ + +
verbose
+

Logical, control the level of on screen output.

+ + +
mhDraws
+

Number of Metropolis-Hastings samples to perform for each cluster update.

+ +
+
+

Value

+

Dirichlet process object

+
+
+

Details

\(G_0 (\mu , \nu | maxY, \alpha ) = U(\mu | 0, maxY) \mathrm{Pareto} (\nu | x_m, \gamma)\).

- +
+
-
- +
+ + - - - + diff --git a/docs/reference/DirichletProcessCreate.html b/docs/reference/DirichletProcessCreate.html index 6f1bc7a..b292228 100644 --- a/docs/reference/DirichletProcessCreate.html +++ b/docs/reference/DirichletProcessCreate.html @@ -1,67 +1,19 @@ - - - - - - - -Create a Dirichlet Process object — DirichletProcessCreate • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Create a Dirichlet Process object — DirichletProcessCreate • dirichletprocess - + - -
-
- - -
-
+
-

Using a previously created Mixing Distribution Object (mdObject) create a Dirichlet process object. `alphaPriorParameters sets the parameters for alpha using the shape-rate specification of the gamma distribution.

-
-
DirichletProcessCreate(x, mdObject, alphaPriorParameters = c(1, 1),
-  mhDraws = 250)
- -

Arguments

- - - - - - - - - - - - - - - - - - -
x

Data

mdObject

Mixing Distribution Object

alphaPriorParameters

Prior parameters for the concentration parameter of the Dirichlet Process

mhDraws

Number of posterior samples to take in the nonconjugate case

- +
+
DirichletProcessCreate(
+  x,
+  mdObject,
+  alphaPriorParameters = c(1, 1),
+  mhDraws = 250
+)
+
+ +
+

Arguments

+ + +
x
+

Data

+ + +
mdObject
+

Mixing Distribution Object

+ + +
alphaPriorParameters
+

Prior parameters for the concentration parameter of the Dirichlet Process

+ + +
mhDraws
+

Number of posterior samples to take in the nonconjugate case

+ +
+
-
- +
+ + - - - + diff --git a/docs/reference/DirichletProcessExponential.html b/docs/reference/DirichletProcessExponential.html index 4b31f96..244be48 100644 --- a/docs/reference/DirichletProcessExponential.html +++ b/docs/reference/DirichletProcessExponential.html @@ -1,67 +1,19 @@ - - - - - - - -Create a Dirichlet Mixture of Exponentials — DirichletProcessExponential • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Create a Dirichlet Mixture of Exponentials — DirichletProcessExponential • dirichletprocess - + - -
-
- - -
-
+
-

This is the constructor function to produce a dirichletprocess object with a Exponential mixture kernel with unknown rate. The base measure is a Gamma distribution that is conjugate to the posterior distribution.

-
-
DirichletProcessExponential(y, g0Priors = c(0.01, 0.01),
-  alphaPriors = c(2, 4))
- -

Arguments

- - - - - - - - - - - - - - -
y

Data

g0Priors

Base Distribution Priors \(\alpha _0 , \beta _0)\)

alphaPriors

Alpha prior parameters. See UpdateAlpha.

- -

Value

+
+
DirichletProcessExponential(y, g0Priors = c(0.01, 0.01), alphaPriors = c(2, 4))
+
+ +
+

Arguments

+ + +
y
+

Data

-

Dirichlet process object

- -

Details

+
g0Priors
+

Base Distribution Priors \(\alpha _0 , \beta _0)\)

+ + +
alphaPriors
+

Alpha prior parameters. See UpdateAlpha.

+ +
+
+

Value

+

Dirichlet process object

+
+
+

Details

\(G_0(\theta | \alpha _0, \beta_0) = \mathrm{Gamma} \left(\theta | \alpha_0, \beta_0 \right)\)

- +
+
-
- +
+ + - - - + diff --git a/docs/reference/DirichletProcessGaussian.html b/docs/reference/DirichletProcessGaussian.html index 4120f6d..bac6cd6 100644 --- a/docs/reference/DirichletProcessGaussian.html +++ b/docs/reference/DirichletProcessGaussian.html @@ -1,67 +1,19 @@ - - - - - - - -Create a Dirichlet Mixture of Gaussians — DirichletProcessGaussian • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Create a Dirichlet Mixture of Gaussians — DirichletProcessGaussian • dirichletprocess - + - -
-
- - -
-
+
-

This is the constructor function to produce a dirichletprocess object with a Gaussian mixture kernel with unknown mean and variance. The base measure is a Normal Inverse Gamma distribution that is conjugate to the posterior distribution.

-
-
DirichletProcessGaussian(y, g0Priors = c(0, 1, 1, 1),
-  alphaPriors = c(2, 4))
- -

Arguments

- - - - - - - - - - - - - - -
y

Data

g0Priors

Base Distribution Priors \(\gamma = (\mu _0, k_0 , \alpha _0 , \beta _0)\)

alphaPriors

Alpha prior parameters. See UpdateAlpha.

- -

Value

+
+
DirichletProcessGaussian(y, g0Priors = c(0, 1, 1, 1), alphaPriors = c(2, 4))
+
+ +
+

Arguments

+ + +
y
+

Data

-

Dirichlet process object

- -

Details

+
g0Priors
+

Base Distribution Priors \(\gamma = (\mu _0, k_0 , \alpha _0 , \beta _0)\)

+ + +
alphaPriors
+

Alpha prior parameters. See UpdateAlpha.

+ +
+
+

Value

+

Dirichlet process object

+
+
+

Details

\(G_0(\theta | \gamma) = N \left(\mu | \mu_0, \frac{\sigma^2}{k_0} \right) \mathrm{Inv-Gamma} \left(\sigma^2 | \alpha_0, \beta_0 \right)\)

We recommend scaling your data to zero mean and unit variance for quicker convergence.

- +
+
-
- +
+ + - - - + diff --git a/docs/reference/DirichletProcessGaussianFixedVariance.html b/docs/reference/DirichletProcessGaussianFixedVariance.html index 0bb7696..bfcac2b 100644 --- a/docs/reference/DirichletProcessGaussianFixedVariance.html +++ b/docs/reference/DirichletProcessGaussianFixedVariance.html @@ -1,66 +1,18 @@ - - - - - - - -Create a Dirichlet Mixture of the Gaussian Distribution with fixed variance. — DirichletProcessGaussianFixedVariance • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Create a Dirichlet Mixture of the Gaussian Distribution with fixed variance. — DirichletProcessGaussianFixedVariance • dirichletprocess - + - -
-
- - -
-
+
-

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

-
-
DirichletProcessGaussianFixedVariance(y, sigma, g0Priors = c(0, 1),
-  alphaPriors = c(2, 4))
- -

Arguments

- - - - - - - - - - - - - - - - - - -
y

Data.

sigma

The fixed variance

g0Priors

Base Distribution Priors.

alphaPriors

Prior parameter distributions for the alpha concentration parameter.

- -

Value

+
+
DirichletProcessGaussianFixedVariance(
+  y,
+  sigma,
+  g0Priors = c(0, 1),
+  alphaPriors = c(2, 4)
+)
+
+ +
+

Arguments

+ + +
y
+

Data.

+ +
sigma
+

The fixed variance

+ + +
g0Priors
+

Base Distribution Priors.

+ + +
alphaPriors
+

Prior parameter distributions for the alpha concentration parameter.

+ +
+
+

Value

Dirichlet process object

- +
+
-
- +
+ + - - - + diff --git a/docs/reference/DirichletProcessHierarchicalBeta.html b/docs/reference/DirichletProcessHierarchicalBeta.html index 6901302..53dbf44 100644 --- a/docs/reference/DirichletProcessHierarchicalBeta.html +++ b/docs/reference/DirichletProcessHierarchicalBeta.html @@ -1,66 +1,18 @@ - - - - - - - -Create a Hierarchical Dirichlet Mixture of Beta Distributions — DirichletProcessHierarchicalBeta • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Create a Hierarchical Dirichlet Mixture of Beta Distributions — DirichletProcessHierarchicalBeta • dirichletprocess + - - -
-
- - -
-
+
-

Create a Hierarchical Dirichlet Mixture of Beta Distributions

-
-
DirichletProcessHierarchicalBeta(dataList, maxY, priorParameters = c(2,
-  8), hyperPriorParameters = c(1, 0.125), gammaPriors = c(2, 4),
-  alphaPriors = c(2, 4), mhStepSize = c(0.1, 0.1), numSticks = 50,
-  mhDraws = 250)
- -

Arguments

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
dataList

List of data for each separate Dirichlet mixture object

maxY

Maximum value for the Beta distribution.

priorParameters

Prior Parameters for the top level base distribution.

hyperPriorParameters

Hyper prior parameters for the top level base distribution.

gammaPriors

Prior parameters for the top level concentration parameter.

alphaPriors

Prior parameters for the individual parameters.

mhStepSize

Metropolis Hastings jump size.

numSticks

Truncation level for the Stick Breaking formulation.

mhDraws

Number of Metropolis-Hastings samples to perform for each cluster update.

- -

Value

+
+
DirichletProcessHierarchicalBeta(
+  dataList,
+  maxY,
+  priorParameters = c(2, 8),
+  hyperPriorParameters = c(1, 0.125),
+  gammaPriors = c(2, 4),
+  alphaPriors = c(2, 4),
+  mhStepSize = c(0.1, 0.1),
+  numSticks = 50,
+  mhDraws = 250
+)
+
+
+

Arguments

+ + +
dataList
+

List of data for each separate Dirichlet mixture object

+ + +
maxY
+

Maximum value for the Beta distribution.

+ + +
priorParameters
+

Prior Parameters for the top level base distribution.

+ + +
hyperPriorParameters
+

Hyper prior parameters for the top level base distribution.

+ + +
gammaPriors
+

Prior parameters for the top level concentration parameter.

+ + +
alphaPriors
+

Prior parameters for the individual parameters.

+ + +
mhStepSize
+

Metropolis Hastings jump size.

+ + +
numSticks
+

Truncation level for the Stick Breaking formulation.

+ + +
mhDraws
+

Number of Metropolis-Hastings samples to perform for each cluster update.

+ +
+
+

Value

dpobjlist A Hierarchical Dirichlet Process object that can be fitted, plotted etc.

- +
+
-
- +
+ + - - - + diff --git a/docs/reference/DirichletProcessHierarchicalMvnormal2.html b/docs/reference/DirichletProcessHierarchicalMvnormal2.html index 873d6f0..3652fa6 100644 --- a/docs/reference/DirichletProcessHierarchicalMvnormal2.html +++ b/docs/reference/DirichletProcessHierarchicalMvnormal2.html @@ -1,69 +1,19 @@ - - - - - - - -Create a Hierarchical Dirichlet Mixture of -semi-conjugate Multivariate Normal Distributions — DirichletProcessHierarchicalMvnormal2 • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Create a Hierarchical Dirichlet Mixture of semi-conjugate Multivariate Normal Distributions — DirichletProcessHierarchicalMvnormal2 • dirichletprocess - + - -
-
- - -
-
+
-

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

-
-
DirichletProcessHierarchicalMvnormal2(dataList, g0Priors,
-  gammaPriors = c(2, 4), alphaPriors = c(2, 4), numSticks = 50,
-  numInitialClusters = 1, mhDraws = 250)
- -

Arguments

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
dataList

List of data for each separate Dirichlet mixture object

g0Priors

Prior Parameters for the top level base distribution.

gammaPriors

Prior parameters for the top level concentration parameter.

alphaPriors

Prior parameters for the individual parameters.

numSticks

Truncation level for the Stick Breaking formulation.

numInitialClusters

Number of clusters to initialise with.

mhDraws

Number of Metropolis-Hastings samples to perform for each cluster update.

- -

Value

+
+
DirichletProcessHierarchicalMvnormal2(
+  dataList,
+  g0Priors,
+  gammaPriors = c(2, 4),
+  alphaPriors = c(2, 4),
+  numSticks = 50,
+  numInitialClusters = 1,
+  mhDraws = 250
+)
+
+ +
+

Arguments

+ + +
dataList
+

List of data for each separate Dirichlet mixture object

+ + +
g0Priors
+

Prior Parameters for the top level base distribution.

+ + +
gammaPriors
+

Prior parameters for the top level concentration parameter.

+ + +
alphaPriors
+

Prior parameters for the individual parameters.

+ +
numSticks
+

Truncation level for the Stick Breaking formulation.

+ + +
numInitialClusters
+

Number of clusters to initialise with.

+ + +
mhDraws
+

Number of Metropolis-Hastings samples to perform for each cluster update.

+ +
+
+

Value

dpobjlist A Hierarchical Dirichlet Process object that can be fitted, plotted etc.

- +
+
-
- +
+ + - - - + diff --git a/docs/reference/DirichletProcessMvnormal.html b/docs/reference/DirichletProcessMvnormal.html index f1cebdc..be04cb6 100644 --- a/docs/reference/DirichletProcessMvnormal.html +++ b/docs/reference/DirichletProcessMvnormal.html @@ -1,66 +1,18 @@ - - - - - - - -Create a Dirichlet mixture of multivariate normal distributions. — DirichletProcessMvnormal • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Create a Dirichlet mixture of multivariate normal distributions. — DirichletProcessMvnormal • dirichletprocess - + - -
-
- - -
-
+
-

\(G_0 (\boldsymbol{\mu} , \Lambda | \boldsymbol{\mu _0} , \kappa _0, \nu _0, T_0) = N ( \boldsymbol{\mu} | \boldsymbol{\mu _0} , (\kappa _0 \Lambda )^{-1} ) \mathrm{Wi} _{\nu _0} (\Lambda | T_0)\)

-
-
DirichletProcessMvnormal(y, g0Priors, alphaPriors = c(2, 4),
-  numInitialClusters = 1)
- -

Arguments

- - - - - - - - - - - - - - - - - - -
y

Data

g0Priors

Prior parameters for the base distribution.

alphaPriors

Alpha prior parameters. See UpdateAlpha.

numInitialClusters

Number of clusters to initialise with.

- +
+
DirichletProcessMvnormal(
+  y,
+  g0Priors,
+  alphaPriors = c(2, 4),
+  numInitialClusters = 1
+)
+
+ +
+

Arguments

+ + +
y
+

Data

+ + +
g0Priors
+

Prior parameters for the base distribution.

+ + +
alphaPriors
+

Alpha prior parameters. See UpdateAlpha.

+ + +
numInitialClusters
+

Number of clusters to initialise with.

+ +
+
-
- +
+ + - - - + diff --git a/docs/reference/DirichletProcessMvnormal2.html b/docs/reference/DirichletProcessMvnormal2.html index c270b21..9626295 100644 --- a/docs/reference/DirichletProcessMvnormal2.html +++ b/docs/reference/DirichletProcessMvnormal2.html @@ -1,66 +1,18 @@ - - - - - - - -Create a Dirichlet mixture of multivariate normal distributions with semi-conjugate prior. — DirichletProcessMvnormal2 • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Create a Dirichlet mixture of multivariate normal distributions with semi-conjugate prior. — DirichletProcessMvnormal2 • dirichletprocess + - - -
-
- - -
-
+
-

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

-
-
DirichletProcessMvnormal2(y, g0Priors, alphaPriors = c(2, 4))
- -

Arguments

- - - - - - - - - - - - - - -
y

Data

g0Priors

Prior parameters for the base distribution.

alphaPriors

Alpha prior parameters. See UpdateAlpha.

- +
+
DirichletProcessMvnormal2(y, g0Priors, alphaPriors = c(2, 4))
+
+ +
+

Arguments

+ + +
y
+

Data

+ + +
g0Priors
+

Prior parameters for the base distribution.

+ + +
alphaPriors
+

Alpha prior parameters. See UpdateAlpha.

+ +
+
-
- +
+ + - - - + diff --git a/docs/reference/DirichletProcessWeibull.html b/docs/reference/DirichletProcessWeibull.html index 253cc41..14969c4 100644 --- a/docs/reference/DirichletProcessWeibull.html +++ b/docs/reference/DirichletProcessWeibull.html @@ -1,71 +1,23 @@ - - - - - - - -Create a Dirichlet Mixture of the Weibull distribution — DirichletProcessWeibull • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Create a Dirichlet Mixture of the Weibull distribution — DirichletProcessWeibull • dirichletprocess - - - - - - - - - - + - - -
-
- - -
-
+
-

The likelihood is parameterised as \(\mathrm{Weibull} (y | a, b) = \frac{a}{b} y ^{a-1} \exp \left( - \frac{x^a}{b} \right)\). The base measure is a Uniform Inverse Gamma Distribution. \(G_0 (a, b | \phi, \alpha _0 , \beta _0) = U(a | 0, \phi ) \mathrm{Inv-Gamma} ( b | \alpha _0, \beta _0)\) \(\phi \sim \mathrm{Pareto}(x_m , k)\) \(\beta \sim \mathrm{Gamma} (\alpha _0 , \beta _0)\) This is a semi-conjugate distribution. The cluster parameter a is updated using the Metropolis Hastings algorithm an analytical posterior exists for b.

-
-
DirichletProcessWeibull(y, g0Priors, alphaPriors = c(2, 4),
-  mhStepSize = c(1, 1), hyperPriorParameters = c(6, 2, 1, 0.5),
-  verbose = FALSE, mhDraws = 250)
- -

Arguments

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
y

Data.

g0Priors

Base Distribution Priors.

alphaPriors

Prior for the concentration parameter.

mhStepSize

Step size for the new parameter in the Metropolis Hastings algorithm.

hyperPriorParameters

Hyper prior parameters.

verbose

Set the level of screen output.

mhDraws

Number of Metropolis-Hastings samples to perform for each cluster update.

- -

Value

+
+
DirichletProcessWeibull(
+  y,
+  g0Priors,
+  alphaPriors = c(2, 4),
+  mhStepSize = c(1, 1),
+  hyperPriorParameters = c(6, 2, 1, 0.5),
+  verbose = FALSE,
+  mhDraws = 250
+)
+
+ +
+

Arguments

+ + +
y
+

Data.

+ + +
g0Priors
+

Base Distribution Priors.

+ + +
alphaPriors
+

Prior for the concentration parameter.

+ + +
mhStepSize
+

Step size for the new parameter in the Metropolis Hastings algorithm.

-

Dirichlet process object

- -

References

+
hyperPriorParameters
+

Hyper prior parameters.

+ + +
verbose
+

Set the level of screen output.

+ + +
mhDraws
+

Number of Metropolis-Hastings samples to perform for each cluster update.

+ +
+
+

Value

+

Dirichlet process object

+
+
+

References

Kottas, A. (2006). Nonparametric Bayesian survival analysis using mixtures of Weibull distributions. Journal of Statistical Planning and Inference, 136(3), 578-596.

- +
+
-
- +
+ + - - - + diff --git a/docs/reference/ExponentialMixtureCreate.html b/docs/reference/ExponentialMixtureCreate.html index ec7f24d..ad9d2f9 100644 --- a/docs/reference/ExponentialMixtureCreate.html +++ b/docs/reference/ExponentialMixtureCreate.html @@ -1,66 +1,18 @@ - - - - - - - -Create a Exponential mixing distribution — ExponentialMixtureCreate • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Create a Exponential mixing distribution — ExponentialMixtureCreate • dirichletprocess + - - -
-
- - -
-
+
- -

See DirichletProcessExponential for details on the base measure.

- +

See DirichletProcessExponential for details on the base measure.

-
ExponentialMixtureCreate(priorParameters = c(0.01, 0.01))
- -

Arguments

- - - - - - -
priorParameters

Prior parameters for the base measure.

- -

Value

+
+
ExponentialMixtureCreate(priorParameters = c(0.01, 0.01))
+
+
+

Arguments

+ + +
priorParameters
+

Prior parameters for the base measure.

+ +
+
+

Value

Mixing distribution object

- +
+
-
- +
+ + - - - + diff --git a/docs/reference/Fit.html b/docs/reference/Fit.html index 5cbcdc9..9470471 100644 --- a/docs/reference/Fit.html +++ b/docs/reference/Fit.html @@ -1,68 +1,20 @@ - - - - - - - -Fit the Dirichlet process object — Fit • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Fit the Dirichlet process object — Fit • dirichletprocess - - - - - - - - - - + - - -
-
- - -
-
+
-

Using Neal's algorithm 4 or 8 depending on conjugacy the sampling procedure for a Dirichlet process is carried out. Lists of both cluster parameters, weights and the sampled concentration values are included in the fitted dpObj. When update_prior is set to TRUE the parameters of the base measure are also updated.

-
-
Fit(dpObj, its, updatePrior = FALSE, progressBar = TRUE)
- -

Arguments

- - - - - - - - - - - - - - - - - - -
dpObj

Initialised Dirichlet Process object

its

Number of iterations to use

updatePrior

Logical flag, defaults to FAlSE. Set whether the parameters of the base measure are updated.

progressBar

Logical flag indicating whether to display a progress bar.

- -

Value

+
+
Fit(dpObj, its, updatePrior = FALSE, progressBar = TRUE)
+
+ +
+

Arguments

+ + +
dpObj
+

Initialised Dirichlet Process object

+ + +
its
+

Number of iterations to use

-

A Dirichlet Process object with the fitted cluster parameters and labels.

- -

References

+
updatePrior
+

Logical flag, defaults to FAlSE. Set whether the parameters of the base measure are updated.

+ + +
progressBar
+

Logical flag indicating whether to display a progress bar.

+ +
+
+

Value

+

A Dirichlet Process object with the fitted cluster parameters and labels.

+
+
+

References

Neal, R. M. (2000). Markov chain sampling methods for Dirichlet process mixture models. Journal of computational and graphical statistics, 9(2), 249-265.

- +
+
-
- +
+ + - - - + diff --git a/docs/reference/Fit.markov.html b/docs/reference/Fit.markov.html index f541fb3..f4ef841 100644 --- a/docs/reference/Fit.markov.html +++ b/docs/reference/Fit.markov.html @@ -1,66 +1,18 @@ - - - - - - - -Fit a Hidden Markov Dirichlet Process Model — Fit.markov • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Fit a Hidden Markov Dirichlet Process Model — Fit.markov • dirichletprocess - + - -
-
- - -
-
+
-

Fit a Hidden Markov Dirichlet Process Model

-
-
# S3 method for markov
-Fit(dpObj, its, updatePrior = F, progressBar = F)
- -

Arguments

- - - - - - - - - - - - - - - - - - -
dpObj

Initialised Dirichlet Process object

its

Number of iterations to use

updatePrior

Logical flag, defaults to FAlSE. Set whether the parameters of the base measure are updated.

progressBar

Logical flag indicating whether to display a progress bar.

- -

Value

+
+
# S3 method for class 'markov'
+Fit(dpObj, its, updatePrior = F, progressBar = F)
+
+ +
+

Arguments

+ + +
dpObj
+

Initialised Dirichlet Process object

+ +
its
+

Number of iterations to use

+ + +
updatePrior
+

Logical flag, defaults to FAlSE. Set whether the parameters of the base measure are updated.

+ + +
progressBar
+

Logical flag indicating whether to display a progress bar.

+ +
+
+

Value

A Dirichlet Process object with the fitted cluster parameters and states.

- +
+
-
- +
+ + - - - + diff --git a/docs/reference/GaussianFixedVarianceMixtureCreate.html b/docs/reference/GaussianFixedVarianceMixtureCreate.html index e77d40b..c563ce9 100644 --- a/docs/reference/GaussianFixedVarianceMixtureCreate.html +++ b/docs/reference/GaussianFixedVarianceMixtureCreate.html @@ -1,66 +1,18 @@ - - - - - - - -Create a Gaussian Mixing Distribution with fixed variance. — GaussianFixedVarianceMixtureCreate • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Create a Gaussian Mixing Distribution with fixed variance. — GaussianFixedVarianceMixtureCreate • dirichletprocess - + - -
-
- - -
-
+
-

Create a Gaussian Mixing Distribution with fixed variance.

-
-
GaussianFixedVarianceMixtureCreate(priorParameters = c(0, 1), sigma)
- -

Arguments

- - - - - - - - - - -
priorParameters

The prior parameters for the base measure.

sigma

The fixed variance of the model.

- -

Value

+
+
GaussianFixedVarianceMixtureCreate(priorParameters = c(0, 1), sigma)
+
+ +
+

Arguments

+ +
priorParameters
+

The prior parameters for the base measure.

+ + +
sigma
+

The fixed variance of the model.

+ +
+
+

Value

A mixing distribution object.

- +
+
-
- +
+ + - - - + diff --git a/docs/reference/GaussianMixtureCreate.html b/docs/reference/GaussianMixtureCreate.html index 35ec1d9..1a01507 100644 --- a/docs/reference/GaussianMixtureCreate.html +++ b/docs/reference/GaussianMixtureCreate.html @@ -1,66 +1,18 @@ - - - - - - - -Create a Normal mixing distribution — GaussianMixtureCreate • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Create a Normal mixing distribution — GaussianMixtureCreate • dirichletprocess + - - -
-
- - -
-
+
- -

See DirichletProcessGaussian for details on the base measure.

- +

See DirichletProcessGaussian for details on the base measure.

-
GaussianMixtureCreate(priorParameters = c(0, 1, 1, 1))
- -

Arguments

- - - - - - -
priorParameters

Prior parameters for the base measure.

- -

Value

+
+
GaussianMixtureCreate(priorParameters = c(0, 1, 1, 1))
+
+
+

Arguments

+ + +
priorParameters
+

Prior parameters for the base measure.

+ +
+
+

Value

Mixing distribution object

- +
+
-
- +
+ + - - - + diff --git a/docs/reference/GlobalParameterUpdate.html b/docs/reference/GlobalParameterUpdate.html index ca88364..afe1067 100644 --- a/docs/reference/GlobalParameterUpdate.html +++ b/docs/reference/GlobalParameterUpdate.html @@ -1,66 +1,18 @@ - - - - - - - -Update the parameters of the hierarchical Dirichlet process object. — GlobalParameterUpdate • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Update the parameters of the hierarchical Dirichlet process object. — GlobalParameterUpdate • dirichletprocess + - - -
-
- - -
-
+
-

Update the parameters of the hierarchical Dirichlet process object.

-
-
GlobalParameterUpdate(dpobjlist)
- -

Arguments

- - - - - - -
dpobjlist

List of Dirichlet Process objects.

- +
+
GlobalParameterUpdate(dpobjlist)
+
+ +
+

Arguments

+ + +
dpobjlist
+

List of Dirichlet Process objects.

+ +
+
-
- +
+ + - - - + diff --git a/docs/reference/HierarchicalBetaCreate.html b/docs/reference/HierarchicalBetaCreate.html index 504065d..76ab113 100644 --- a/docs/reference/HierarchicalBetaCreate.html +++ b/docs/reference/HierarchicalBetaCreate.html @@ -1,66 +1,18 @@ - - - - - - - -Create a Mixing Object for a hierarchical Beta Dirichlet process object. — HierarchicalBetaCreate • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Create a Mixing Object for a hierarchical Beta Dirichlet process object. — HierarchicalBetaCreate • dirichletprocess + - - -
-
- - -
-
+
-

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

-
-
HierarchicalBetaCreate(n, priorParameters, hyperPriorParameters,
-  alphaPrior, maxT, gammaPrior, mhStepSize, num_sticks)
- -

Arguments

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
n

Number of data sets

priorParameters

The prior parameters for the top level base distribution.

hyperPriorParameters

Hyper prior parameters for the top level base distribution.

alphaPrior

Individual level concentration parameter priors.

maxT

Bounding value of the data.

gammaPrior

Concentration parameter for the top level priors.

mhStepSize

Metropolis Hastings step size for the posterior drawing.

num_sticks

Number of stick breaking values to use.

- -

Value

+
+
HierarchicalBetaCreate(
+  n,
+  priorParameters,
+  hyperPriorParameters,
+  alphaPrior,
+  maxT,
+  gammaPrior,
+  mhStepSize,
+  num_sticks
+)
+
+ +
+

Arguments

+ + +
n
+

Number of data sets

+ + +
priorParameters
+

The prior parameters for the top level base distribution.

+ + +
hyperPriorParameters
+

Hyper prior parameters for the top level base distribution.

+ + +
alphaPrior
+

Individual level concentration parameter priors.

+ +
maxT
+

Bounding value of the data.

+ + +
gammaPrior
+

Concentration parameter for the top level priors.

+ + +
mhStepSize
+

Metropolis Hastings step size for the posterior drawing.

+ + +
num_sticks
+

Number of stick breaking values to use.

+ +
+
+

Value

A mixing distribution object.

- +
+
-
- +
+ + - - - + diff --git a/docs/reference/HierarchicalMvnormal2Create.html b/docs/reference/HierarchicalMvnormal2Create.html index 79d3c27..7e7497f 100644 --- a/docs/reference/HierarchicalMvnormal2Create.html +++ b/docs/reference/HierarchicalMvnormal2Create.html @@ -1,69 +1,19 @@ - - - - - - - -Create a Mixing Object for a hierarchical semi-conjugate -Multivariate Normal Dirichlet process object. — HierarchicalMvnormal2Create • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Create a Mixing Object for a hierarchical semi-conjugate Multivariate Normal Dirichlet process object. — HierarchicalMvnormal2Create • dirichletprocess + - - -
-
- - -
-
+
-

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

-
-
HierarchicalMvnormal2Create(n, priorParameters, alphaPrior, gammaPrior,
-  num_sticks)
- -

Arguments

- - - - - - - - - - - - - - - - - - - - - - -
n

Number of data sets

priorParameters

The prior parameters for the top level base distribution.

alphaPrior

Individual level concentration parameter priors.

gammaPrior

Concentration parameter for the top level priors.

num_sticks

Number of stick breaking values to use.

- -

Value

+
+
HierarchicalMvnormal2Create(
+  n,
+  priorParameters,
+  alphaPrior,
+  gammaPrior,
+  num_sticks
+)
+
+ +
+

Arguments

+ + +
n
+

Number of data sets

+ + +
priorParameters
+

The prior parameters for the top level base distribution.

+ +
alphaPrior
+

Individual level concentration parameter priors.

+ + +
gammaPrior
+

Concentration parameter for the top level priors.

+ + +
num_sticks
+

Number of stick breaking values to use.

+ +
+
+

Value

A mixing distribution object.

- +
+
-
- +
+ + - - - + diff --git a/docs/reference/Initialise.html b/docs/reference/Initialise.html index a08c357..71ed527 100644 --- a/docs/reference/Initialise.html +++ b/docs/reference/Initialise.html @@ -1,66 +1,18 @@ - - - - - - - -Initialise a Dirichlet process object — Initialise • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Initialise a Dirichlet process object — Initialise • dirichletprocess + - - -
-
- - -
-
+
-

Initialise a Dirichlet process object by assigning all the data points to a single cluster with a posterior or prior draw for parameters.

-
-
Initialise(dpObj, posterior = TRUE, m = 3, verbose = TRUE,
-  numInitialClusters = 1)
- -

Arguments

- - - - - - - - - - - - - - - - - - - - - - -
dpObj

A Dirichlet process object.

posterior

TRUE/FALSE value for whether the cluster parameters should be from the posterior. If false then the values are from the prior.

m

Number of auxiliary variables to use for a non-conjugate mixing distribution. Defaults to m=3. See ClusterComponentUpdate for more details on m.

verbose

Logical flag indicating whether to output the acceptance ratio for non-conjugate mixtures.

numInitialClusters

Number of clusters to initialise with.

- -

Value

+
+
Initialise(
+  dpObj,
+  posterior = TRUE,
+  m = 3,
+  verbose = TRUE,
+  numInitialClusters = 1
+)
+
+ +
+

Arguments

+ + +
dpObj
+

A Dirichlet process object.

+ + +
posterior
+

TRUE/FALSE value for whether the cluster parameters should be from the posterior. If false then the values are from the prior.

+ +
m
+

Number of auxiliary variables to use for a non-conjugate mixing distribution. Defaults to m=3. See ClusterComponentUpdate for more details on m.

+ + +
verbose
+

Logical flag indicating whether to output the acceptance ratio for non-conjugate mixtures.

+ + +
numInitialClusters
+

Number of clusters to initialise with.

+ +
+
+

Value

A Dirichlet process object that has initial cluster allocations.

- +
+
-
- +
+ + - - - + diff --git a/docs/reference/Likelihood.html b/docs/reference/Likelihood.html index cf5cdf2..19a45eb 100644 --- a/docs/reference/Likelihood.html +++ b/docs/reference/Likelihood.html @@ -1,66 +1,18 @@ - - - - - - - -Mixing Distribution Likelihood — Likelihood.beta • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Mixing Distribution Likelihood — Likelihood.beta • dirichletprocess + - - -
-
- - -
-
+
-

Evaluate the Likelihood of some data \(x\) for some parameter \(\theta\).

-
-
# S3 method for beta
-Likelihood(mdObj, x, theta)
-
-# S3 method for beta2
-Likelihood(mdObj, x, theta)
-
-# S3 method for exponential
-Likelihood(mdObj, x, theta)
-
-Likelihood(mdObj, x, theta)
-
-# S3 method for mvnormal
-Likelihood(mdObj, x, theta)
-
-# S3 method for mvnormal2
-Likelihood(mdObj, x, theta)
-
-# S3 method for normalFixedVariance
-Likelihood(mdObj, x, theta)
-
-# S3 method for normal
-Likelihood(mdObj, x, theta)
- -

Arguments

- - - - - - - - - - - - - - -
mdObj

Mixing Distribution

x

Data

theta

Parameters of distribution

- -

Value

+
+
# S3 method for class 'beta'
+Likelihood(mdObj, x, theta)
+
+# S3 method for class 'beta2'
+Likelihood(mdObj, x, theta)
+
+# S3 method for class 'exponential'
+Likelihood(mdObj, x, theta)
+
+Likelihood(mdObj, x, theta)
+
+# S3 method for class 'mvnormal'
+Likelihood(mdObj, x, theta)
+
+# S3 method for class 'mvnormal2'
+Likelihood(mdObj, x, theta)
+
+# S3 method for class 'normalFixedVariance'
+Likelihood(mdObj, x, theta)
+
+# S3 method for class 'normal'
+Likelihood(mdObj, x, theta)
+
+ +
+

Arguments

+ + +
mdObj
+

Mixing Distribution

+ +
x
+

Data

+ + +
theta
+

Parameters of distribution

+ +
+
+

Value

Likelihood of the data

- +
+
-
- +
+ + - - - + diff --git a/docs/reference/LikelihoodDP.html b/docs/reference/LikelihoodDP.html index e5ea3b6..9ff4bf5 100644 --- a/docs/reference/LikelihoodDP.html +++ b/docs/reference/LikelihoodDP.html @@ -1,66 +1,18 @@ - - - - - - - -The likelihood of the Dirichlet process object — LikelihoodDP • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -The likelihood of the Dirichlet process object — LikelihoodDP • dirichletprocess + - - -
-
- - -
-
+
-

Calculate the likelihood of each data point with its parameter.

-
-
LikelihoodDP(dpobj)
- -

Arguments

- - - - - - -
dpobj

The dirichletprocess object on which to calculate the likelihood.

- +
+
LikelihoodDP(dpobj)
+
+ +
+

Arguments

+ + +
dpobj
+

The dirichletprocess object on which to calculate the likelihood.

+ +
+
-
- +
+ + - - - + diff --git a/docs/reference/LikelihoodFunction-1.png b/docs/reference/LikelihoodFunction-1.png index e545b32..073e858 100644 Binary files a/docs/reference/LikelihoodFunction-1.png and b/docs/reference/LikelihoodFunction-1.png differ diff --git a/docs/reference/LikelihoodFunction.html b/docs/reference/LikelihoodFunction.html index 7dafb0d..a6f7b0b 100644 --- a/docs/reference/LikelihoodFunction.html +++ b/docs/reference/LikelihoodFunction.html @@ -1,67 +1,19 @@ - - - - - - - -The Likelihood function of a Dirichlet process object. — LikelihoodFunction • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -The Likelihood function of a Dirichlet process object. — LikelihoodFunction • dirichletprocess + - - -
-
- - -
-
+
-

Collecting the fitted cluster parameters and number of datapoints associated with each parameter a likelihood can be calculated. Each cluster is weighted by the number of datapoints assigned.

-
-
LikelihoodFunction(dpobj, ind)
- -

Arguments

- - - - - - - - - - -
dpobj

Dirichlet process object.

ind

The iteration number. Defaults to the last iteration.

- -

Value

+
+
LikelihoodFunction(dpobj, ind)
+
+ +
+

Arguments

+ + +
dpobj
+

Dirichlet process object.

+ +
ind
+

The iteration number. Defaults to the last iteration.

+ +
+
+

Value

A function f(x) that represents the Likelihood of the dpobj.

- - -

Examples

-
y <- rnorm(10) -dp <- DirichletProcessGaussian(y) -dp <- Fit(dp, 5) -f <- LikelihoodFunction(dp) -plot(f(-2:2)) -
-
+
+ +
+

Examples

+
y <- rnorm(10)
+dp <- DirichletProcessGaussian(y)
+dp <- Fit(dp, 5)
+f <- LikelihoodFunction(dp)
+plot(f(-2:2))
+
+
+
+
+
-
- +
+ + - - - + diff --git a/docs/reference/MixingDistribution.html b/docs/reference/MixingDistribution.html index 2e620bb..bed5a14 100644 --- a/docs/reference/MixingDistribution.html +++ b/docs/reference/MixingDistribution.html @@ -1,67 +1,19 @@ - - - - - - - -Create a mixing distribution object — MixingDistribution • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Create a mixing distribution object — MixingDistribution • dirichletprocess + - - -
-
- - -
-
+
-

The constructor function for a mixing distribution object. Use this function to prepare an object for use with the appropriate distribution functions.

-
-
MixingDistribution(distribution, priorParameters, conjugate,
-  mhStepSize = NULL, hyperPriorParameters = NULL)
- -

Arguments

- - - - - - - - - - - - - - - - - - - - - - -
distribution

The name of the distribution mixture

priorParameters

The prior parameters

conjugate

Whether the prior is conjugate to the Likelihood.

mhStepSize

The scale of the proposal parameter for the Metropolis Hastings algorithm. Not needed for conjugate mixtures.

hyperPriorParameters

Vector of hyperPriorParameters for the distribution.

- +
+
MixingDistribution(
+  distribution,
+  priorParameters,
+  conjugate,
+  mhStepSize = NULL,
+  hyperPriorParameters = NULL
+)
+
+ +
+

Arguments

+ + +
distribution
+

The name of the distribution mixture

+ + +
priorParameters
+

The prior parameters

+ + +
conjugate
+

Whether the prior is conjugate to the Likelihood.

+ + +
mhStepSize
+

The scale of the proposal parameter for the Metropolis Hastings algorithm. Not needed for conjugate mixtures.

+ + +
hyperPriorParameters
+

Vector of hyperPriorParameters for the distribution.

+ +
+
-
- +
+ + - - - + diff --git a/docs/reference/Mvnormal2Create.html b/docs/reference/Mvnormal2Create.html index cf181e0..099f10f 100644 --- a/docs/reference/Mvnormal2Create.html +++ b/docs/reference/Mvnormal2Create.html @@ -1,66 +1,18 @@ - - - - - - - -Create a multivariate normal mixing distribution with semi conjugate prior — Mvnormal2Create • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Create a multivariate normal mixing distribution with semi conjugate prior — Mvnormal2Create • dirichletprocess + - - -
-
- - -
-
+
-

Create a multivariate normal mixing distribution with semi conjugate prior

-
-
Mvnormal2Create(priorParameters)
- -

Arguments

- - - - - - -
priorParameters

The prior parameters for the Multivariate Normal.

- +
+
Mvnormal2Create(priorParameters)
+
+ +
+

Arguments

+ + +
priorParameters
+

The prior parameters for the Multivariate Normal.

+ +
+
-
- +
+ + - - - + diff --git a/docs/reference/MvnormalCreate.html b/docs/reference/MvnormalCreate.html index 2c3f77b..dfcafc9 100644 --- a/docs/reference/MvnormalCreate.html +++ b/docs/reference/MvnormalCreate.html @@ -1,66 +1,18 @@ - - - - - - - -Create a multivariate normal mixing distribution — MvnormalCreate • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Create a multivariate normal mixing distribution — MvnormalCreate • dirichletprocess + - - -
-
- - -
-
+
-

Create a multivariate normal mixing distribution

-
-
MvnormalCreate(priorParameters)
- -

Arguments

- - - - - - -
priorParameters

The prior parameters for the Multivariate Normal.

- +
+
MvnormalCreate(priorParameters)
+
+ +
+

Arguments

+ + +
priorParameters
+

The prior parameters for the Multivariate Normal.

+ +
+
-
- +
+ + - - - + diff --git a/docs/reference/PenalisedLikelihood.html b/docs/reference/PenalisedLikelihood.html index 3021e39..e492358 100644 --- a/docs/reference/PenalisedLikelihood.html +++ b/docs/reference/PenalisedLikelihood.html @@ -1,67 +1,19 @@ - - - - - - - -Calculate the parameters that maximise the penalised likelihood. — PenalisedLikelihood.beta • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Calculate the parameters that maximise the penalised likelihood. — PenalisedLikelihood.beta • dirichletprocess - + - -
-
- - -
-
+
-

Used to find suitable starting parameters for nonconjugate mixtures. For some mixing distributions this hasn't been implemented yet.

-
-
# S3 method for beta
-PenalisedLikelihood(mdObj, x)
-
-PenalisedLikelihood(mdObj, x)
-
-# S3 method for default
-PenalisedLikelihood(mdObj, x)
- -

Arguments

- - - - - - - - - - -
mdObj

Mixing distribution object

x

Data

- +
+
# S3 method for class 'beta'
+PenalisedLikelihood(mdObj, x)
+
+PenalisedLikelihood(mdObj, x)
+
+# Default S3 method
+PenalisedLikelihood(mdObj, x)
+
+ +
+

Arguments

+ + +
mdObj
+

Mixing distribution object

+ + +
x
+

Data

+ +
+
-
- +
+ + - - - + diff --git a/docs/reference/PosteriorClusters.html b/docs/reference/PosteriorClusters.html index 46d8f20..d700142 100644 --- a/docs/reference/PosteriorClusters.html +++ b/docs/reference/PosteriorClusters.html @@ -1,67 +1,19 @@ - - - - - - - -Generate the posterior clusters of a Dirichlet Process — PosteriorClusters • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Generate the posterior clusters of a Dirichlet Process — PosteriorClusters • dirichletprocess + - - -
-
- - -
-
+
-

Using the stick breaking representation the user can draw the posterior clusters and weights for a fitted Dirichlet Process. -See also PosteriorFunction.

- +See also PosteriorFunction.

-
PosteriorClusters(dpobj, ind)
- -

Arguments

- - - - - - - - - - -
dpobj

Fitted Dirichlet process

ind

Index for which the posterior will be drawn from. Defaults to the last iteration of the fit.

- -

Value

+
+
PosteriorClusters(dpobj, ind)
+
-

A list with the weights and cluster parameters that form the posterior of the Dirichlet process.

- +
+

Arguments

+ + +
dpobj
+

Fitted Dirichlet process

-

Examples

-
y <- rnorm(10) -dp <- DirichletProcessGaussian(y) -dp <- Fit(dp, 5) -postClusters <- PosteriorClusters(dp) -
+
ind
+

Index for which the posterior will be drawn from. Defaults to the last iteration of the fit.

+ +
+
+

Value

+

A list with the weights and cluster parameters that form the posterior of the Dirichlet process.

+
+ +
+

Examples

+
y <- rnorm(10)
+dp <- DirichletProcessGaussian(y)
+dp <- Fit(dp, 5)
+postClusters <- PosteriorClusters(dp)
+
+
+
+
-
- +
+ + - - - + diff --git a/docs/reference/PosteriorDraw.html b/docs/reference/PosteriorDraw.html index 598c0fa..28196f2 100644 --- a/docs/reference/PosteriorDraw.html +++ b/docs/reference/PosteriorDraw.html @@ -1,66 +1,18 @@ - - - - - - - -Draw from the posterior distribution — PosteriorDraw.exponential • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Draw from the posterior distribution — PosteriorDraw.exponential • dirichletprocess - + - -
-
- - -
-
+
-

Draw from the posterior distribution

-
-
# S3 method for exponential
-PosteriorDraw(mdObj, x, n = 1, ...)
-
-PosteriorDraw(mdObj, x, n = 1, ...)
-
-# S3 method for mvnormal
-PosteriorDraw(mdObj, x, n = 1, ...)
-
-# S3 method for mvnormal2
-PosteriorDraw(mdObj, x, n = 1, ...)
-
-# S3 method for normalFixedVariance
-PosteriorDraw(mdObj, x, n = 1, ...)
-
-# S3 method for normal
-PosteriorDraw(mdObj, x, n = 1, ...)
-
-# S3 method for weibull
-PosteriorDraw(mdObj, x, n = 100, ...)
- -

Arguments

- - - - - - - - - - - - - - - - - - -
mdObj

Mixing Distribution

x

Data

n

Number of draws

...

For a non-conjugate distribution the starting parameters. Defaults to a draw from the prior distribution.

- -

Value

+
+
# S3 method for class 'exponential'
+PosteriorDraw(mdObj, x, n = 1, ...)
+
+PosteriorDraw(mdObj, x, n = 1, ...)
+
+# S3 method for class 'mvnormal'
+PosteriorDraw(mdObj, x, n = 1, ...)
+
+# S3 method for class 'mvnormal2'
+PosteriorDraw(mdObj, x, n = 1, ...)
+
+# S3 method for class 'normalFixedVariance'
+PosteriorDraw(mdObj, x, n = 1, ...)
+
+# S3 method for class 'normal'
+PosteriorDraw(mdObj, x, n = 1, ...)
+
+# S3 method for class 'weibull'
+PosteriorDraw(mdObj, x, n = 100, ...)
+
+ +
+

Arguments

+ + +
mdObj
+

Mixing Distribution

+ +
x
+

Data

+ + +
n
+

Number of draws

+ + +
...
+

For a non-conjugate distribution the starting parameters. Defaults to a draw from the prior distribution.

+ +
+
+

Value

A sample from the posterior distribution

- +
+
-
- +
+ + - - - + diff --git a/docs/reference/PosteriorFrame.html b/docs/reference/PosteriorFrame.html index ebeda3d..8b142cc 100644 --- a/docs/reference/PosteriorFrame.html +++ b/docs/reference/PosteriorFrame.html @@ -1,66 +1,18 @@ - - - - - - - -Calculate the posterior mean and quantiles from a Dirichlet process object. — PosteriorFrame • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Calculate the posterior mean and quantiles from a Dirichlet process object. — PosteriorFrame • dirichletprocess - + - -
-
- - -
-
+
-

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

-
-
PosteriorFrame(dpobj, xgrid, ndraws = 1000, ci_size = 0.1)
- -

Arguments

- - - - - - - - - - - - - - - - - - -
dpobj

The Dirichlet process object to be drawn from.

xgrid

The x values the posterior is to be evaluated at.

ndraws

The number of posterior draws to take.

ci_size

The size of the credible interval draw in terms of percentage.

- -

Value

+
+
PosteriorFrame(dpobj, xgrid, ndraws = 1000, ci_size = 0.1)
+
+ +
+

Arguments

+ + +
dpobj
+

The Dirichlet process object to be drawn from.

+ +
xgrid
+

The x values the posterior is to be evaluated at.

+ + +
ndraws
+

The number of posterior draws to take.

+ + +
ci_size
+

The size of the credible interval draw in terms of percentage.

+ +
+
+

Value

A dataframe consisting of the posterior mean and credible intervals.

- +
+
-
- +
+ + - - - + diff --git a/docs/reference/PosteriorFunction-1.png b/docs/reference/PosteriorFunction-1.png index a716381..d781e28 100644 Binary files a/docs/reference/PosteriorFunction-1.png and b/docs/reference/PosteriorFunction-1.png differ diff --git a/docs/reference/PosteriorFunction.html b/docs/reference/PosteriorFunction.html index f33a4bf..66a32fd 100644 --- a/docs/reference/PosteriorFunction.html +++ b/docs/reference/PosteriorFunction.html @@ -1,66 +1,18 @@ - - - - - - - -Generate the posterior function of the Dirichlet function — PosteriorFunction • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Generate the posterior function of the Dirichlet function — PosteriorFunction • dirichletprocess + - - -
-
- - -
-
+
-

Generate the posterior function of the Dirichlet function

-
-
PosteriorFunction(dpobj, ind)
- -

Arguments

- - - - - - - - - - -
dpobj

Fitted Dirichlet Process object

ind

What iteration to draw the posterior function from. Defaults to the last iteration.

- -

Value

+
+
PosteriorFunction(dpobj, ind)
+
+ +
+

Arguments

+ + +
dpobj
+

Fitted Dirichlet Process object

+ +
ind
+

What iteration to draw the posterior function from. Defaults to the last iteration.

+ +
+
+

Value

A posterior function f(x).

- - -

Examples

-
-y <- rnorm(10) -dp <- DirichletProcessGaussian(y) -dp <- Fit(dp, 5) -postFuncDraw <- PosteriorFunction(dp) -plot(-3:3, postFuncDraw(-3:3)) -
-
+
+ +
+

Examples

+

+y <- rnorm(10)
+dp <- DirichletProcessGaussian(y)
+dp <- Fit(dp, 5)
+postFuncDraw <- PosteriorFunction(dp)
+plot(-3:3, postFuncDraw(-3:3))
+
+
+
+
+
-
- +
+ + - - - + diff --git a/docs/reference/PosteriorParameters.html b/docs/reference/PosteriorParameters.html index 04ba231..b6176da 100644 --- a/docs/reference/PosteriorParameters.html +++ b/docs/reference/PosteriorParameters.html @@ -1,66 +1,18 @@ - - - - - - - -Calculate the posterior parameters for a conjugate prior. — PosteriorParameters • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Calculate the posterior parameters for a conjugate prior. — PosteriorParameters • dirichletprocess - + - -
-
- - -
-
+
-

Calculate the posterior parameters for a conjugate prior.

-
-
PosteriorParameters(mdObj, x)
-
-# S3 method for mvnormal
-PosteriorParameters(mdObj, x)
-
-# S3 method for normalFixedVariance
-PosteriorParameters(mdObj, x)
-
-# S3 method for normal
-PosteriorParameters(mdObj, x)
- -

Arguments

- - - - - - - - - - -
mdObj

Mixing distribution object

x

Data

- -

Value

+
+
PosteriorParameters(mdObj, x)
+
+# S3 method for class 'mvnormal'
+PosteriorParameters(mdObj, x)
+
+# S3 method for class 'normalFixedVariance'
+PosteriorParameters(mdObj, x)
+
+# S3 method for class 'normal'
+PosteriorParameters(mdObj, x)
+
+ +
+

Arguments

+ +
mdObj
+

Mixing distribution object

+ + +
x
+

Data

+ +
+
+

Value

Parameters of the posterior distribution

- +
+
-
- +
+ + - - - + diff --git a/docs/reference/Predictive.html b/docs/reference/Predictive.html index 799cac7..e360bc3 100644 --- a/docs/reference/Predictive.html +++ b/docs/reference/Predictive.html @@ -1,66 +1,18 @@ - - - - - - - -Calculate how well the prior predicts the data. — Predictive.exponential • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Calculate how well the prior predicts the data. — Predictive.exponential • dirichletprocess - + - -
-
- - -
-
+
-

Calculate how well the prior predicts the data.

-
-
# S3 method for exponential
-Predictive(mdObj, x)
-
-Predictive(mdObj, x)
-
-# S3 method for mvnormal
-Predictive(mdObj, x)
-
-# S3 method for normalFixedVariance
-Predictive(mdObj, x)
-
-# S3 method for normal
-Predictive(mdObj, x)
- -

Arguments

- - - - - - - - - - -
mdObj

The distribution

x

The data

- -

Value

+
+
# S3 method for class 'exponential'
+Predictive(mdObj, x)
+
+Predictive(mdObj, x)
+
+# S3 method for class 'mvnormal'
+Predictive(mdObj, x)
+
+# S3 method for class 'normalFixedVariance'
+Predictive(mdObj, x)
+
+# S3 method for class 'normal'
+Predictive(mdObj, x)
+
+ +
+

Arguments

+ +
mdObj
+

The distribution

+ + +
x
+

The data

+ +
+
+

Value

The probability of the data being from the prior.

- +
+
-
- +
+ + - - - + diff --git a/docs/reference/PriorClusters.html b/docs/reference/PriorClusters.html index 557595c..f91c144 100644 --- a/docs/reference/PriorClusters.html +++ b/docs/reference/PriorClusters.html @@ -1,66 +1,18 @@ - - - - - - - -Draw prior clusters and weights from the Dirichlet process — PriorClusters • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Draw prior clusters and weights from the Dirichlet process — PriorClusters • dirichletprocess + - - -
-
- - -
-
+
-

Draw prior clusters and weights from the Dirichlet process

-
-
PriorClusters(dpobj)
- -

Arguments

- - - - - - -
dpobj

A Dirichlet process object

- -

Value

+
+
PriorClusters(dpobj)
+
+
+

Arguments

+ + +
dpobj
+

A Dirichlet process object

+ +
+
+

Value

A list of weights and parameters of the prior distribution of the Dirichcet process

- +
+
-
- +
+ + - - - + diff --git a/docs/reference/PriorDensity.html b/docs/reference/PriorDensity.html index fcb9336..3b479fa 100644 --- a/docs/reference/PriorDensity.html +++ b/docs/reference/PriorDensity.html @@ -1,66 +1,18 @@ - - - - - - - -Calculate the prior density of a mixing distribution — PriorDensity.beta • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Calculate the prior density of a mixing distribution — PriorDensity.beta • dirichletprocess - + - -
-
- - -
-
+
-

Calculate the prior density of a mixing distribution

-
-
# S3 method for beta
-PriorDensity(mdObj, theta)
-
-# S3 method for beta2
-PriorDensity(mdObj, theta)
-
-PriorDensity(mdObj, theta)
-
-# S3 method for weibull
-PriorDensity(mdObj, theta)
- -

Arguments

- - - - - - - - - - -
mdObj

Mixing distribution

theta

Prior parameters

- +
+
# S3 method for class 'beta'
+PriorDensity(mdObj, theta)
+
+# S3 method for class 'beta2'
+PriorDensity(mdObj, theta)
+
+PriorDensity(mdObj, theta)
+
+# S3 method for class 'weibull'
+PriorDensity(mdObj, theta)
+
+ +
+

Arguments

+ + +
mdObj
+

Mixing distribution

+ + +
theta
+

Prior parameters

+ +
+
-
- +
+ + - - - + diff --git a/docs/reference/PriorDraw.html b/docs/reference/PriorDraw.html index a2f4403..d060c2c 100644 --- a/docs/reference/PriorDraw.html +++ b/docs/reference/PriorDraw.html @@ -1,66 +1,18 @@ - - - - - - - -Draw from the prior distribution — PriorDraw.beta • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Draw from the prior distribution — PriorDraw.beta • dirichletprocess + - - -
-
- - -
-
+
-

Draw from the prior distribution

-
-
# S3 method for beta
-PriorDraw(mdObj, n = 1)
-
-# S3 method for beta2
-PriorDraw(mdObj, n = 1)
-
-# S3 method for exponential
-PriorDraw(mdObj, n)
-
-PriorDraw(mdObj, n)
+    
+
# S3 method for class 'beta'
+PriorDraw(mdObj, n = 1)
+
+# S3 method for class 'beta2'
+PriorDraw(mdObj, n = 1)
+
+# S3 method for class 'exponential'
+PriorDraw(mdObj, n)
+
+PriorDraw(mdObj, n)
+
+# S3 method for class 'mvnormal'
+PriorDraw(mdObj, n = 1)
+
+# S3 method for class 'mvnormal2'
+PriorDraw(mdObj, n = 1)
+
+# S3 method for class 'normalFixedVariance'
+PriorDraw(mdObj, n = 1)
+
+# S3 method for class 'normal'
+PriorDraw(mdObj, n = 1)
+
+# S3 method for class 'weibull'
+PriorDraw(mdObj, n = 1)
+
-# S3 method for mvnormal -PriorDraw(mdObj, n = 1) +
+

Arguments

-# S3 method for mvnormal2 -PriorDraw(mdObj, n = 1) -# S3 method for normalFixedVariance -PriorDraw(mdObj, n = 1) +
mdObj
+

Mixing Distribution

-# S3 method for normal -PriorDraw(mdObj, n = 1) -# S3 method for weibull -PriorDraw(mdObj, n = 1)
- -

Arguments

- - - - - - - - - - -
mdObj

Mixing Distribution

n

Number of draws.

- -

Value

+
n
+

Number of draws.

+
+
+

Value

A sample from the prior distribution

- +
+
-
- +
+ + - - - + diff --git a/docs/reference/PriorFunction.html b/docs/reference/PriorFunction.html index 4fe6233..6dc25a6 100644 --- a/docs/reference/PriorFunction.html +++ b/docs/reference/PriorFunction.html @@ -1,66 +1,18 @@ - - - - - - - -Generate the prior function of the Dirichlet process — PriorFunction • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Generate the prior function of the Dirichlet process — PriorFunction • dirichletprocess + - - -
-
- - -
-
+
-

Generate the prior function of the Dirichlet process

-
-
PriorFunction(dpobj)
- -

Arguments

- - - - - - -
dpobj

A Dirichlet process object

- -

Value

+
+
PriorFunction(dpobj)
+
+
+

Arguments

+ + +
dpobj
+

A Dirichlet process object

+ +
+
+

Value

A function f(x) that represents a draw from the prior distrubtion of the Dirichlet process.

@export

- +
+
-
- +
+ + - - - + diff --git a/docs/reference/PriorParametersUpdate.html b/docs/reference/PriorParametersUpdate.html index a334115..3b51cab 100644 --- a/docs/reference/PriorParametersUpdate.html +++ b/docs/reference/PriorParametersUpdate.html @@ -1,66 +1,18 @@ - - - - - - - -Update the prior parameters of a mixing distribution — PriorParametersUpdate.beta • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Update the prior parameters of a mixing distribution — PriorParametersUpdate.beta • dirichletprocess + - - -
-
- - -
-
+
-

Update the prior parameters of a mixing distribution

-
-
# S3 method for beta
-PriorParametersUpdate(mdObj, clusterParameters, n = 1)
-
-PriorParametersUpdate(mdObj, clusterParameters, n = 1)
-
-# S3 method for weibull
-PriorParametersUpdate(mdObj, clusterParameters, n = 1)
- -

Arguments

- - - - - - - - - - - - - - -
mdObj

Mixing Distribution Object

clusterParameters

Current cluster parameters

n

Number of samples

- -

Value

+
+
# S3 method for class 'beta'
+PriorParametersUpdate(mdObj, clusterParameters, n = 1)
+
+PriorParametersUpdate(mdObj, clusterParameters, n = 1)
+
+# S3 method for class 'weibull'
+PriorParametersUpdate(mdObj, clusterParameters, n = 1)
+
+ +
+

Arguments

+ + +
mdObj
+

Mixing Distribution Object

+ +
clusterParameters
+

Current cluster parameters

+ + +
n
+

Number of samples

+ +
+
+

Value

mdobj New Mixing Distribution object with updated cluster parameters

- +
+
-
- +
+ + - - - + diff --git a/docs/reference/StickBreaking.html b/docs/reference/StickBreaking.html index 3f66999..81d389c 100644 --- a/docs/reference/StickBreaking.html +++ b/docs/reference/StickBreaking.html @@ -1,71 +1,23 @@ - - - - - - - -The Stick Breaking representation of the Dirichlet process. — StickBreaking • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -The Stick Breaking representation of the Dirichlet process. — StickBreaking • dirichletprocess - - - - - - - - - - - + - -
-
- - -
-
+
-

A Dirichlet process can be represented using a stick breaking construction $$G = \sum _{i=1} ^n pi _i \delta _{\theta _i}$$, where \(\pi _k = \beta _k \prod _{k=1} ^{n-1} (1- \beta _k )\) are the stick breaking weights. The atoms \(\delta _{\theta _i}\) are drawn from \(G_0\) the base measure of the Dirichlet Process. The \(\beta _k \sim \mathrm{Beta} (1, \alpha)\). In theory \(n\) should be infinite, but we chose some value of \(N\) to truncate the series. For more details see reference.

-
-
StickBreaking(alpha, N)
-
-piDirichlet(betas)
- -

Arguments

- - - - - - - - - - - - - - -
alpha

Concentration parameter of the Dirichlet Process.

N

Truncation value.

betas

Draws from the Beta distribution.

- -

Value

+
+
StickBreaking(alpha, N)
+
+piDirichlet(betas)
+
+ +
+

Arguments

+ + +
alpha
+

Concentration parameter of the Dirichlet Process.

-

Vector of stick breaking probabilities.

- -

Functions

- -
    -
  • piDirichlet: Function for calculating stick lengths.

  • -
- -

References

+
N
+

Truncation value.

+ +
betas
+

Draws from the Beta distribution.

+ +
+
+

Value

+

Vector of stick breaking probabilities.

+
+
+

Functions

+ +
  • piDirichlet(): Function for calculating stick lengths.

  • +
+
+

References

Ishwaran, H., & James, L. F. (2001). Gibbs sampling methods for stick-breaking priors. Journal of the American Statistical Association, 96(453), 161-173.

- +
+
-
- +
+ + - - - + diff --git a/docs/reference/UpdateAlpha.html b/docs/reference/UpdateAlpha.html index 8fd59fd..3b3164d 100644 --- a/docs/reference/UpdateAlpha.html +++ b/docs/reference/UpdateAlpha.html @@ -1,66 +1,18 @@ - - - - - - - -Update the Dirichlet process concentration parameter. — UpdateAlpha • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Update the Dirichlet process concentration parameter. — UpdateAlpha • dirichletprocess - + - -
-
- - -
-
+
-

Using the procedure outlined in West (1992) we sample the concentration parameter of the Dirichlet process. See reference for further details.

-
-
UpdateAlpha(dpobj)
-
-# S3 method for default
-UpdateAlpha(dpobj)
-
-# S3 method for hierarchical
-UpdateAlpha(dpobj)
- -

Arguments

- - - - - - -
dpobj

Dirichlet process object.

- -

Value

+
+
UpdateAlpha(dpobj)
+
+# Default S3 method
+UpdateAlpha(dpobj)
+
+# S3 method for class 'hierarchical'
+UpdateAlpha(dpobj)
+
-

A Dirichlet process object with updated concentration parameter.

- -

References

+
+

Arguments

+ +
dpobj
+

Dirichlet process object.

+ +
+
+

Value

+

A Dirichlet process object with updated concentration parameter.

+
+
+

References

West, M. (1992). Hyperparameter estimation in Dirichlet process mixture models. ISDS Discussion Paper# 92-A03: Duke University.

- +
+
-
- +
+ + - - - + diff --git a/docs/reference/UpdateAlphaBeta.html b/docs/reference/UpdateAlphaBeta.html index defd45c..644981e 100644 --- a/docs/reference/UpdateAlphaBeta.html +++ b/docs/reference/UpdateAlphaBeta.html @@ -1,66 +1,18 @@ - - - - - - - -Update the \(\alpha\) and \(\beta\) parameter of a hidden Markov Dirichlet process model. — UpdateAlphaBeta • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Update the \(\alpha\) and \(\beta\) parameter of a hidden Markov Dirichlet process model. — UpdateAlphaBeta • dirichletprocess + - - -
-
- - -
-
+
-

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

-
-
UpdateAlphaBeta(dp)
- -

Arguments

- - - - - - -
dp

Dirichlet process object

- +
+
UpdateAlphaBeta(dp)
+
+ +
+

Arguments

+ + +
dp
+

Dirichlet process object

+ +
+
-
- +
+ + - - - + diff --git a/docs/reference/WeibullMixtureCreate.html b/docs/reference/WeibullMixtureCreate.html index c14dbd5..345591d 100644 --- a/docs/reference/WeibullMixtureCreate.html +++ b/docs/reference/WeibullMixtureCreate.html @@ -1,66 +1,18 @@ - - - - - - - -Create a Weibull mixing distribution. — WeibullMixtureCreate • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Create a Weibull mixing distribution. — WeibullMixtureCreate • dirichletprocess + - - -
-
- - -
-
+
- -

See DirichletProcessWeibull for the default prior and hyper prior distributions.

- +

See DirichletProcessWeibull for the default prior and hyper prior distributions.

-
WeibullMixtureCreate(priorParameters, mhStepSize,
-  hyperPriorParameters = c(6, 2, 1, 0.5))
- -

Arguments

- - - - - - - - - - - - - - -
priorParameters

Prior parameters for the Weibull parameters

mhStepSize

Metropolis Hastings Step Size

hyperPriorParameters

Parameters for the hyper-priors

- -

Value

+
+
WeibullMixtureCreate(
+  priorParameters,
+  mhStepSize,
+  hyperPriorParameters = c(6, 2, 1, 0.5)
+)
+
+ +
+

Arguments

+ + +
priorParameters
+

Prior parameters for the Weibull parameters

+ +
mhStepSize
+

Metropolis Hastings Step Size

+ + +
hyperPriorParameters
+

Parameters for the hyper-priors

+ +
+
+

Value

A mixing distribution object.

- +
+
-
- +
+ + - - - + diff --git a/docs/reference/dirichletprocess-package.html b/docs/reference/dirichletprocess-package.html new file mode 100644 index 0000000..7491ee0 --- /dev/null +++ b/docs/reference/dirichletprocess-package.html @@ -0,0 +1,102 @@ + +dirichletprocess: Build Dirichlet Process Objects for Bayesian Modelling — dirichletprocess-package • dirichletprocess + + +
+
+ + + +
+
+ + +
+

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.

+
+ + + +
+

Author

+

Maintainer: Dean Markwick dean.markwick@talk21.com

+

Authors:

Other contributors:

+ +
+ +
+ + +
+ +
+

Site built with pkgdown 2.2.0.

+
+ +
+ + + + + + + + diff --git a/docs/reference/dirichletprocess.html b/docs/reference/dirichletprocess.html index 0008a57..569b195 100644 --- a/docs/reference/dirichletprocess.html +++ b/docs/reference/dirichletprocess.html @@ -1,66 +1,18 @@ - - - - - - - -A flexible package for fitting Bayesian non-parametric models. — dirichletprocess • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -A flexible package for fitting Bayesian non-parametric models. — dirichletprocess • dirichletprocess + - - -
-
- - -
-
+
-

Create, fit and take posterior samples from a Dirichlet process.

-
- + + +
+

Author

+

Maintainer: Dean Markwick dean.markwick@talk21.com

+

Authors:

Other contributors:

+
-
- +
+ + - - - + diff --git a/docs/reference/index.html b/docs/reference/index.html index e657ec7..677aa3a 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -1,62 +1,18 @@ - - - - - - - -Function reference • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Package index • dirichletprocess + - - -
-
- - -
-
+
- - - - - - - - - - -
-

All functions

+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - -
+

All functions

+

BetaMixture2Create()

Create a Beta mixture with zeros at the boundaries.

+

BetaMixtureCreate()

Create a Beta mixing distribution.

+

Burn()

Add burn-in to a dirichletprocess object

+

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.

+

ClusterParameterUpdate()

Update the cluster parameters of the Dirichlet process.

+

DiagnosticPlots() AlphaTraceplot() AlphaPriorPosteriorPlot() ClusterTraceplot() LikelihoodTraceplot()

Diagnostic plots for dirichletprocess objects

+

DirichletHMMCreate()

Create a generic Dirichlet process hidden Markov Model

+

DirichletProcessBeta()

Dirichlet process mixture of the Beta distribution.

+

DirichletProcessBeta2()

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

+

DirichletProcessCreate()

Create a Dirichlet Process object

+

DirichletProcessExponential()

Create a Dirichlet Mixture of Exponentials

+

DirichletProcessGaussian()

Create a Dirichlet Mixture of Gaussians

+

DirichletProcessGaussianFixedVariance()

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

+

DirichletProcessHierarchicalBeta()

Create a Hierarchical Dirichlet Mixture of Beta Distributions

+

DirichletProcessHierarchicalMvnormal2()

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

+

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

DirichletProcessMvnormal()

Create a Dirichlet mixture of multivariate normal distributions.

+

DirichletProcessMvnormal2()

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

+

DirichletProcessWeibull()

Create a Dirichlet Mixture of the Weibull distribution

+

ExponentialMixtureCreate()

Create a Exponential mixing distribution

+

Fit()

Fit the Dirichlet process object

+

Fit(<markov>)

Fit a Hidden Markov Dirichlet Process Model

+

GaussianFixedVarianceMixtureCreate()

Create a Gaussian Mixing Distribution with fixed variance.

+

GaussianMixtureCreate()

Create a Normal mixing distribution

+

GlobalParameterUpdate()

Update the parameters of the hierarchical Dirichlet process object.

+

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.

+

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

Initialise()

Initialise a Dirichlet process object

+

Likelihood()

Mixing Distribution Likelihood

+

LikelihoodDP()

The likelihood of the Dirichlet process object

+

LikelihoodFunction()

The Likelihood function of a Dirichlet process object.

+

MixingDistribution()

Create a mixing distribution object

+

Mvnormal2Create()

Create a multivariate normal mixing distribution with semi conjugate prior

+

MvnormalCreate()

Create a multivariate normal mixing distribution

+

PenalisedLikelihood()

Calculate the parameters that maximise the penalised likelihood.

+

PosteriorClusters()

Generate the posterior clusters of a Dirichlet Process

+

PosteriorDraw()

Draw from the posterior distribution

+

PosteriorFrame()

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

+

PosteriorFunction()

Generate the posterior function of the Dirichlet function

+

PosteriorParameters()

Calculate the posterior parameters for a conjugate prior.

+

Predictive()

Calculate how well the prior predicts the data.

+

PriorClusters()

Draw prior clusters and weights from the Dirichlet process

+

PriorDensity()

Calculate the prior density of a mixing distribution

+

PriorDraw()

Draw from the prior distribution

+

PriorFunction()

Generate the prior function of the Dirichlet process

+

PriorParametersUpdate()

Update the prior parameters of a mixing distribution

+

StickBreaking() piDirichlet()

The Stick Breaking representation of the Dirichlet process.

+

UpdateAlpha()

Update the Dirichlet process concentration parameter.

+

UpdateAlphaBeta()

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

+

WeibullMixtureCreate()

Create a Weibull mixing distribution.

+

dirichletprocess

A flexible package for fitting Bayesian non-parametric models.

+

plot(<dirichletprocess>) plot_dirichletprocess_univariate() plot_dirichletprocess_multivariate()

Plot the Dirichlet process object

+

print(<dirichletprocess>)

Print the Dirichlet process object

+

rats

Tumour incidences in rats

+

true_cluster_labels()

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

+

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

weighted_function_generator()

Generate a weighted function.

- +
+
-
- +
+ + - - - + diff --git a/docs/reference/plot.dirichletprocess-1.png b/docs/reference/plot.dirichletprocess-1.png index 0224751..fba94d5 100644 Binary files a/docs/reference/plot.dirichletprocess-1.png and b/docs/reference/plot.dirichletprocess-1.png differ diff --git a/docs/reference/plot.dirichletprocess-2.png b/docs/reference/plot.dirichletprocess-2.png index 9c5d8c8..8078588 100644 Binary files a/docs/reference/plot.dirichletprocess-2.png and b/docs/reference/plot.dirichletprocess-2.png differ diff --git a/docs/reference/plot.dirichletprocess.html b/docs/reference/plot.dirichletprocess.html index 057c913..094e6ee 100644 --- a/docs/reference/plot.dirichletprocess.html +++ b/docs/reference/plot.dirichletprocess.html @@ -1,70 +1,22 @@ - - - - - - - -Plot the Dirichlet process object — plot.dirichletprocess • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Plot the Dirichlet process object — plot.dirichletprocess • dirichletprocess - - - - - - - - - - + - - -
-
- - -
-
+
-

For a univariate Dirichlet process plot the density of the data with the posterior distribution and credible intervals overlayed. For multivariate data the first two columns of the data are plotted with the data points coloured by their cluster labels. The additional arguments are not used for multivariate data.

-
-
# S3 method for dirichletprocess
-plot(x, ...)
-
-plot_dirichletprocess_univariate(x, likelihood = FALSE, single = TRUE,
-  data_fill = "black", data_method = "density", data_bw = NULL,
-  ci_size = 0.05, xgrid_pts = 100, quant_pts = 100, xlim = NA)
-
-plot_dirichletprocess_multivariate(x)
- -

Arguments

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
x

Dirichlet Process Object to plot

...

Further arguments, currently ignored.

likelihood

Logical, indicating whether to plot the likelihood from the -dpobj.

single

Logical, indicating whether to draw the posterior from the last -iteration or use the full cluster sequence.

data_fill

Passed to `fill` in the data geom, for example a color. -Defaults to "black".

data_method

A string containing either "density" (default), -"hist"/"histogram", or "none". Data is plotted according to this method.

data_bw

Bandwith to be passed either as the binwidth of -geom_histogram, or as the bw of geom_density.

ci_size

Numeric, the interval size to use. Defaults to .05.

xgrid_pts

Integer, the number of points on the x-axis to evaluate.

quant_pts

Integer, the number of posterior functions to use to obtain -the posterior and its interval.

xlim

Default NA. If a vector of length two, the limits on the x-axis +

+
# S3 method for class 'dirichletprocess'
+plot(x, ...)
+
+plot_dirichletprocess_univariate(
+  x,
+  likelihood = FALSE,
+  single = TRUE,
+  data_fill = "black",
+  data_method = "density",
+  data_bw = NULL,
+  ci_size = 0.05,
+  xgrid_pts = 100,
+  quant_pts = 100,
+  xlim = NA
+)
+
+plot_dirichletprocess_multivariate(x)
+
+ +
+

Arguments

+ + +
x
+

Dirichlet Process Object to plot

+ + +
...
+

Further arguments, currently ignored.

+ + +
likelihood
+

Logical, indicating whether to plot the likelihood from the +dpobj.

+ + +
single
+

Logical, indicating whether to draw the posterior from the last +iteration or use the full cluster sequence.

+ + +
data_fill
+

Passed to `fill` in the data geom, for example a color. +Defaults to "black".

+ + +
data_method
+

A string containing either "density" (default), +"hist"/"histogram", or "none". Data is plotted according to this method.

+ + +
data_bw
+

Bandwith to be passed either as the binwidth of +geom_histogram, or as the bw of geom_density.

+ + +
ci_size
+

Numeric, the interval size to use. Defaults to .05.

+ + +
xgrid_pts
+

Integer, the number of points on the x-axis to evaluate.

+ + +
quant_pts
+

Integer, the number of posterior functions to use to obtain +the posterior and its interval.

+ + +
xlim
+

Default NA. If a vector of length two, the limits on the x-axis of the plot. If NA (default), the limits will be automatically -chosen.

- -

Value

+chosen.

+
+
+

Value

A ggplot object.

- - -

Examples

-
dp <- DirichletProcessGaussian(c(rnorm(50, 2, .2), rnorm(60))) -dp <- Fit(dp, 100) -plot(dp) -
-plot(dp, likelihood = TRUE, data_method = "hist", - data_fill = rgb(.5, .5, .8, .6), data_bw = .3) -
-
+
+ +
+

Examples

+
dp <- DirichletProcessGaussian(c(rnorm(50, 2, .2), rnorm(60)))
+dp <- Fit(dp, 100)
+plot(dp)
+
+
+plot(dp, likelihood = TRUE, data_method = "hist",
+     data_fill = rgb(.5, .5, .8, .6), data_bw = .3)
+
+
+
+
+
-
- +
+ + - - - + diff --git a/docs/reference/print.dirichletprocess.html b/docs/reference/print.dirichletprocess.html index 83d8b9e..b94a293 100644 --- a/docs/reference/print.dirichletprocess.html +++ b/docs/reference/print.dirichletprocess.html @@ -1,67 +1,19 @@ - - - - - - - -Print the Dirichlet process object — print.dirichletprocess • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Print the Dirichlet process object — print.dirichletprocess • dirichletprocess - + - -
-
- - -
-
+
-

Print a Dirichlet process object. This will print some basic information about the dirichletprocess object.

-
-
# S3 method for dirichletprocess
-print(x, param_summary = FALSE, digits = 2,
-  ...)
- -

Arguments

- - - - - - - - - - - - - - - - - - -
x

Dirichlet Process Object to print.

param_summary

If TRUE, print the overall averages of each +

+
# S3 method for class 'dirichletprocess'
+print(x, param_summary = FALSE, digits = 2, ...)
+
+ +
+

Arguments

+ + +
x
+

Dirichlet Process Object to print.

+ + +
param_summary
+

If TRUE, print the overall averages of each parameter of the model. Note that this averages over all clusters and over all iterations, so it will only give a loose sense of the resulting DPM -model.

digits

Integer; Number of digits to display.

...

Further arguments passed to or from other methods.

- - -

Examples

-
dp <- Fit(DirichletProcessGaussian(rnorm(10)), 100) -dp -
#> Dirichlet process object run for 100 iterations. -#> -#> Mixing distribution normal -#> Base measure parameters 0, 1, 1, 1 -#> Alpha Prior parameters 2, 4 -#> Conjugacy conjugate -#> Sample size 10 -#> -#> Mean number of clusters 3.65 -#> Median alpha 0.70 -#>
-
+model.

+ + +
digits
+

Integer; Number of digits to display.

+ + +
...
+

Further arguments passed to or from other methods.

+ +
+ +
+

Examples

+
dp <- Fit(DirichletProcessGaussian(rnorm(10)), 100)
+dp
+#> Dirichlet process object run for 100 iterations.
+#>                                      
+#>   Mixing distribution          normal
+#>   Base measure parameters  0, 1, 1, 1
+#>   Alpha Prior parameters         2, 4
+#>   Conjugacy                 conjugate
+#>   Sample size                      10
+#>                                      
+#>   Mean number of clusters        3.65
+#>   Median alpha                   0.70
+#> 
+
+
+
+
-
- +
+ + - - - + diff --git a/docs/reference/rats.html b/docs/reference/rats.html index ba605c7..a6d82b6 100644 --- a/docs/reference/rats.html +++ b/docs/reference/rats.html @@ -1,66 +1,18 @@ - - - - - - - -Tumour incidences in rats — rats • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Tumour incidences in rats — rats • dirichletprocess - + - -
-
- - -
-
+
-

Rat tumour data from Tarone (1982). Data from Table 5.1 of Bayesian Data Analysis

-
-
rats
- -

Format

+
+
rats
+
+ +
+

Format

-
-
y

number of rats with a tumour

-
N

total number of rats in the experiment

+
y
+

number of rats with a tumour

-
- -

Source

+
N
+

total number of rats in the experiment

-

http://www.stat.columbia.edu/~gelman/book/data/rats.asc

- + +
+
+
-
- +
+ + - - - + diff --git a/docs/reference/true_cluster_labels.html b/docs/reference/true_cluster_labels.html index 0f708a5..0ec50f7 100644 --- a/docs/reference/true_cluster_labels.html +++ b/docs/reference/true_cluster_labels.html @@ -1,69 +1,19 @@ - - - - - - - -Identifies the correct clusters labels, in any dimension, -when cluster parameters and global parameters are matched. — true_cluster_labels • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Identifies the correct clusters labels, in any dimension, when cluster parameters and global parameters are matched. — true_cluster_labels • dirichletprocess - + - -
-
- - -
-
+
-

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

-
-
true_cluster_labels(array, dpObj)
- -

Arguments

- - - - - - - - - - -
array

The array containing matching indexes.

dpObj

A hierarchical dirichletprocess object.

- -

Value

+
+
true_cluster_labels(array, dpObj)
+
+ +
+

Arguments

+ +
array
+

The array containing matching indexes.

+ + +
dpObj
+

A hierarchical dirichletprocess object.

+ +
+
+

Value

The array containing the correct matching indexes

- +
+
-
- +
+ + - - - + diff --git a/docs/reference/weighted_function_generator.html b/docs/reference/weighted_function_generator.html index ca4e427..255a014 100644 --- a/docs/reference/weighted_function_generator.html +++ b/docs/reference/weighted_function_generator.html @@ -1,66 +1,18 @@ - - - - - - - -Generate a weighted function. — weighted_function_generator • dirichletprocess - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Generate a weighted function. — weighted_function_generator • dirichletprocess + - - -
-
- - -
-
+
-

Generate a weighted function.

-
-
weighted_function_generator(func, weights, params)
- -

Arguments

- - - - - - - - - - - - - - -
func

Function that is used of the form func(x, params).

weights

Weighting of each cluster.

params

Cluster parameter list

- -

Value

+
+
weighted_function_generator(func, weights, params)
+
+ +
+

Arguments

+ + +
func
+

Function that is used of the form func(x, params).

+ +
weights
+

Weighting of each cluster.

+ + +
params
+

Cluster parameter list

+ +
+
+

Value

weighted function

- +
+
-
- +
+ + - - - + diff --git a/docs/sitemap.xml b/docs/sitemap.xml new file mode 100644 index 0000000..7c3595b --- /dev/null +++ b/docs/sitemap.xml @@ -0,0 +1,66 @@ + +/404.html +/authors.html +/index.html +/news/index.html +/reference/BetaMixture2Create.html +/reference/BetaMixtureCreate.html +/reference/Burn.html +/reference/ChangeObservations.html +/reference/ClusterComponentUpdate.html +/reference/ClusterLabelPredict.html +/reference/ClusterParameterUpdate.html +/reference/DiagnosticPlots.html +/reference/DirichletHMMCreate.html +/reference/DirichletProcessBeta.html +/reference/DirichletProcessBeta2.html +/reference/DirichletProcessCreate.html +/reference/DirichletProcessExponential.html +/reference/DirichletProcessGaussian.html +/reference/DirichletProcessGaussianFixedVariance.html +/reference/DirichletProcessHierarchicalBeta.html +/reference/DirichletProcessHierarchicalMvnormal2.html +/reference/DirichletProcessMvnormal.html +/reference/DirichletProcessMvnormal2.html +/reference/DirichletProcessWeibull.html +/reference/ExponentialMixtureCreate.html +/reference/Fit.html +/reference/Fit.markov.html +/reference/GaussianFixedVarianceMixtureCreate.html +/reference/GaussianMixtureCreate.html +/reference/GlobalParameterUpdate.html +/reference/HierarchicalBetaCreate.html +/reference/HierarchicalMvnormal2Create.html +/reference/Initialise.html +/reference/Likelihood.html +/reference/LikelihoodDP.html +/reference/LikelihoodFunction.html +/reference/MixingDistribution.html +/reference/Mvnormal2Create.html +/reference/MvnormalCreate.html +/reference/PenalisedLikelihood.html +/reference/PosteriorClusters.html +/reference/PosteriorDraw.html +/reference/PosteriorFrame.html +/reference/PosteriorFunction.html +/reference/PosteriorParameters.html +/reference/Predictive.html +/reference/PriorClusters.html +/reference/PriorDensity.html +/reference/PriorDraw.html +/reference/PriorFunction.html +/reference/PriorParametersUpdate.html +/reference/StickBreaking.html +/reference/UpdateAlpha.html +/reference/UpdateAlphaBeta.html +/reference/WeibullMixtureCreate.html +/reference/dirichletprocess-package.html +/reference/dirichletprocess.html +/reference/index.html +/reference/plot.dirichletprocess.html +/reference/print.dirichletprocess.html +/reference/rats.html +/reference/true_cluster_labels.html +/reference/weighted_function_generator.html + + diff --git a/man/dirichletprocess-package.Rd b/man/dirichletprocess-package.Rd new file mode 100644 index 0000000..b6b0351 --- /dev/null +++ b/man/dirichletprocess-package.Rd @@ -0,0 +1,36 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/dirichletprocess-package.R +\docType{package} +\name{dirichletprocess-package} +\alias{dirichletprocess-package} +\title{dirichletprocess: Build Dirichlet Process Objects for Bayesian Modelling} +\description{ +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) \url{https://www.stats.ox.ac.uk/~teh/research/npbayes/Teh2010a.pdf}, among many other sources. +} +\seealso{ +Useful links: +\itemize{ + \item \url{https://github.com/dm13450/dirichletprocess} + \item \url{https://dm13450.github.io/dirichletprocess/} + \item Report bugs at \url{https://github.com/dm13450/dirichletprocess/issues} +} + +} +\author{ +\strong{Maintainer}: Dean Markwick \email{dean.markwick@talk21.com} + +Authors: +\itemize{ + \item Dean Markwick \email{dean.markwick@talk21.com} + \item Gordon J. Ross \email{gordon@gordonjross.co.uk} +} + +Other contributors: +\itemize{ + \item Kees Mulder \email{keestimmulder@gmail.com} (\href{https://orcid.org/0000-0002-5387-3812}{ORCID}) [contributor] + \item Giovanni Sighinolfi \email{giovanni.sighinolfi2@studio.unibo.it} [contributor] + \item Filippo Fiocchi \email{filippofiocchi1@gmail.com} [contributor] +} + +} +\keyword{internal} diff --git a/man/dirichletprocess.Rd b/man/dirichletprocess.Rd index 593da89..71fe69b 100644 --- a/man/dirichletprocess.Rd +++ b/man/dirichletprocess.Rd @@ -7,3 +7,29 @@ \description{ Create, fit and take posterior samples from a Dirichlet process. } +\seealso{ +Useful links: +\itemize{ + \item \url{https://github.com/dm13450/dirichletprocess} + \item \url{https://dm13450.github.io/dirichletprocess/} + \item Report bugs at \url{https://github.com/dm13450/dirichletprocess/issues} +} + +} +\author{ +\strong{Maintainer}: Dean Markwick \email{dean.markwick@talk21.com} + +Authors: +\itemize{ + \item Dean Markwick \email{dean.markwick@talk21.com} + \item Gordon J. Ross \email{gordon@gordonjross.co.uk} +} + +Other contributors: +\itemize{ + \item Kees Mulder \email{keestimmulder@gmail.com} (\href{https://orcid.org/0000-0002-5387-3812}{ORCID}) [contributor] + \item Giovanni Sighinolfi \email{giovanni.sighinolfi2@studio.unibo.it} [contributor] + \item Filippo Fiocchi \email{filippofiocchi1@gmail.com} [contributor] +} + +} diff --git a/tests/testthat/test_beta_uniform_gamma.R b/tests/testthat/test_beta_uniform_gamma.R index 229d3f5..e752131 100644 --- a/tests/testthat/test_beta_uniform_gamma.R +++ b/tests/testthat/test_beta_uniform_gamma.R @@ -312,14 +312,14 @@ test_that("Beta Penelised Likelihodd", { }) test_that("Dirichlet Process Likelihood", { - + N = 10 pts <- rbeta(10, 2,2) beta_dpobj <- DirichletProcessBeta(pts, 1, verbose = FALSE) beta_dpobj <- Fit(beta_dpobj, 5, FALSE, FALSE) lik <- LikelihoodDP(beta_dpobj) - + expect_shape(lik, dim=c(N, 1)) }) diff --git a/tests/testthat/test_dirichlet_process_hierarchical_beta.R b/tests/testthat/test_dirichlet_process_hierarchical_beta.R index a488c16..f1efd56 100644 --- a/tests/testthat/test_dirichlet_process_hierarchical_beta.R +++ b/tests/testthat/test_dirichlet_process_hierarchical_beta.R @@ -1,11 +1,13 @@ context("Hierarchical Beta") -test_that("",{ +test_that("Hierarchical Beta Update",{ testData <- replicate(3, rbeta(100, 3, 6), simplify = FALSE) - dp <- DirichletProcessHierarchicalBeta(testData, 1, gammaPriors = c(2, 0.01)) + dpobj <- DirichletProcessHierarchicalBeta(testData, 1, gammaPriors = c(2, 0.01)) + expect_is(dpobj, c("list")) + expect_length(dpobj$indDP, 3) }) diff --git a/tests/testthat/test_global_parameter_update.R b/tests/testthat/test_global_parameter_update.R index 065ae0d..65f8e57 100644 --- a/tests/testthat/test_global_parameter_update.R +++ b/tests/testthat/test_global_parameter_update.R @@ -97,11 +97,14 @@ test_that("2 Data; 1 Cluster, 2D", { expect_equal(dpobjlistTest$indDP[[1]]$clusterParameters[[1]][,,1], dpobjlistTest$indDP[[2]]$clusterParameters[[1]][,,1]) }) -test_that("5 Data",{ +test_that("5 Data Beta",{ dataTest <- list(rbeta(10, 1, 3), rbeta(10, 1, 3), rbeta(10, 3, 5), rbeta(10, 4, 5), rbeta(10, 6, 3)) dpobjlistTest <- DirichletProcessHierarchicalBeta(dataTest, 1) dpobjlistTest <- GlobalParameterUpdate(dpobjlistTest) + expect_equal(dim(dpobjlistTest$indDP[[1]]$clusterParameters[[1]]), c(1,1,1)) + expect_equal(dim(dpobjlistTest$indDP[[1]]$clusterParameters[[2]]), c(1,1,1)) + }) diff --git a/tests/testthat/test_mvnormal_normal_wishart.R b/tests/testthat/test_mvnormal_normal_wishart.R index fade2c2..f2bf043 100644 --- a/tests/testthat/test_mvnormal_normal_wishart.R +++ b/tests/testthat/test_mvnormal_normal_wishart.R @@ -99,8 +99,6 @@ test_that("Multivariate Normal Predictive", { }) - - test_that("Multivariate Normal Dirichlet Create and Initialise", { test_data <- mvtnorm::rmvnorm(10, c(0,0), diag(2)) @@ -162,6 +160,8 @@ test_that("Multivariate Normal Cluster Label Change",{ dpobj <- ClusterLabelChange(dpobj, 1, 11, 1) + expect_equal(dpobj$clusterLabels[1], 11) + }) test_that("Multivariate Normal Cluster Parameter Update", { diff --git a/tests/testthat/test_plot.R b/tests/testthat/test_plot.R index a4a440b..91e73d7 100644 --- a/tests/testthat/test_plot.R +++ b/tests/testthat/test_plot.R @@ -70,10 +70,6 @@ test_that("MvNormal Plotting", { }) - - - - test_that("Plotting options", { dp <- DirichletProcessGaussian(c(rnorm(50, 2, .2), rnorm(60))) diff --git a/tests/testthat/test_weibull_uniform_gamma.R b/tests/testthat/test_weibull_uniform_gamma.R index d996c41..5f09339 100644 --- a/tests/testthat/test_weibull_uniform_gamma.R +++ b/tests/testthat/test_weibull_uniform_gamma.R @@ -83,6 +83,8 @@ test_that("Parameter Proposal", { old_param <- PriorDraw(test_mdobj, 1) new_param <- MhParameterProposal(test_mdobj, old_param) + + expect_shape(new_param[[1]], dim = dim(old_param[[1]])) })