# Correlation specification in non-linear brms model

**URL:** <https://discourse.mc-stan.org/t/correlation-specification-in-non-linear-brms-model/36301>\
**Category:** Modeling\
**Tags:** brms\
**Created:** [August 19, 2024, 8:55am UTC](https://discourse.mc-stan.org/t/correlation-specification-in-non-linear-brms-model/36301 "2024-08-19T08:55:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abic289](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/abic289/32/18992_2.png) [@Abic289](https://discourse.mc-stan.org/u/Abic289)\
**Post date:** [August 19, 2024, 8:55am UTC](https://discourse.mc-stan.org/t/correlation-specification-in-non-linear-brms-model/36301/1 "2024-08-19T08:55:09Z")

</div>

Hello,

I am fitting a piece-wise linear mixed model with a random change-point, very similar to the model in this topic: [Piecewise Linear Mixed Models With a Random Change Point](https://discourse.mc-stan.org/t/piecewise-linear-mixed-models-with-a-random-change-point/5306/15). In my model, the first slope (slope1), change-point (knot) and Intercept are the random effects.

However, my model is struggling to fit when I allow the correlation between all random effects to be estimated, using:

```stan
Intercept + slope1 + knot ~ 1 + (1|a|subjid)

```

I would therefore like to investigate pairwise combinations of correlations. For instance, how do I allow for correlation between the Intercept and slope1 as well as between slope1 and knot but **not** allow for correlation between Intercept and knot? I.e. I want to constrain the correlation between Intercept and knot to be 0 but allow the other two correlations to be estimated. I tried the following code but (unsurprisingly) it did not do what I wanted:

```stan
Intercept + slope1 ~ 1 + (1|a|subjid),
knot + slope1 ~ 1 + (1|b|subjid)

```

---

<div class="post-metadata">

**Author:** ![Ax3man](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/ax3man/32/11894_2.png) [@Ax3man](https://discourse.mc-stan.org/u/Ax3man)\
**Post date:** [August 19, 2024, 5:15pm UTC](https://discourse.mc-stan.org/t/correlation-specification-in-non-linear-brms-model/36301/2 "2024-08-19T17:15:21Z")

</div>

You can fix certain parameters by using a constant prior, see `?constant`. Perhaps that will work for your case?
