Implementing the Conway-Maxwell Poisson distribution in Stan. Code uses stan_summer as a submodule.
Approximately compute the normalising constant of a Conway-Maxwell Poisson distribution with parameters mu
and nu
.
- Asymptotic: use the asymptotic expansion of Gaunt et al. 2019 with four terms.
- SumToThreshold: For a given
eps
, sum untillterm < log(eps)
; - ErrorBoundingPair: for a given
eps
, this method guarantees an answer withineps
. Uses elementary results from convergent series. - bmrs: similar to the current implementation in brms with bug fixes and a bit of streamlining.
- brms_bulk similar to the above, but summing everything at once, 'in bulk'.
See Carvalho & Moreira (2022) for more details.
We will be looking at
- Error (in the original scale) to the true value (computed either exactly or with a stupidly large number of terms);
- Whether the absolute error is within a given
eps
; - Number of function evaluations needed to achieve the approximation (not applicable for the asymptotic approximation). When doing MCMC we will be looking at
- ESS/time for
mu
,nu
andlp__
; max_treedepth
exceedances;- Divergences.
The first bar to clear is that of correctly returning the answer within the error bound requested. Of course, not every method comes with mathematical guarantees (e.g. the asymptotic expansion of Gaunt et al. makes no promises about using finitely many terms). It is nevertheless useful to record whether each method/implementation got the answer within a certain tolerance in order to gauge their overall accuracy under many scenarios. This can be found in testing_implementations_grid.r.
The next step is to see what happens when these implementations are actually used in MCMC. This is implemented in fit_simple_COMP.r. We provide a real world analysis of inventory data here.