50% off | Unlimited Data & AI Learning

Last chance! 50% off unlimited learning

Sale ends in


bbricks (version 0.1.1)

dPosteriorPredictive.DP: Posterior predictive density function of a Dirichlet Process object

Description

Generate the the density value of the posterior predictive distribution of the following structure: pi|alpha ~ DP(alpha,U) z|pi ~ Categorical(pi) theta_z|psi ~ H0(psi) x|theta_z,z ~ F(theta_z) where DP(alpha,U) is a Dirichlet Process on positive integers, alpha is the "concentration parameter" of the Dirichlet Process, U is the "base measure" of this Dirichlet process. The choice of F() and H0() can be arbitrary, they are distributions of x and theta_z correspondingly. The model structure and prior parameters are stored in a "DP" object. Posterior predictive is a distribution of x,z|alpha,psi.

Usage

# S3 method for DP
dPosteriorPredictive(obj, x, z, LOG = TRUE, ...)

Arguments

obj

A "DP" object.

x

Random samples of the "BasicBayesian" object.

z

integer, the partition label of the parameter space where the observation x is drawn from.

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.

See Also

@seealso DP, dPosteriorPredictive.DP, marginalLikelihood.DP

Examples

Run this code
# NOT RUN {
x <- rnorm(4)
z <- sample(1L:10L,size = 4,replace = TRUE)
obj <- DP()
ss <- sufficientStatistics(obj = obj,x=x,foreach = TRUE)
for(i in 1L:length(x)) posterior(obj = obj,ss=ss[[i]],z=z[i])
xnew <- rnorm(10)
znew <- sample(1L:10L,size = 10,replace = TRUE)
dPosteriorPredictive(obj = obj,x=xnew,z=znew)
# }

Run the code above in your browser using DataLab