Skip to main content
. 2018 May 23;20(6):396. doi: 10.3390/e20060396
Algorithm 1 Gibbs sampling for the proposed method
  • Input: Datasets {yt,zt}t=1T; hyperparameters a, b, α, {μj}j=1q, {βj}j=1q; number of truncating components L; number of all samples N; initial sample (0)ϕ,(0)π,(0)λ,(0)ω,(0)x,(0)k.

  • Output: All posterior samples {(n)ϕ,(n)π,(n)λ,(n)ω,(n)x,(n)k}n=1N

  • 1:

    forn=1 to N do

  • 2:
       For each one string (s1,,sq), collect a sample ϕs1,,sq from its multinomial full conditional
    p(ϕs1,,sq=lξ)πlc=1C0{λl(c)}ns1,,sq(c)
       where ns1,,sq(c)=1T1{x1,t=s1,,xq,t=sq,yt=c}.
  • 3:
       For l=1,,L, update πl by the following rules
    VlξBeta(1b+nl,a+lb+k>lnk),l<LVL=1,πl=Vlk=1l1(1Vk)
       where nl=(s1,,sq)1{ϕs1,,sq=l}.
  • 4:
       For l=1,,L, collect samples λl from their respective Dirichlet full conditionals
    λlξDir{α+nl(1),,α+nl(C0)}
       where nl(c)=(s1,,sq)1{ϕs1,,sq=l}ns1,,sq(c).
  • 5:
       For j=1,,q, for c=1,,Cj, collect samples
    ω(j)(c)ξDir{βj+nj,c(1),,βj+nj,c(kj)}
       where nj,c(sj)=t=1T1{xj,t=sj,zj,t=c}.
  • 6:
       For j=1,,q, for t=1,,T, collect samples xj,t from their corresponding multinomial full conditionals
    p(xj,t=sξ,xi,t=si,ij)ωs(j)(zj,t)λϕs1,,s,,sq(yt)
  • 7:
       For j=1,,q, collect samples kj from their respective multinomial full conditionals
    p(kj=kξ)exp(μjk)c=1Cjnj,ckβj,kj=maxt{xj,t},,Cj
       where nj,c=t=1T1{zj,t=c}.
  • 8:

    end for