posterior.DP {bbricks} | R Documentation |
For the model structure:
pi|alpha \sim DP(alpha,U)
z|pi \sim Categorical(pi)
theta_z|psi \sim H0(psi)
x|theta_z,z \sim F(theta_z)
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. The choice of F() and H0() can be described by an arbitrary "BasicBayesian" object such as "GaussianGaussian","GaussianInvWishart","GaussianNIW", "GaussianNIG", "CatDirichlet", and "CatDP". See ?BasicBayesian
for definition of "BasicBayesian" objects, and see for example ?GaussianGaussian
for specific "BasicBayesian" instances. As a summary, An "DP" object is simply a combination of a "CatDP" object (see ?CatDP
) and an object of any "BasicBayesian" type.
This function will update the prior knowledge by adding the information of newly observed samples x. The model structure and prior parameters are stored in a "DP" object, the prior parameters in this object will be updated after running this function.
## S3 method for class 'DP' posterior(obj, ss = NULL, z, w = NULL, ...)
obj |
A "DP" object. |
ss |
Sufficient statistics of x of the "BasicBayesian" object, must be a list of sufficient statistics for each of the observations. Use sufficientStatistics(...,foreach=TRUE) to generate ss. See examples. |
z |
integer, the partition label of the parameter space where the observation x is drawn from. |
w |
Sample weights, default NULL. |
... |
Additional arguments to be passed to other inherited types. |
None. the model stored in "obj" will be updated based on "ss".
Teh, Yee W., et al. "Sharing clusters among related groups: Hierarchical Dirichlet processes." Advances in neural information processing systems. 2005.
DP
,posteriorDiscard.DP
,sufficientStatistics.DP
x <- rnorm(40) z <- sample(1L:10L,size = 40,replace = TRUE) obj <- DP() ss <- sufficientStatistics(obj = obj,x=x,foreach = TRUE) #must use foreach=TRUE for(i in 1L:length(z)) posterior(obj = obj,ss = ss[[i]],z=z[i]) obj