Just to have breadcrumbs, I believe this sprang out from the discussion at Using beta binomial with size of the population provided as a "real" (where there are some links to papers proposing something related, which I unfortunately don’t understand).
One of the links follows through to Continuous binomial, negative binomial and Poisson where Mike warns that a proposed extension of the Binomial distribution is impractical.
I would however definitely try to reimplement the binomial distribution with real N directly, it might break badly, but it is IMHO worth trying, e.g.: (a sketch, didn’t even test if it compiles, could also be vectorized to have arrays as input instead)
functions {
real binomial_real_dangerous_lpmf(int k, real n, real p) {
return binomial_coefficient_log(n, k) + k * log(p) + (n - k) * log1m(p);
}
}
If that let’s you reliably recover the parameters from the simulation (and even better, if you can use SBC as a stronger check), I wouldn’t be too afraid to actually use it. For large-ish n
, the difference between binomial_real_dangerous_lpmf(k, n, p)
and binomial_lpmf(k, floor(n), p)
should be pretty small.
A more difficult challenge would be to somehow ensure that ObsA[year] < pop[year,2]
for all Mjuv
values to make the likelihood well defined.