posteriorDiscard.CatDP {bbricks}R Documentation

Update a "CatDP" object with sample sufficient statistics


For the model structure:

pi|alpha \sim DP(alpha,U)

x|pi \sim 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.Categorical() is the Categorical distribution. See dCategorical for the definition of the Categorical distribution.
In the case of CatDP, x can only be positive integers.
Contrary to posterior(), this function will update the prior knowledge by removing the information of observed samples x. The model structure and prior parameters are stored in a "CatDP" object, the prior parameters in this object will be updated after running this function.


## S3 method for class 'CatDP'
posteriorDiscard(obj, ss, w = NULL, ...)



A "CatDP" object.


Sufficient statistics of x. In Categorical-DP case the sufficient statistic of sample x can either be an object of type "ssCatDP" generated by sufficientStatistics(), or x itself(if x is a integer vector with all positive values).


Sample weights,default NULL.


Additional arguments to be passed to other inherited types.


None. the model stored in "obj" will be updated with the information in "ss".


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

See Also



## generate some integer samples
x <- sample(1L:10L,size = 40,replace = TRUE)
obj <- CatDP()
ss <- sufficientStatistics(obj=obj,x=x)
posterior(obj = obj,ss = ss)
obj2 <- CatDP(objCopy = obj)            #create obj2 contains the sames info as obj
obj3 <- CatDP(objCopy = obj)            #create obj3 contains the sames info as obj
## discard by samples
posteriorDiscard(obj = obj,ss = x)
## or discard by samples, one by one
for(xx in x) posteriorDiscard(obj = obj2,ss = xx)
## or discard by sufficient statistics
posteriorDiscard(obj = obj3,ss = ss)
## obj, obj2 and obj3 should be the same:

[Package bbricks version 0.1.4 Index]