stan-dev / rstanarm

rstanarm R package for Bayesian applied regression modeling
https://mc-stan.org/rstanarm
GNU General Public License v3.0
388 stars 132 forks source link

how to place a inverse gaussian prior on the intercept #222

Open HirokiFujita2353 opened 7 years ago

HirokiFujita2353 commented 7 years ago

Summary:

Is it possible to place a inverse gaussian prior with rstanarm?

Description:

I am now trying to use stan_glmer in the rstanarm package with a inverse gaussian distribution for prior_intercept but it seems that the rstanarm package does not support such a prior. Is there any way to do this with the rstanarm package? Any suggestions will be highly appreciated. Thank you.

jgabry commented 7 years ago

We don't currently have inverse-Gaussian distributions available as priors, although it wouldn't be hard to add if there's a good motivation for it. Can I ask why you want to use that distribution for the intercept? Is that a common distribution in certain fields?

On Thu, Aug 17, 2017 at 11:38 AM HirokiFujita2353 notifications@github.com wrote:

Summary:

Is it possible to place a inverse gaussian prior with rstanarm? Description:

I am now trying to use stan_glmer in the rstanarm package with a inverse gaussian distribution for prior_intercept but it seems that the rstanarm package does not support such a prior. Is there any way to do this with the rstanarm package? Any suggestions will be highly appreciated. Thank you.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/stan-dev/rstanarm/issues/222, or mute the thread https://github.com/notifications/unsubscribe-auth/AHb4Q0Yv-yte9CAqYr5gT1_PJyepurVkks5sZF52gaJpZM4O6cWV .

HirokiFujita2353 commented 7 years ago

Thank you for your comment. One of the reasons is that my data is right skewed (reaction time data, which is often right skewed), and as long as I see my data visually, it seems the inverse gaussian distribution is most fit with my data.

HirokiFujita2353 commented 7 years ago

my field is (psycho)linguistics, where people traditionally assume reaction times to be normally distributed though actually they are almost always right skewed, and the inverse gaussian distribution is now being considered to be a better way to fit a model with. The following article is one example showing the inverse gaussian distribution is well fit with reading time data (among non-transformed distributions) http://journal.frontiersin.org/article/10.3389/fpsyg.2015.01171/full

bbbales2 commented 7 years ago

@jgabry I remember an early version of the new GP chapter had inverse Gaussians in it (as priors for length scales I think). I remember trying to use them and being sad they weren't there.

jgabry commented 7 years ago

@HirokiFujita2353 when you refer to the prior on the intercept in a stan_glmer model, are you referring to the global (nonvarying) intercept or the prior on the group-specific deviations from the global intercept (I.e. varying intercepts)?

Also, from your description it kind of sounds as if you're saying that the likelihood you want is an inverse Gaussian rather than the prior, although I may be misunderstanding. But if that is indeed what you want then currently in rstanarm we actually do allow setting family=inverse.gaussian(link), which would use an inverse-Gaussian for the likelihood.

On the other hand, if what you want really is just an inverse-Gaussian prior on the global intercept then that's not currently enabled but it could be added if it would really be useful for particular applications.

On Thu, Aug 17, 2017 at 12:04 PM HirokiFujita2353 notifications@github.com wrote:

my field is psycho(linguistics), where people often assume reaction times to be normally distributed though actually they are almost always right skewed, and the inverse gaussian distribution is now being considered to be a better way to fit a model with. The following article is one example showing the inverse gaussian distribution is well fit with reading time data (among non-transformed distributions) http://journal.frontiersin.org/article/10.3389/fpsyg.2015.01171/full

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/stan-dev/rstanarm/issues/222#issuecomment-323117970, or mute the thread https://github.com/notifications/unsubscribe-auth/AHb4Qz9bLQQrY2dN9kKqdOObNQHy35Kkks5sZGQ0gaJpZM4O6cWV .

jgabry commented 7 years ago

@bbales2 we might not have it as a built in distribution but were there statistical/computational reasons that make manually incrementing 'target' with the log PDF problematic?

On Thu, Aug 17, 2017 at 12:15 PM Ben Bales notifications@github.com wrote:

@jgabry https://github.com/jgabry I remember an early version of the new GP chapter had inverse Gaussians in it (as priors for length scales I think). I remember trying to use them and being sad they weren't there.

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/stan-dev/rstanarm/issues/222#issuecomment-323121504, or mute the thread https://github.com/notifications/unsubscribe-auth/AHb4Q_ZgWidsutcdlDTzVE9KPPe3qCnuks5sZGc0gaJpZM4O6cWV .

HirokiFujita2353 commented 7 years ago

@jgabry Thank you for the reply. I mean the global intercept, and as you said, family=inverse.gaussian can be used for the likelihood, but given reaction time data are always assumed to be right skewed (and this is almost always true), I wonder the prior for the likelihood also should be right skewed if a prior indicates a prior belief? If I am not wrong, the inverse gaussian distribution will be very helpful to (psycho)linguists who handle reaction time data. Thank you.

bbbales2 commented 7 years ago

@jgabry It didn't really matter to me -- I just switched to playing with gammas. That'd just be a question for @rtrangucci. Maybe there was no reason, or maybe it had heavier or lighter tails or something.

betanalpha commented 7 years ago

Gammas have heavy lower tails and light higher tails. Inverse Gamma have light lower tails and heavy higher tails. Generalized Inverse Gaussian with p = 1 has nice, light tails on both sides.

For the GP application we can get away with the heavy tail hence we are using inverse Gammas. I looked into implementing the generalized inverse Gaussian and it’s slightly tricky to get the gradients due to the Bessel functions, but not impossible. It would be even easier if we just did p = 1, but the question is how useful that would be in of itself.

On Aug 17, 2017, at 1:29 PM, Ben Bales notifications@github.com wrote:

@jgabry https://github.com/jgabry It didn't really matter to me -- I just switched to playing with gammas. That'd just be a question for @rtrangucci https://github.com/rtrangucci. Maybe there was no reason, or maybe it had heavier or lighter tails or something.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/stan-dev/rstanarm/issues/222#issuecomment-323140755, or mute the thread https://github.com/notifications/unsubscribe-auth/ABdNljvnujMrAIHbSGJAMSbTcf56I6jgks5sZHiEgaJpZM4O6cWV.