posteriorDiscard.CatDP: Update a "CatDP" object with sample sufficient statistics

Description Usage Arguments Value References See Also Examples

View source: R/Dirichlet_Process.r

Description

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.

Usage

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

Arguments

obj

A "CatDP" object.

ss

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).

w

Sample weights,default NULL.

...

Additional arguments to be passed to other inherited types.

Value

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

References

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

See Also

CatDP,posterior.CatDP

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## 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:
obj
obj2
obj3

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