title: Stan vs PYMC3 for Discrete Mixture Models
body: <p>I am studying zero-inflated count temporal data. I have built a <code>stan</code> model that deals with this zero-inflated data with an <code>if</code> statement in the <code>model</code> block. This is as they advise in the Stan Reference Guide. e.g.,</p>
  
  <pre><code>model { 
     for (n in 1:N) { 
        if (y[n] == 0) 
           target += log_sum_exp(bernoulli_lpmf(1 | theta), bernoulli_lpmf(0 | theta) + poisson_lpmf(y[n] | lambda));
        else
           target += bernoulli_lpmf(0 | theta) + poisson_lpmf(y[n] | lambda);
     } 
  }
  </code></pre>
  
  <p>This <code>if</code> statement is clearly necessary as Stan uses NUTS as the sampler which does not deal with discrete variables (<em>and thus we are marginalising over this discrete random variable instead of sampling from it</em>). I have not had very much experience with <code>pymc3</code> but my understanding is that it can deal with a Gibbs update step (to sample from the discrete bernoulli likelihood). Then conditioned on the zero-inflated value, it could perform a Metropolis or NUTS update for the parameters that depend on the Poisson likelihood.</p>
  
  <p><strong>My question is:</strong> Can (<em>and if so how can</em>) <code>pymc3</code> be used in such a way to sample from the discrete zero-inflated variable with the updates to the continuous variable being performed with a NUTS update? If it can, is the performance significantly improved over the above implementation in <code>stan</code> (which marginalises out the discrete random variable)? Further, if <code>pymc3</code> can only support a Gibbs + Metropolis update, is this change away from NUTS worth considering?</p>