Learn R Programming

nimble (version 0.6-12)

getSamplesDPmeasure: Get posterior samples for a Dirichlet process measure

Description

EXPERIMENTAL This function obtains samples from the estimated Dirichlet process measure for models specified using the dCRP distribution.

Usage

getSamplesDPmeasure(MCMC)

Arguments

MCMC

an MCMC class object, either compiled or uncompiled.

Details

This function provides samples from a truncated approximation to the random measure associated with the mixing distribution of a Dirichlet process mixture model. The random measure is represented by a stick-breaking representation (Sethuraman, 1994). This sampler can only be used with models containing a dCRP distribution.

The MCMC argument is an object of class MCMC provided by buildMCMC, or its compiled version. The MCMC should already have been run, as getSamplesDPmeasure uses the parameter samples to generates samples for the random measure. Note that the monitors associated with that MCMC must include the cluster membership variable (which has the dCRP distribution), the cluster parameter variables, all variables directly determining the dCRP concentration parameter, and any stochastic parent variables of the cluster parameter variables. See help(configureMCMC) or help(addMonitors) for information on specifying monitors for an MCMC.

The truncation level of the random measure is determined based on a fixed error of approximation and by the posterior samples of the concentration parameter, if random. The error of approximation is the tail probability of the random measure (Section 4 in Ishwaran and Zarepour, 2000).

The returned object is a matrix containing samples from the truncated approximation of the random measure (one row per sample), with columns for the weights and the cluster variables. The stick-breaking weights are named weights and the atoms, or point masses, are named based on the cluster variables in the model.

References

Sethuraman, J. (1994). A constructive definition of Dirichlet priors. Statistica Sinica, 639-650.

Ishwaran, H., and Zarepour, M. (2000). Markov chain Monte Carlo in approximate Dirichlet and beta two-parameter process hierarchical models. Biometrika, 87(2), 371-390.

See Also

buildMCMC, configureMCMC,

Examples

Run this code
# NOT RUN {
  conf <- configureMCMC(model)
  Rmcmc <- buildMCMC(conf)
  Cmodel <- compileNimble(model)
  Cmcmc <- compileNimble(Rmcmc, project = model)
  runMCMC(Cmcmc, niter = 1000)
  samplesG <- getSamplesDPmeasure(Cmcmc)
# }

Run the code above in your browser using DataLab