LOO-CV with refitting and Negative Binomial

Hi everybody,
I would like to model LOO-CV with refitting similarly to http://mc-stan.org/loo/articles/loo2-non-factorizable.html#working-with-stan-directly. However, instead of having a linear model I would like to have either a Poisson or Negative Binomial.

Stan does not allow to have an int parameter, and forces me to have y as int in the negative binomial. Thus, how do I model in Stan the Ymi - Yl trick if I can’t declare Yl as vector?

parameters {
  vector[Nmi] Ymi;  // estimated missings
}
model {
  vector[N] Yl = Y;
  Yl[Jmi] = Ymi;


 Yl ~ neg_binomial_2_log(beta0 + X_Q * betas_tilde, phi2);

Gives the error:

  vector ~ neg_binomial_2_log(vector, real)

Available argument signatures for neg_binomial_2_log:

  int ~ neg_binomial_2_log(real, real)
  int ~ neg_binomial_2_log(real, real[ ])
  int ~ neg_binomial_2_log(real, vector)
  int ~ neg_binomial_2_log(real, row_vector)
  int ~ neg_binomial_2_log(real[ ], real)
  int ~ neg_binomial_2_log(real[ ], real[ ])
  int ~ neg_binomial_2_log(real[ ], vector)
  int ~ neg_binomial_2_log(real[ ], row_vector)
  int ~ neg_binomial_2_log(vector, real)
  int ~ neg_binomial_2_log(vector, real[ ])
  int ~ neg_binomial_2_log(vector, vector)
  int ~ neg_binomial_2_log(vector, row_vector)
  int ~ neg_binomial_2_log(row_vector, real)
  int ~ neg_binomial_2_log(row_vector, real[ ])
  int ~ neg_binomial_2_log(row_vector, vector)
  int ~ neg_binomial_2_log(row_vector, row_vector)
  int[ ] ~ neg_binomial_2_log(real, real)
  int[ ] ~ neg_binomial_2_log(real, real[ ])
  int[ ] ~ neg_binomial_2_log(real, vector)
  int[ ] ~ neg_binomial_2_log(real, row_vector)
  int[ ] ~ neg_binomial_2_log(real[ ], real)
  int[ ] ~ neg_binomial_2_log(real[ ], real[ ])
  int[ ] ~ neg_binomial_2_log(real[ ], vector)
  int[ ] ~ neg_binomial_2_log(real[ ], row_vector)
  int[ ] ~ neg_binomial_2_log(vector, real)
  int[ ] ~ neg_binomial_2_log(vector, real[ ])
  int[ ] ~ neg_binomial_2_log(vector, vector)
  int[ ] ~ neg_binomial_2_log(vector, row_vector)
  int[ ] ~ neg_binomial_2_log(row_vector, real)
  int[ ] ~ neg_binomial_2_log(row_vector, real[ ])
  int[ ] ~ neg_binomial_2_log(row_vector, vector)
  int[ ] ~ neg_binomial_2_log(row_vector, row_vector)

It seems that from the available signatures, it is not possible to estimate missing values (Yl).
Thank you!

Add in functions block:

  real nbinom_log(real k,  real mu1, real r) {
     return  lgamma(r + k) - lgamma(k+1) - lgamma(r) + r * (log(r) - log(r + exp(mu1))) + k * (mu1- log(r + exp(mu1)));
  }

Write the function by yourself. Add in model block:

target += nbiom_log(Y1, beta0 + X_Q * betas_tilde, phi2);