This function obtains posterior samples from a Dirichlet process distributed random measure of a model specified using the
getSamplesDPmeasure( MCMC, epsilon = 1e-04, setSeed = FALSE, progressBar = getNimbleOption("MCMCprogressBar") )
an MCMC class object, either compiled or uncompiled.
used for determining the truncation level of the representation of the random measure.
Logical or numeric argument. If a single numeric value is provided, R's random number seed will be set to this value. In the case of a logical value, if
Logical specifying whether to display a progress bar during execution (default = TRUE). The progress bar can be permanently disabled by setting the system option
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
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 posterior samples to generate samples of 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(addMonitors) for information on specifying monitors for an MCMC.
epsilon argument is optional and 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. The default value is 1e-4.
The output is a list of matrices. Each matrix represents a sample from the random measure. In order to reduce the output's dimensionality, the weights of identical atoms are added up. The stick-breaking weights are named
weights and the atoms are named based on the cluster variables in the model.
For more details about sampling the random measure and determining its truncation level, see Section 3 in Gelfand, A.E. and Kottas, A. 2002.
Claudia Wehrhahn and Christopher Paciorek
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. Journal of Computational and Graphical Statistics, 11(2), 289-305.
## Not run: conf <- configureMCMC(model) mcmc <- buildMCMC(conf) cmodel <- compileNimble(model) cmcmc <- compileNimble(mcmc, project = model) runMCMC(cmcmc, niter = 1000) outputG <- getSamplesDPmeasure(cmcmc) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.