posteriorDiscard.CatDirichlet: Update a "CatDirichlet" object with sample sufficient...

Description Usage Arguments Value References See Also Examples

View source: R/Categorical_Inference.r

Description

Contrary to posterior(), this function will update alpha by removing the information of observed samples x for the model structure:

pi|alpha \sim Dir(alpha)

x|pi \sim Categorical(pi)

Where Dir() is the Dirichlet distribution, Categorical() is the Categorical distribution. See ?dDir and dCategorical for the definitions of these distribution.
The model structure and prior parameters are stored in a "CatDirichlet" object, the prior parameters in this object will be updated after running this function.

Usage

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

Arguments

obj

A "CatDirichlet" object.

ss

Sufficient statistics of x. In Categorical-Dirichlet case the sufficient statistic of sample x can be either x itself, of an "ssCat" object generated by the function sufficientStatistics.CatDirichlet().

w

Sample weights,default NULL.

...

Additional arguments to be passed to other inherited types.

Value

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

References

Murphy, Kevin P. Machine learning: a probabilistic perspective. MIT press, 2012.

See Also

CatDirichlet,posterior.CatDirichlet

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
obj <- CatDirichlet(gamma=list(alpha=rep(1,26),uniqueLabels = letters))
x <- sample(letters,size = 20,replace = TRUE)
w <- runif(20)
posterior(obj=obj,ss=x)
obj
posteriorDiscard(obj=obj,ss=x)
obj
## weighted sample
posterior(obj=obj,ss=x,w=w)
obj
posteriorDiscard(obj=obj,ss=x,w=w)
obj

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