# Converting unstandardized priors for rstanarm function arguments

**URL:** <https://discourse.mc-stan.org/t/converting-unstandardized-priors-for-rstanarm-function-arguments/25868>\
**Category:** rstanarm\
**Tags:** priors, rstanarm\
**Created:** [January 4, 2022, 12:01pm UTC](https://discourse.mc-stan.org/t/converting-unstandardized-priors-for-rstanarm-function-arguments/25868 "2022-01-04T12:01:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![BeniSportSci](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/benisportsci/32/11320_2.png) [@BeniSportSci](https://discourse.mc-stan.org/u/BeniSportSci)\
**Post date:** [January 4, 2022, 12:01pm UTC](https://discourse.mc-stan.org/t/converting-unstandardized-priors-for-rstanarm-function-arguments/25868/1 "2022-01-04T12:01:01Z")

</div>

Hi everyone in the Stan community!

I’m struggling to wrap my head around the usage of informative priors in rstanarm functions (in a case where I want exceptionally specific prior information to be included). I’m afraid that the more I think about it without expert feedback, the more I will get lost.  
If I understand correctly, stan\_glm runs models on transformed data. However, I’m still not 100% sure if it’s standardization or mean-centering (the part of the rstanarm manual on the prior\_intercept statement got me confused there). Either way, I’m not sure how to express specific priors correctly.

To clarify my issue, here’s an example: Consider a simple linear regression model

y = a + bx

, where I’d like to apply specific **unstandardized** normal priors for both parameters a and b, let’s say

a \sim \mathcal{N}(100, 1) and  
b \sim \mathcal{N}(5, 2)

How would I express these two specific priors within the **`prior`** and **`prior_intercept`** statement of stan\_glm function? Given that stan\_glm requires the expression of priors on a standardized scale, my first idea was to convert the parameters according to

b \hspace{1pt} '= b \hspace{1pt} \frac{\sigma\_x}{\sigma\_y} and

a \hspace{1pt} '= \frac{a + b \hspace{1pt} ' \hspace{1pt} \frac{\sigma\_y}{\sigma\_x} \hspace{1pt} \overline{x} - \overline{y}}{\sigma\_y}

, where a’ and b’ represent the standardized parameters I could use in the prior arguments of stan\_glm.  
However, I can’t figure out how to continue from there. If anything, these formulas would only apply to the location argument of my specific priors ? But what about the scale argument?

It would be very appreciated if somebody could help me along on this topic. How do you convert a specific unstandardized normal prior to a scale that fits the requirements of the stan\_glm prior arguments? What are the respecitive prior expressions for a and b in the fictional example above?

Thank you for your help,

Beni

---

<div class="post-metadata">

**Author:** ![maxbiostat](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/maxbiostat/32/1326_2.png) [@maxbiostat](https://discourse.mc-stan.org/u/maxbiostat)\
**Post date:** [January 4, 2022, 4:17pm UTC](https://discourse.mc-stan.org/t/converting-unstandardized-priors-for-rstanarm-function-arguments/25868/2 "2022-01-04T16:17:44Z")

</div>

@jonah

---

<div class="post-metadata">

**Author:** ![BeniSportSci](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/benisportsci/32/11320_2.png) [@BeniSportSci](https://discourse.mc-stan.org/u/BeniSportSci)\
**Post date:** [January 7, 2022, 9:16am UTC](https://discourse.mc-stan.org/t/converting-unstandardized-priors-for-rstanarm-function-arguments/25868/3 "2022-01-07T09:16:10Z")

</div>

I may have found the answer to my question in Kruschke’s “Doing Bayesian Data Analysis”, but it would be much appreciated if someone who knows their maths better than me could sign it off (or please correct me if I’m wrong)

I believe the location parameters for the standardized slope and intercept would be according to the equations mentioned in my original post. For the scale parameter, Kruschke suggests that the difference between standardized and original scale is simply the factor \sigma\_y (the standard deviation of the dependent variable) and the normality parameter is not affected. Kind of obvious if I look at it now. Therefore I’d propose the following solution to my example problem:

a\hspace{1pt}' \sim \mathcal{N} ( \frac{100 + b\hspace{1pt}' \frac{\sigma\_y}{\sigma\_x} \overline{x} - \overline{y} }{\sigma\_y}, \hspace{1pt} \frac{1}{\sigma\_y})

b\hspace{1pt}' \sim \mathcal{N} ( 5 \frac{\sigma\_x}{\sigma\_y}, \hspace{1pt} \frac{2}{\sigma\_y})

Again, a\hspace{1pt}' and b\hspace{1pt}' would be the standardized expressions.

Yet one question still remains: how are the priors correctly included in rstanarm functions? If I understand correctly, I would have to set `autoscale = FALSE` in a `normal()` function when using standardized priors, and `autoscale = TRUE` if I use non-standardized priors. So is `autoscale` actually applying the abovementioned transformation, or is it doing something different? Also, will rstanarm functions always standardize my data before running the model?
