Using discrete parameters in models

Hi everyone,

Say I’m modeling an outcome y as Poisson distributed with rate \lambda, y \sim \textrm{Poisson} (\lambda), and I model the rate as a product of two latent quantities, a baseline rate \eta and a discrete multiplier \xi, \lambda = \eta \times \xi, where \log \eta is continuous but \xi is discrete. This part of the model is part of the detection component of a larger continuous-time occupancy model.

I’ve worked with binary discrete states before in occupancy models and also think I understand what’s going on for N-mixture models, but these examples just marginalise the discrete states out of the likelihood. In my case, I think it’s slightly different (but maybe not?) in that I want to incorporate the latent discrete as part of a different component of the model. In JAGS, the whole occupancy model would look something like this, where you can see that xi[i] is a latent discrete parameter:

for (i in 1:n) {
   # occupancy
   z[i] ~ dbern(psi)
   for (j in 1:n_survey) {
      # detection
      y[i, j] ~ dpois(z[i] * lambda[i])
   }
   lambda[i] <- eta[i] * xi[i]
   log(eta[i]) ~ ddist(some_prior)
   xi[i] ~ dpois(mu)
}

I’m probably missing something obvious, but what’s the best way to incorporate latent discrete parameters in parts of the model that aren’t the likelihood?

thanks!

Matt

Because the various values of xi[i] are all mutually exclusive events, you can compute the likelihood for a given value of i by summing (i.e. marginalizing) over every possible combination of z[i] and xi[i]. In practice you’ll truncate the marginalization at some finite number of terms in the Poisson, chosen to ensure that the probability mass that you are truncating off is negligible.

Thanks for chiming in. So would that imply that to incorporate the random discrete effects I need to marginalise them out in the likelihood? For continuous random effects, you can first specify them in the (transformed) parameters block and then use those parameters in the likelihood. But if I want to use discrete random effects, I can’t do this, correct?

Correct. No discrete parameters in Stan; all discrete parameters must be marginalized out. Usually this leads to faster and more reliable model fitting, even in Jags compared to the unmarginalized formulation.

Yeah, I suppose I’ve found it fairly easy to grasp for something like occupancy where you just have two possibilities per site. But here in this case, I think I’d need to marginalise out a site-specific discrete random effect on the detection rates in addition to just the latent occupancy state. You wouldn’t have any example of such a situation?

The N-mixture model can be thought of as binomial regression with a site-specific Poisson random effect. Does that help?