
Bayesian nonparametric DP Gaussian mixture via dirichletprocess
Source:R/extenders_nonparam.R
morie_dp_gaussian_mixture.RdThin extender over
dirichletprocess::DirichletProcessGaussian +
dirichletprocess::Fit for a Bayesian nonparametric
Dirichlet-process Gaussian mixture model (Ross & Markwick, 2018;
MacEachern, 1994). Constructs the DP object on y and
then runs the Gibbs sampler for iterations sweeps.
Arguments
- y
Numeric vector of observations to model with the DP Gaussian mixture.
- iterations
Integer; number of Gibbs-sampler iterations to run via
dirichletprocess::Fit(default1000).- ...
Further arguments forwarded to
dirichletprocess::DirichletProcessGaussian(e.g.g0Priors,alphaPriors,mhDraws,verbose).
Value
A list with
$method = "dirichletprocess::DirichletProcessGaussian + Fit"
and $raw (the fitted dirichletprocess object
after the Gibbs run, containing the cluster assignments,
cluster parameters, and concentration-parameter trace).
Examples
# \donttest{
if (requireNamespace("dirichletprocess", quietly = TRUE)) {
set.seed(1)
y <- c(stats::rnorm(50, -2), stats::rnorm(50, 2))
morie_dp_gaussian_mixture(y, iterations = 200)
}
#> $method
#> [1] "dirichletprocess::DirichletProcessGaussian + Fit"
#>
#> $raw
#> Dirichlet process object run for 200 iterations.
#>
#> Mixing distribution normal
#> Base measure parameters 0, 1, 1, 1
#> Alpha Prior parameters 2, 4
#> Conjugacy conjugate
#> Sample size 100
#>
#> Mean number of clusters 7.05
#> Median alpha 0.95
#>
#>
# }