rPosteriorPredictive.DP: Generate random samples from the posterior predictive...

Description Usage Arguments Value References See Also Examples

View source: R/Dirichlet_Process.r

Description

Generate random samples from the posterior predictive distribution of the following structure:

pi|alpha \sim DP(alpha,U)

z|pi \sim Categorical(pi)

theta_z|psi \sim H0(psi)

x|theta_z,z \sim 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 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 "DP" object is simply a combination of a "CatDP" object (see ?CatDP) and an object of any "BasicBayesian" type.
The model structure and prior parameters are stored in a "DP" object.
This function will generate random samples from the distribution z|alpha,psi,x.

Usage

1
2
## S3 method for class 'DP'
rPosteriorPredictive(obj, n = 1, x, ...)

Arguments

obj

A "DP" object.

n

integer, number of samples.

x

Random samples of the "BasicBayesian" object.

...

Additional arguments to be passed to other inherited types.

Value

integer, the categorical samples.

References

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

See Also

DP, dPosteriorPredictive.DP

Examples

1
2
3
4
5
6
7
8
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)
rPosteriorPredictive(obj = obj,n=1,x=xnew[5])

bbricks documentation built on July 8, 2020, 7:29 p.m.