Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A better default prior for shape parameter of negative binomial #1614

Closed
avehtari opened this issue Mar 8, 2024 · 9 comments
Closed

A better default prior for shape parameter of negative binomial #1614

avehtari opened this issue Mar 8, 2024 · 9 comments

Comments

@avehtari
Copy link
Contributor

avehtari commented Mar 8, 2024

The current default prior for shape parameter of negbinomial is gamma(0.01, 0.01) which having a lot of mass for near 0 values, that is, for high overdispersion. A more reasonable prior would be something close to the PC prior shown e.g. in https://dansblog.netlify.app/posts/2022-08-29-priors4/priors4.html#the-dream-pc-priors-in-practice. PC prior has parameter lambda, and I don't know yet what would be a good default for that, so I'm not yet suggesting the new default, but creating the issue so that I don't forget this.

EDIT: removed wrong advice

@avehtari
Copy link
Contributor Author

I looked again at this. Previously, I had missed that Dan used alpha=1/phi. I made a notebook showing the steps going from Dan's results to PC prior for phi, and an inverse-gamma approximation that is easy to use.

The recommended prior inv_gamma(0.4, 0.3) is shown with red dashed line and PC(lambda=1) prior with continuous red line
image

@paul-buerkner if you agree with the choice, I can make a PR, too

@paul-buerkner
Copy link
Owner

Looks good! A PR would be great!

@ASKurz
Copy link

ASKurz commented Mar 17, 2024

I like this a lot. It has a nice intuitive appeal.

@paul-buerkner
Copy link
Owner

Quick question: I assume you are suggesting to just use inv_gamma(0.4, 0.3) as the general default, right? In this case, I can also quickly make the change if you are short on time.

@avehtari
Copy link
Contributor Author

use inv_gamma(0.4, 0.3) as the general default, right?

Yes.

In this case, I can also quickly make the change if you are short on time.

Do you want documentation? It would be nice to mention the default priors and brief justifications (e.g. one sentence and reference or link)

@paul-buerkner
Copy link
Owner

Ah I see. Yes, for the doc it could be more sensible if you would add the info. Do you think you can do it in the next couple of days? I will try to submit the new brms version to CRAN this week.

@avehtari
Copy link
Contributor Author

Hmm... I looked at the code, and I don't know how to make the change for the prior as if I now read it correctly, there are 4 distributions that have parameter shape and the default prior is set only based on the name of the parameter, but the family name doesn't matter. If you know how to fix it, then here is a proposal for the updated doc

#'   Further, family \code{student} needs the parameter
#'   \code{nu} representing the degrees of freedom of Student-t distribution.
#'   By default, \code{nu} has prior \code{gamma(2, 0.1)}, which is
#'   close to a penalized complexity prior (see Stan prior choice Wiki),
#'   and a fixed lower bound of \code{1}.
#'   Family \code{negbinomial} needs a \code{shape} parameter that has by
#'   default \code{inv_gamma(0.4, 0.3)} prior which is close to a
#'   penalized complexity prior (see Stan prior choice Wiki).
#'   Families \code{gamma}, \code{weibull}, and \code{inverse.gaussian},
#'   need a \code{shape} parameter that has a \code{gamma(0.01, 0.01)}
#'   prior by default.

I have updated Stan prior choice Wiki today to include the new advice for negbinomial

@paul-buerkner
Copy link
Owner

paul-buerkner commented Mar 18, 2024 via email

paul-buerkner added a commit that referenced this issue Mar 19, 2024
@paul-buerkner
Copy link
Owner

It's now working. I implemented a small internal feature that allows for family-specific default priors. I think it's actually kind handy more generally and I guess I will expand this to many other families at some point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants