LDA Tutorial likelihood calculation

Hi everyone,
I am trying to run the LDA model from the Stan user guide which can be found here:

However, I think the likelihood calculation in the code is not right:

for (n in 1:N) {
    real gamma[K];
    for (k in 1:K)
      gamma[k] = log(theta[doc[n], k]) + log(phi[k, w[n]]);
    target += log_sum_exp(gamma);  // likelihood;

In the formula, it also includes the prior probabilities (for \theta and \phi); however, in the code while calculating the target , likelihood, they are not included. I would appreciate your help on that whether there is a reason they are not included.

1 Like

From a brief look, the priors are already added to target in the prior definitions above the likelihood loop.