Stan_glm: defining prior distributions


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.


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.