PYdensity | R Documentation |
The PYdensity
function generates a posterior density sample for a selection of univariate and multivariate Pitman-Yor
process mixture models with Gaussian kernels. See details below for the description of the different specifications of the implemented models.
PYdensity(y, mcmc = list(), prior = list(), output = list())
y |
a vector or matrix giving the data based on which the density is to be estimated; |
mcmc |
a list of MCMC arguments:
|
prior |
a list giving the prior information. The list includes
|
output |
a list of arguments for generating posterior output. It contains:
|
This generic function fits a Pitman-Yor process mixture model for density estimation and clustering. The general model is
\tilde f(y) = \int K(y; θ) \tilde p (d θ),
where K(y; θ) is a kernel density with parameter θ\inΘ. Univariate and multivariate Gaussian kernels are implemented with different specifications for the parametric space Θ, as described below. The mixing measure \tilde p has a Pitman-Yor process prior with strength parameter \vartheta, discount parameter α, and base measure P_0 admitting the specifications presented below. For posterior sampling, three MCMC approaches are implemented. See details below.
Univariate data
For univariate y the function implements both a location and location-scale mixture model. The former assumes
\tilde f(y) = \int φ(y; μ, σ^2) \tilde p (d μ) π(σ^2),
where φ(y; μ, σ^2) is a univariate Gaussian kernel function with mean μ and variance σ^2, and π(σ^2) is an inverse gamma prior. The base measure is specified as
P_0(d μ) = N(d μ; m0, s20),
and σ^2 ~ IGa(a0, b0). Optional hyperpriors for the base measure's parameters are
(m0,s20) ~ N(m1, s20 / k_1) IGa(a1, b1).
The location-scale mixture model, instead, assumes
\tilde f(y) = \int φ(y; μ, σ^2) \tilde p (d μ, d σ^2)
with normal-inverse gamma base measure
P_0 (d μ, d σ^2) = N(d μ; m0, σ^2 / k0) IGa(d σ^2; a0, b0)
and (optional) hyperpriors
m0 ~ N(m1, σ12 ), k0 ~ Ga(τ1, ζ2), b0 ~ Ga(a1, b1).
Multivariate data
For multivariate y (p-variate) the function implements a location mixture model (with full covariance matrix) and two different location-scale mixture models, with either full or diagonal covariance matrix. The location mixture model assumes
\tilde f(y) = \int φ_p(y; μ, Σ) \tilde p (d μ) π(Σ)
where φ_p(y; μ, Σ) is a p-dimensional Gaussian kernel function with mean vector μ and covariance matrix Σ. The prior on Σ is inverse Whishart with parameters Σ_0 and ν_0, while the base measure is
P_0 (d μ) = N(d μ; m0, S0),
with optional hyperpriors
m0 ~ N(m1, S0 / k1), S0 ~ IW(λ1, Λ1).
The location-scale mixture model assumes
\tilde f(x) = \int φ_p(y; μ, Σ) \tilde p (d μ, d Σ).
Two possible structures for Σ are implemented, namely full and diagonal covariance. For the full covariance mixture model, the base measure is the normal-inverse Wishart
P_0 (d μ, d Σ) = N(d μ; m0, Σ / k0) IW(d Σ; ν, Σ0),
with optional hyperpriors
m_0 ~ N(m1, S12), k0 ~ Ga(τ1, ζ1), b_0 ~ W(ν1, Σ1).
The second location-scale mixture model assumes a diagonal covariance structure. This is equivalent to write the mixture model as a mixture of products of univariate normal kernels, i.e.
\tilde f(y) = \int ∏_{r=1}^p φ(y_r; μ_r, σ^2_r) \tilde p (d μ_1,…,d μ_p, d σ_1^2,…,d σ_p^2).
For this specification, the base measure is assumed defined as the product of p independent normal-inverse gamma distributions, that is
P_0 = ∏_{r=1}^p P_{0r}
where
P_{0r}(d μ_r, d σ_r^2) = N(d μ_r; m_{0j}, σ^2_r / k_{0r}) Ga(d σ^2_r; a_{0r}, b_{0r}).
Optional hyperpriors can be added, and, for each component, correspond to the set of hyperpriors considered for the univariate location-scale mixture model.
Posterior simulation methods
This generic function implements three types of MCMC algorithms for posterior simulation.
The default method is the importance conditional sampler 'ICS'
(Canale et al. 2019). Other options are
the marginal sampler 'MAR'
(Neal, 2000) and the slice sampler 'SLI'
(Kalli et al. 2011).
The importance conditional sampler performs an importance sampling step when updating the values of
individual parameters θ, which requires to sample m_imp
values from a suitable
proposal. Large values of m_imp
are known to improve the mixing of the chain
at the cost of increased running time (Canale et al. 2019). Two options are available for the slice sampler,
namely the dependent slice-efficient sampler (slice_type = 'DEP'
), which is set as default, and the
independent slice-efficient sampler (slice_type = 'INDEP'
) (Kalli et al. 2011). See Corradin et al. (to appear)
for more details.
A BNPdens
class object containing the estimated density and
the cluster allocations for each iterations. If out_param = TRUE
the output
contains also the kernel specific parameters for each iteration. If mcmc_dens = TRUE
the output
contains also a realization from the posterior density for each iteration. IF mean_dens = TRUE
the output contains just the mean of the realizations from the posterior density. The output contains
also informations as the number of iterations, the number of burn-in iterations, the used
computational time and the type of estimated model (univariate = TRUE
or FALSE
).
Canale, A., Corradin, R., Nipoti, B. (2019), Importance conditional sampling for Bayesian nonparametric mixtures, arXiv preprint, arXiv:1906.08147
Corradin, R., Canale, A., Nipoti, B. (2021), BNPmix: An R Package for Bayesian Nonparametric Modeling via Pitman-Yor Mixtures, Journal of Statistical Software, 100, doi:10.18637/jss.v100.i15
Kalli, M., Griffin, J. E., and Walker, S. G. (2011), Slice sampling mixture models. Statistics and Computing 21, 93-105, doi:10.1007/s11222-009-9150-y
Neal, R. M. (2000), Markov Chain Sampling Methods for Dirichlet Process Mixture Models, Journal of Computational and Graphical Statistics 9, 249-265, doi:10.2307/1390653
data_toy <- cbind(c(rnorm(100, -3, 1), rnorm(100, 3, 1)), c(rnorm(100, -3, 1), rnorm(100, 3, 1))) grid <- expand.grid(seq(-7, 7, length.out = 50), seq(-7, 7, length.out = 50)) est_model <- PYdensity(y = data_toy, mcmc = list(niter = 200, nburn = 100), output = list(grid = grid)) summary(est_model) plot(est_model)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.