# Shared parameters in multiple models

**URL:** <https://discourse.mc-stan.org/t/shared-parameters-in-multiple-models/26170>\
**Category:** brms\
**Created:** [January 31, 2022, 7:29pm UTC](https://discourse.mc-stan.org/t/shared-parameters-in-multiple-models/26170 "2022-01-31T19:29:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bdeonovic](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bdeonovic/32/10527_2.png) [@bdeonovic](https://discourse.mc-stan.org/u/bdeonovic)\
**Post date:** [January 31, 2022, 7:29pm UTC](https://discourse.mc-stan.org/t/shared-parameters-in-multiple-models/26170/1 "2022-01-31T19:29:04Z")

</div>

I have the following model

```
  bf(rel_size ~ eta,
     nlf(eta ~ A + K * inv_logit(-exp(slope) *(log10(dose) - gamma) ) ),
     A ~ 0 + insect + (1|qq|experiment),
     K ~ 0 + insect + (1|qq|experiment),
     slope ~ 0 + insect + (1|qq|experiment),
     gamma ~ 0 + insect + offset(delta) + (1|qq|experiment),
     nl = TRUE)

```

However I have data where `dose` is 0, which causes gradients to explode. For this particular model the likelihood is well defined as dose → 0 (eta → A + K). When I have written such a model in pure stan (without the grouping effects) I write something like this

```
...
    // compute non-linear predictor values
    if (dose[n] == 0){
      mu[n] = A + K;
    }else{
      mu[n] = A + K / (1 + exp( exp(slope) * (log10(dose[n]) - gamma)));
    }
}
...

```

How would I achieve something similar with brms? One way would be if one could provide multiple models to brms with shared parameters, but I don’t think thats currently possible? Is there any other way?
