nimble (version 0.7.0)

getSamplesDPmeasure: Get posterior samples for a Dirichlet process measure

Description

This function obtains posterior samples from a Dirichlet process distributed random measure of a model specified using the dCRP distribution.

Usage

getSamplesDPmeasure(MCMC, epsilon = 1e-04)

Arguments

MCMC

an MCMC class object, either compiled or uncompiled.

epsilon

used for determining the truncation level of the representation of the random measure.

Details

This function provides samples from a random measure having a Dirichlet process prior. Realizations are almost surely discrete and represented by a (finite) stick-breaking representation (Sethuraman, 1994), whose atoms (or point masses) are independent and identically distributed. 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 epsilon argument is used to determine the truncation level of the random measure. epsilon is the tail probability of the random measure, which together with posterior samples of the concentration parameter, determines the truncation level (see Section 3 in Gelfand, A.E. and Kottas, A. 2002). The default value is 1e-4.

The returned list contains a matrix with samples from the random measure (one sample per row) and the truncation level. 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.

Gelfand, A.E. and Kottas, A. (2002). A computational approach for full nonparametric Bayesian inference under Dirichlet process mixture models. ournal of Computational and Graphical Statistics, 11(2), 289-305.

See Also

buildMCMC, configureMCMC,

Examples

Run this code
# NOT RUN {
  conf <- configureMCMC(model)
  mcmc <- buildMCMC(conf)
  cmodel <- compileNimble(model)
  cmcmc <- compileNimble(mcmc, project = model)
  runMCMC(cmcmc, niter = 1000)
  outputG <- getSamplesDPmeasure(cmcmc)
  samples <- outputG$samples
  truncation <- output$trunc
# }

Run the code above in your browser using DataLab