DDPdensity {BNPmix}  R Documentation 
The DDPdensity
function generates posterior density samples for a univariate GriffithsMilne dependent Dirichlet process mixture model with Gaussian
kernel, for partially exchangeable data. The function implements the importance conditional sampler method.
DDPdensity(y, group, mcmc = list(), prior = list(), output = list())
y 
a vector or matrix giving the data based on which densities are to be estimated; 
group 
vector of length 
mcmc 
list of MCMC arguments:

prior 
a list giving the prior information, which contains:

output 
a list of arguments for generating posterior output. It contains:

This function fits a GriffithsMilne dependent Dirichlet process (GMDDP) mixture
for density estimation for partially exchangeable data (Lijoi et al., 2014).
For each observation the group
variable allows the observations to be gathered
into L=length(unique(group))
distinct groups.
The model assumes exchangeability within each group, with observations in the lth group marginally
modelled by a locationscale Dirichlet process mixtures, i.e.
\tilde f_l(y) = \int φ(y; μ, σ^2) \tilde p_l (d μ, d σ^2)
where each \tilde p_l is a Dirichlet process with total mass strength
and base measure P_0.
The vector \tilde p = (\tilde p_1,…,\tilde p_L) is assumed to be jointly distributed as a vector of
GMDDP(strength
, wei
; P_0), where strength
and
P_0 are the total mass parameter and the base measure of each \tilde p_l, and wei
controls the dependence across the components of
\tilde p. Admissible values for wei
are in (0,1), with the two extremes of the range
corresponding to full exchangeability (wei
\rightarrow 0)
and independence across groups (wei
\rightarrow 1).
P_0 is a normalinverse gamma base measure, i.e.
P_0 (dμ,dσ^2) = N(d μ; m0, σ^2 / k0) IGa(d σ^2; a0, b0).
Posterior sampling is obtained by implementing the importance conditional sampler (Canale et al., 2019).
A BNPdensity
class object containing the estimated densities for each iteration,
the allocations for each iteration; the grid used to evaluate the densities (for each group); the
densities sampled from the posterior distribution (for each group); the groups; the weights of the processes.
The function returns also informations regarding the estimation: the number of iterations, the number
of burnin iterations and the execution time.
Lijoi, A., Nipoti, B., and Pruenster, I. (2014). Bayesian inference with dependent normalized completely random measures. Bernoulli 20, 1260–1291.
Canale, A., Corradin, R., & Nipoti, B. (2019). Importance conditional sampling for Bayesian nonparametric mixtures. arXiv preprint arXiv:1906.08147.
data_toy < c(rnorm(50, 4, 1), rnorm(100, 0, 1), rnorm(50, 4, 1)) group_toy < c(rep(1,100), rep(2,100)) grid < seq(7, 7, length.out = 50) est_model < DDPdensity(y = data_toy, group = group_toy, mcmc = list(niter = 200, nburn = 100, napprox_unif = 50), output = list(grid = grid)) summary(est_model) plot(est_model)