# dPosteriorPredictive.HDP: Posterior predictive density function of a "HDP" object In bbricks: Bayesian Methods and Graphical Model Structures for Statistical Modeling

## Description

Generate the the density value of the posterior predictive distribution of the following structure:

G|gamma \sim DP(gamma,U)

pi_j|G,alpha \sim DP(alpha,G), j = 1:J

z|pi_j \sim Categorical(pi_j)

k|z,G \sim Categorical(G), \textrm{ if z is a sample from the base measure G}

theta_k|psi \sim H0(psi)

x|theta_k,k \sim F(theta_k)

where DP(gamma,U) is a Dirichlet Process on positive integers, gamma is the "concentration parameter", U is the "base measure" of this Dirichlet process, U is an uniform distribution on all positive integers. DP(alpha,G) is a Dirichlet Process on integers with concentration parameter alpha and base measure G. The choice of F() and H0() can be described by an arbitrary "BasicBayesian" object such as "GaussianGaussian","GaussianInvWishart","GaussianNIW", "GaussianNIG", "CatDirichlet", and "CatDP". See `?BasicBayesian` for definition of "BasicBayesian" objects, and see for example `?GaussianGaussian` for specific "BasicBayesian" instances. As a summary, An "HDP" object is simply a combination of a "CatHDP" object (see `?CatHDP`) and an object of any "BasicBayesian" type.
In the case of HDP, z and k can only be positive integers.
The model structure and prior parameters are stored in a "HDP" object.
Posterior predictive density = p(x,z,k|gamma,alpha,psi) when x is not NULL, or p(z,k|gamma,alpha,psi) when x is NULL.

## Usage

 ```1 2``` ```## S3 method for class 'HDP' dPosteriorPredictive(obj, x = NULL, z, k, j, LOG = TRUE, ...) ```

## Arguments

 `obj` A "HDP" object. `x` Random samples of the "BasicBayesian" object. `z` integer. `k` integer, the partition label of the parameter space where the observation x is drawn from. `j` integer, group label. `LOG` Return the log density if set to "TRUE". `...` Additional arguments to be passed to other inherited types.

## Value

A numeric vector, the posterior predictive density.

## References

Teh, Yee W., et al. "Sharing clusters among related groups: Hierarchical Dirichlet processes." Advances in neural information processing systems. 2005.

`HDP`, `dPosteriorPredictive.HDP`, `marginalLikelihood.HDP`