Learn R Programming

bbricks (version 0.1.1)

sufficientStatistics.DP: Sufficient statistics of a "DP" object

Description

For following model structure: Create an object of type "DP", which represents the Dirichlet-Process model 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 sufficient statistics of a set of samples x in a "DP" object is the same sufficient statistics of the "BasicBayesian" inside the "DP", see examples.

Usage

# S3 method for DP
sufficientStatistics(obj, x, ...)

Arguments

obj

A "DP" object.

x

Random samples of the "BasicBayesian" object.

...

Additional arguments to be passed to other inherited types.

Value

Return the sufficient statistics of the corresponding BasicBayesian type, see examples.

References

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

See Also

DP, sufficientStatistics_Weighted.DP

Examples

Run this code
# NOT RUN {
obj1 <- DP(gamma=list(alpha=1,H0aF="GaussianNIW",parH0=list(m=1,k=1,v=1,S=1)))
obj2 <- DP(gamma=list(alpha=1,H0aF="CatDirichlet",parH0=list(alpha=1,uniqueLabels=letters)))
x1 <- rnorm(100)
x2 <- sample(letters,100,replace = TRUE)
sufficientStatistics(obj = obj1,x=x1)
sufficientStatistics(obj = obj2,x=x2)
sufficientStatistics(obj = obj1,x=x1,foreach = TRUE)
# }

Run the code above in your browser using DataLab