# Relative Risk (RR) and absolute reduction in relative risk (ARR) with stan\_glm

**URL:** <https://discourse.mc-stan.org/t/relative-risk-rr-and-absolute-reduction-in-relative-risk-arr-with-stan-glm/15446>\
**Category:** rstanarm\
**Tags:** example-models, mixed-model, simulation-based-calibration, model-comparison, hierarchical-model\
**Created:** [May 28, 2020, 11:39am UTC](https://discourse.mc-stan.org/t/relative-risk-rr-and-absolute-reduction-in-relative-risk-arr-with-stan-glm/15446 "2020-05-28T11:39:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rani](https://avatars.discourse-cdn.com/v4/letter/r/f4b2a3/32.png) [@Rani](https://discourse.mc-stan.org/u/Rani)\
**Post date:** [May 28, 2020, 11:39am UTC](https://discourse.mc-stan.org/t/relative-risk-rr-and-absolute-reduction-in-relative-risk-arr-with-stan-glm/15446/1 "2020-05-28T11:39:48Z")

</div>

Dear all,  
I would like o to ask about the choice of the family to use to compute RR and ARR,  
normally for RR I should choose these families in these lines

```
> str(mydata)

'data.frame':	190 obs. of 2 variables:
 $ treat: int 1 1 1 1 1 1 1 1 1 1 ...
 $ death: int 1 0 0 0 0 0 0 1 0 0 ...

> model_OR = stan_glm(death~treat, data = mydata,
+ family = binomial(link = "logit"), 
+ prior = normal(location =0, scale = 10),
                      prior_intercept = normal(location =0, scale = 10) , 
                      QR=FALSE,
+ seed = 12345,
+ refresh = 0)

> OR = exp(coef(model_OR)[2])

> OR
    treat 
0.5749312 

> model_RR = stan_glm(death~treat, data = mydata,
+ family = binomial(link = "log"), 
+ prior = normal(location =0, scale = 10), 
           prior_intercept = normal(location =0, scale = 10) , 
            QR=FALSE,
+ seed = 12345,
+ refresh = 0)

> RR = exp(coef(model_RR)[2])

> RR
    treat 
0.6721806 

> model_ARR = stan_glm(death~treat, data = mydata,
+ family = binomial(link = "identity"), 
+ prior = normal(location =0, scale = 10), 
                      prior_intercept = normal(location =0, scale = 10) , 
                      QR=FALSE,
+ seed = 12345,
+ refresh = 0)

Error in stan_glm.fit(x = X, y = Y, weights = weights, offset = offset, : 
  'link' must be one of logit, probit, cauchit, log, cloglog

ARR = coef(model_ARR)[2]

```

Is it the correct families? if so, what is the correction for the last one?

and thanks in advance.

---

<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:** [May 28, 2020, 12:19pm UTC](https://discourse.mc-stan.org/t/relative-risk-rr-and-absolute-reduction-in-relative-risk-arr-with-stan-glm/15446/2 "2020-05-28T12:19:54Z")

</div>

Those are both legal syntax. I suspect the problem is with whatever you are specifying for `prior_intercept`. If the inverse link function is insufficient to make the probabilities between zero and one, then the intercept has to be such that the constraint is satisfied.

---

<div class="post-metadata">

**Author:** ![Rani](https://avatars.discourse-cdn.com/v4/letter/r/f4b2a3/32.png) [@Rani](https://discourse.mc-stan.org/u/Rani)\
**Post date:** [May 28, 2020, 12:27pm UTC](https://discourse.mc-stan.org/t/relative-risk-rr-and-absolute-reduction-in-relative-risk-arr-with-stan-glm/15446/3 "2020-05-28T12:27:13Z")

</div>

I updated the post

---

<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:** [May 28, 2020, 2:07pm UTC](https://discourse.mc-stan.org/t/relative-risk-rr-and-absolute-reduction-in-relative-risk-arr-with-stan-glm/15446/4 "2020-05-28T14:07:12Z")

</div>

> [@Rani](#):
>
> `family = binomial(link = "identity")`

that is supposed to work, but apparently it does not. But you cannot have a `normal(location = 0, scale = 10)` prior on the intercept when you specify a link function that does not ensure that the probabilities are between 0 and 1.

---

<div class="post-metadata">

**Author:** ![Rani](https://avatars.discourse-cdn.com/v4/letter/r/f4b2a3/32.png) [@Rani](https://discourse.mc-stan.org/u/Rani)\
**Post date:** [May 28, 2020, 6:29pm UTC](https://discourse.mc-stan.org/t/relative-risk-rr-and-absolute-reduction-in-relative-risk-arr-with-stan-glm/15446/5 "2020-05-28T18:29:30Z")

</div>

but for

```
gaussian(link="identity")

```

it works well and give closed results to the exact ones, dose this mean this family is true or just by coincidence, and what about the family of RR is it true?

---

<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:** [May 29, 2020, 1:55am UTC](https://discourse.mc-stan.org/t/relative-risk-rr-and-absolute-reduction-in-relative-risk-arr-with-stan-glm/15446/6 "2020-05-29T01:55:59Z")

</div>

`gaussian(link = "identity")` can’t be right if the outcomes are binary.
