# Non-Centered Reparameterisation for the Negative Binomial Distribution?

**URL:** <https://discourse.pymc.io/t/non-centered-reparameterisation-for-the-negative-binomial-distribution/5734>\
**Category:** Questions\
**Created:** [September 3, 2020, 4:53pm UTC](https://discourse.pymc.io/t/non-centered-reparameterisation-for-the-negative-binomial-distribution/5734 "2020-09-03T16:53:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![MrinankSharma](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/mrinanksharma/32/2846_2.png) [@MrinankSharma](https://discourse.pymc.io/u/MrinankSharma)\
**Post date:** [September 3, 2020, 4:53pm UTC](https://discourse.pymc.io/t/non-centered-reparameterisation-for-the-negative-binomial-distribution/5734/1 "2020-09-03T16:53:05Z")

</div>

A typical suggestion that I see with model specification is switching between centered and non-centered representations for scale parameters e.g., see here: [https://twiecki.io/blog/2017/02/08/bayesian-hierchical-non-centered/](https://twiecki.io/blog/2017/02/08/bayesian-hierchical-non-centered/)

The intution I have behind this is that, for the centered model, the posterior looks very different for different values of scale parameters, making it a nightmare to sample from.

I’m basically have the same issue, but I’m using a negative binomial output distribution with an unknown dispersion parameter. I place a prior over this dispersion, similar to placing a prior over the scale parameter, but I suppose that the posterior is different to different values of this parameter, giving issues. For example, I noticed an approximate 2x speed-up from changing my model to use a fixed dispersion rather than having a prior over the dispersion.

I’m wondering if this could be caused by a similar issue with centered parameterisations for scale parameters, or instead perhaps the prior I place on the dispersion is ‘poor’ in some respect.

Thanks 🙂

---

<div class="post-metadata">

**Author:** ![junpenglao](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/junpenglao/32/8_2.png) [@junpenglao](https://discourse.pymc.io/u/junpenglao)\
**Post date:** [September 4, 2020, 6:27am UTC](https://discourse.pymc.io/t/non-centered-reparameterisation-for-the-negative-binomial-distribution/5734/2 "2020-09-04T06:27:09Z")

</div>

centered and non-centered is for latent variables - for observed (i.e., likelihood) it doesnt make much sense usually. I think your reasoning about poor prior for dispersion is correct - try assigning more informative prior usually helps.

---

<div class="post-metadata">

**Author:** ![MrinankSharma](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/mrinanksharma/32/2846_2.png) [@MrinankSharma](https://discourse.pymc.io/u/MrinankSharma)\
**Post date:** [September 4, 2020, 11:59am UTC](https://discourse.pymc.io/t/non-centered-reparameterisation-for-the-negative-binomial-distribution/5734/3 "2020-09-04T11:59:22Z")

</div>

Cool, thanks. Is there any best practice for setting the prior for dispersion?

---

<div class="post-metadata">

**Author:** ![AlexAndorra](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/alexandorra/32/9142_2.png) [@AlexAndorra](https://discourse.pymc.io/u/AlexAndorra)\
**Post date:** [September 4, 2020, 2:04pm UTC](https://discourse.pymc.io/t/non-centered-reparameterisation-for-the-negative-binomial-distribution/5734/4 "2020-09-04T14:04:16Z")

</div>

Hi @MrinankSharma,  
You can take a look at [https://github.com/stan-dev/stan/wiki/Prior-Choice-Recommendations](https://github.com/stan-dev/stan/wiki/Prior-Choice-Recommendations), I think it’ll be useful 😉

---

<div class="post-metadata">

**Author:** ![sabagh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/sabagh/32/2990_2.png) [@sabagh](https://discourse.pymc.io/u/sabagh)\
**Post date:** [January 21, 2021, 8:35pm UTC](https://discourse.pymc.io/t/non-centered-reparameterisation-for-the-negative-binomial-distribution/5734/5 "2021-01-21T20:35:16Z")

</div>

Hello,

This is a very useful post and reply. Could you please provide an example of centered and non-centered parameterization for latent negative binomial? I know what to do for Normal but I cannot figure out what should be done for negative binomial.

Thanks

---

<div class="post-metadata">

**Author:** ![junpenglao](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/junpenglao/32/8_2.png) [@junpenglao](https://discourse.pymc.io/u/junpenglao)\
**Post date:** [January 23, 2021, 8:19am UTC](https://discourse.pymc.io/t/non-centered-reparameterisation-for-the-negative-binomial-distribution/5734/6 "2021-01-23T08:19:19Z")

</div>

latent negative binomial probably wont make much differences when you try to run inference, i suggest you try to see if there is alternative implementation that does not need a latent discrete variable first.
