
For following model structure: pi|alpha ~ DP(alpha,U) x|pi ~ Categorical(pi) 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, it is an uniform distribution on all positive integers. In the case of CatDP, x can only be positive integers. The model structure and prior parameters are stored in a "CatDP" object. The sufficient statistics of a set of samples x is the effective counts of the unique positive integers.
# S3 method for CatDP
sufficientStatistics_Weighted(obj, x, w, foreach = FALSE, ...)
A "CatDP" object.
integer, the elements of the vector must all greater than 0, the samples of a Categorical distribution.
numeric, sample weights
logical, specifying whether to return the sufficient statistics for each observation. Default FALSE.
Additional arguments to be passed to other inherited types.
An object of class "ssCatDP", the sufficient statistics of a set of categorical samples. Or an integer vector same as x if foreach=TRUE.
Teh, Yee W., et al. "Sharing clusters among related groups: Hierarchical Dirichlet processes." Advances in neural information processing systems. 2005.
# NOT RUN {
x <- sample(1L:10L,size = 4,replace = TRUE)
obj <- CatDP()
w <- runif(4)
## return an object of class "ssCatDP" contains the weighted counts of each unique integer
sufficientStatistics_Weighted(obj=obj,x=x,w=w)
## return x itself, no matter what w is
sufficientStatistics_Weighted(obj=obj,x=x,w=w,foreach = TRUE)
# }
Run the code above in your browser using DataLab