# rPosteriorPredictive: Generate random samples from the posterior predictive... In bbricks: Bayesian Methods and Graphical Model Structures for Statistical Modeling

## Description

This is a generic function that will generate random samples from the posterior predictive distribution. i.e. for the model structure:

theta|gamma \sim H(gamma)

x|theta \sim F(theta)

generate x_new from the posterior predictive distribution of x|gamma. For a given Bayesian bricks object obj, `rPosteriorPredictive()` will generate random samples from different model structures:

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

Where

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

z \sim Gaussian(m,S)

`rPosteriorPredictive()` will generate samples from the distribution of x|m,S,A,b,Sigma See `?rPosteriorPredictive.LinearGaussianGaussian` for details.

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

Where

x \sim Gaussian(mu,Sigma)

mu \sim Gaussian(m,S)

Sigma is known. `rPosteriorPredictive()` will generate samples from the distribution of x|m,S,Sigma See `?rPosteriorPredictive.GaussianGaussian` for details.

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

Where

x \sim Gaussian(mu,Sigma)

Sigma \sim InvWishart(v,S)

mu is known. `rPosteriorPredictive()` will generate samples from the distribution of x|mu,v,S See `?rPosteriorPredictive.GaussianInvWishart` for details.

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

Where

x \sim Gaussian(mu,Sigma)

Sigma \sim InvWishart(v,S)

mu \sim Gaussian(m,Sigma/k)

`rPosteriorPredictive()` will generate samples from the distribution of x|m,k,v,S See `?rPosteriorPredictive.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. `rPosteriorPredictive()` will generate samples from the distribution of x,X|m,V,a,b See `?rPosteriorPredictive.GaussianNIG` for details.

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

Where

x \sim Categorical(pi)

pi \sim Dirichlet(alpha)

`rPosteriorPredictive()` will generate samples from the distribution of x|alpha See `?rPosteriorPredictive.CatDirichlet` for details.

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

Where

x \sim Categorical(pi)

pi \sim DirichletProcess(alpha)

`rPosteriorPredictive()` will generate samples from the distribution of x|alpha See `?rPosteriorPredictive.CatDP` for details.

## Usage

 `1` ```rPosteriorPredictive(obj, n, ...) ```

## Arguments

 `obj` A "BayesianBrick" object used to select a method. `n` integer, specify the number of samples to be generated. `...` further arguments passed to or from other methods.

## Value

a matrix or vector or list of random samples, depends on the type of 'obj'.

`rPosteriorPredictive.GaussianNIW` for Gaussian-NIW conjugate structure, `rPosteriorPredictive.GaussianNIG` for Gaussian-NIG conjugate structure, `rPosteriorPredictive.CatDirichlet` for Categorical-Dirichlet conjugate structure, `rPosteriorPredictive.CatDP` for Categorical-DP conjugate structure ...