# dPosteriorPredictive: Get the density value of the posterior predictive... In bbricks: Bayesian Methods and Graphical Model Structures for Statistical Modeling

## Description

This is a generic function that will generate the the density value of the posterior predictive distribution. i.e. for the model structure:

theta|gamma \sim H(gamma)

x|theta \sim F(theta)

get the probability density/mass of the posterior predictive distribution of a new sample x_new: p(x_new|gamma). For a given Bayesian bricks object obj and a new sample x, `dPosteriorPredictive()` will calculate the marginal likelihood for different model structures:

#### class(obj)="LinearGaussianGaussian"

Where

x \sim Gaussian(A z + b, Sigma)

z \sim Gaussian(m,S)

`dPosteriorPredictive()` will return p(x|m,S,A,b,Sigma) See `?dPosteriorPredictive.LinearGaussianGaussian` for details.

#### class(obj)="GaussianGaussian"

Where

x \sim Gaussian(mu,Sigma)

mu \sim Gaussian(m,S)

Sigma is known. `dPosteriorPredictive()` will return p(x|m,S,Sigma) See `?dPosteriorPredictive.GaussianGaussian` for details.

#### class(obj)="GaussianInvWishart"

Where

x \sim Gaussian(mu,Sigma)

Sigma \sim InvWishart(v,S)

mu is known. `dPosteriorPredictive()` will return p(x|mu,v,S) See `?dPosteriorPredictive.GaussianInvWishart` for details.

#### class(obj)="GaussianNIW"

Where

x \sim Gaussian(mu,Sigma)

Sigma \sim InvWishart(v,S)

mu \sim Gaussian(m,Sigma/k)

`dPosteriorPredictive()` will return p(x|m,k,v,S) See `?dPosteriorPredictive.GaussianNIW` for details.

#### class(obj)="GaussianNIG"

Where

x \sim Gaussian(X beta,sigma^2)

sigma^2 \sim InvGamma(a,b)

beta \sim Gaussian(m,sigma^2 V)

X is a row vector, or a design matrix where each row is an obervation. `dPosteriorPredictive()` will return p(x,X|m,V,a,b) See `?dPosteriorPredictive.GaussianNIG` for details.

#### class(obj)="CatDirichlet"

Where

x \sim Categorical(pi)

pi \sim Dirichlet(alpha)

`dPosteriorPredictive()` will return p(x|alpha) See `?dPosteriorPredictive.CatDirichlet` for details.

#### class(obj)="CatDP"

Where

x \sim Categorical(pi)

pi \sim DirichletProcess(alpha)

`dPosteriorPredictive()` will return p(x|alpha) See `?dPosteriorPredictive.CatDP` for details.

## Usage

 `1` ```dPosteriorPredictive(obj, ...) ```

## Arguments

 `obj` A "BayesianBrick" object used to select a method. `...` further arguments passed to or from other methods.

## Value

numeric, the density value

`dPosteriorPredictive.LinearGaussianGaussian` for Linear Gaussian and Gaussian conjugate structure, `dPosteriorPredictive.GaussianGaussian` for Gaussian-Gaussian conjugate structure, `dPosteriorPredictive.GaussianInvWishart` for Gaussian-Inverse-Wishart conjugate structure, `dPosteriorPredictive.GaussianNIW` for Gaussian-NIW conjugate structure, `dPosteriorPredictive.GaussianNIG` for Gaussian-NIG conjugate structure, `dPosteriorPredictive.CatDirichlet` for Categorical-Dirichlet conjugate structure, `dPosteriorPredictive.CatDP` for Categorical-DP conjugate structure ...