Description Usage Arguments Value References See Also Examples
View source: R/Categorical_Inference.r
For following Categorical-Dirichlet 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 sufficient statistics of a set of samples x and weights w are:
the effective counts (in this case the sum of the weight w) of each unique label in x
Unique values of x must be in obj$gamma$uniqueLabels, where "obj" is a "CatDirichlet" object, see examples below.
1 2 | ## S3 method for class 'CatDirichlet'
sufficientStatistics_Weighted(obj, x, w, foreach = FALSE, ...)
|
obj |
A "CatDirichlet" object. |
x |
numeric,integer or character, samples of the Categorical distribution. |
w |
numeric, sample weights. |
foreach |
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 "ssCat", the sufficient statistics of a set of categorical samples. Or an object of the same class as x if foreach=TRUE.
Murphy, Kevin P. Machine learning: a probabilistic perspective. MIT press, 2012.
sufficientStatistics.CatDirichlet
CatDirichlet
1 2 3 4 5 | obj <- CatDirichlet(gamma=list(alpha=runif(26,1,2),uniqueLabels = letters))
x <- sample(letters,size = 20,replace = TRUE)
w <- runif(20)
sufficientStatistics(obj=obj,x=x) #return the counts of each unique label
sufficientStatistics_Weighted(obj=obj,x=x,w=w) #return the weighted counts of each unique lable
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.