# Stan\_glm: defining prior distributions

**URL:** <https://discourse.mc-stan.org/t/stan-glm-defining-prior-distributions/6199>\
**Category:** rstanarm\
**Created:** [October 25, 2018, 6:53pm UTC](https://discourse.mc-stan.org/t/stan-glm-defining-prior-distributions/6199 "2018-10-25T18:53:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mattiasthalen](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/mattiasthalen/32/6768_2.png) [@mattiasthalen](https://discourse.mc-stan.org/u/mattiasthalen)\
**Post date:** [October 25, 2018, 6:53pm UTC](https://discourse.mc-stan.org/t/stan-glm-defining-prior-distributions/6199/1 "2018-10-25T18:53:42Z")

</div>

I’ve been successful in generating a simply y~x linear model with stan\_glm. Now, I’d like to set my priors based on the knowledge I have regarding the data.

For example, the intercept will probably lie between 1.2 & 1.6, but NEVER \<= 1. Likewise, the slope will be around -1, but NEVER \>= 0.

I tried it by setting prior\_intercept to normal(1.5, 0.5), but that ended in the model having equal amounts of positive as negative slopes. Maybe I’m just not understanding the normal() function.

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [October 25, 2018, 6:56pm UTC](https://discourse.mc-stan.org/t/stan-glm-defining-prior-distributions/6199/2 "2018-10-25T18:56:54Z")

</div>

I think the issue is that the intercept is parameterized in **rstanarm** relative to centered predictors. So, you need to think about what the expected value of the outcome for an average x rather than for the case where x is zero. Also, by default `normal()` and several other prior distributions in **rstanarm** are in units of standard deviations rather than raw units and are scaled accordingly inside `stan_glm`. To prevent this, you can pass `autoscale = FALSE` to `normal` to specify the mean and standard deviation in raw units.
