update_s function

Update class weight vector

Update class weight vector

This function updates the class weight vector by drawing from its posterior distribution.

update_s(delta, m)

Arguments

  • delta: A numeric for the concentration parameter vector rep(delta,C) of the Dirichlet prior for s. Per default, delta = 1. In case of Dirichlet process-based updates of the latent classes, delta = 0.1 per default.
  • m: The vector of current class frequencies.

Returns

A vector, a draw from the Dirichlet posterior distribution for s.

Details

Let m=(m1,,mC)m=(m_1,\dots,m_C) be the frequencies of CC classes. Given the class weight (probability) vector s=(s1,,sC)s=(s_1,\dots,s_C), the distribution of mm is multinomial and its likelihood is

L(ms)i=1Csimi. L(m\mid s) \propto \prod_{i=1}^C s_i^{m_i}.

The conjugate prior p(s)p(s) for ss is a Dirichlet distribution, which has a density function proportional to

i=1Csiδi1, \prod_{i=1}^C s_i^{\delta_i-1},

where δ=(δ1,,δC)\delta = (\delta_1,\dots,\delta_C)

is the concentration parameter vector. Note that in {RprobitB}, δ1==δC\delta_1=\dots=\delta_C. This restriction is necessary because the class number CC can change. The posterior distribution of ss is proportional to

p(s)L(ms)i=1Csiδi+mi1, p(s) L(m\mid s) \propto \prod_{i=1}^C s_i^{\delta_i + m_i - 1},

which in turn is proportional to a Dirichlet distribution with parameters δ+m\delta+m.

Examples

### number of classes C <- 4 ### current class sizes m <- sample.int(C) ### concentration parameter for Dirichlet prior (single-valued) delta <- 1 ### updated class weight vector update_s(delta = 1, m = m)