# posterior.CatHDP2: Update a "CatHDP2" object with sample sufficient statistics In bbricks: Bayesian Methods and Graphical Model Structures for Statistical Modeling

## Description

For the model structure:

G |eta \sim DP(eta,U)

G_m|gamma \sim DP(gamma,G), m = 1:M

pi_{mj}|G_m,alpha \sim DP(alpha,G_m), j = 1:J_m

z|pi_{mj} \sim Categorical(pi_{mj})

k|z,G_m \sim Categorical(G_m), \textrm{ if z is a sample from the base measure }G_m

u|k,G \sim Categorical(G), \textrm{ if k is a sample from the base measure G}

where DP(eta,U) is a Dirichlet Process on positive integers, eta is the "concentration parameter", U is the "base measure" of this Dirichlet process, U is an uniform distribution on all positive integers. DP(gamma,G) is a Dirichlet Process on integers with concentration parameter gamma and base measure G. DP(alpha,G_m) is a Dirichlet Process on integers with concentration parameter alpha and base measure G_m. Categorical() is the Categorical distribution. See `dCategorical` for the definition of the Categorical distribution.
In the case of CatHDP2, u, z and k can only be positive integers.
Update the prior knowledge by adding the information of newly observed samples u, z and k. The model structure and prior parameters are stored in a "CatHDP2" object, the prior parameters in this object will be updated after running this function.

## Usage

 ```1 2``` ```## S3 method for class 'CatHDP2' posterior(obj, ss1, ss2, ss3, m, j, w = NULL, ...) ```

## Arguments

 `obj` A "CatHDP2" object. `ss1` Sufficient statistics of u. In CatHDP2 case the sufficient statistic of sample u is u itself(if u is a integer vector with all positive values). `ss2` Sufficient statistics of k. In CatHDP2 case the sufficient statistic of sample k is k itself(if k is a integer vector with all positive values). `ss3` Sufficient statistics of z. In CatHDP2 case the sufficient statistic of sample z is z itself(if z is a integer vector with all positive values). `m` integer, group label. `j` integer, subgroup label. `w` Sample weights, default NULL. `...` Additional arguments to be passed to other inherited types.

## Value

None. the model stored in "obj" will be updated based on "ss1" and "ss2".

## References

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

`CatHDP2`,`posteriorDiscard.CatHDP2`