dPosteriorPredictive.CatDirichlet {bbricks} R Documentation

## Posterior predictive density function of a "CatDirichlet" object

### Description

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

pi|alpha \sim Dir(alpha)

x|pi \sim Categorical(pi)

Where Dir() is the Dirichlet distribution, Categorical() is the Categorical distribution. See `?dDir` and `dCategorical` for the definitions of these distribution.
The model structure and prior parameters are stored in a "CatDirichlet" object.
Posterior predictive is a distribution of x|alpha.

### Usage

```## S3 method for class 'CatDirichlet'
dPosteriorPredictive(obj, x, LOG = TRUE, ...)
```

### Arguments

 `obj` A "CatDirichlet" object. `x` numeric/integer/character vector, observed Categorical samples. `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

Murphy, Kevin P. Machine learning: a probabilistic perspective. MIT press, 2012.

`CatDirichlet`, `dPosteriorPredictive.CatDirichlet`, `marginalLikelihood.CatDirichlet`

### Examples

```obj <- CatDirichlet(gamma=list(alpha=runif(26,1,2),uniqueLabels = letters))
x <- sample(letters,size = 20,replace = TRUE)
## res1 and res2 should provide the same result
res1 <- dPosteriorPredictive(obj = obj,x=x,LOG = TRUE)
res2 <- numeric(length(x))
for(i in seq_along(x)) res2[i] <- marginalLikelihood(obj=obj,x=x[i],LOG = TRUE)
```

[Package bbricks version 0.1.4 Index]