# Parsing error with random effect in brms

**URL:** <https://discourse.mc-stan.org/t/parsing-error-with-random-effect-in-brms/34063>\
**Category:** brms\
**Tags:** brms, cmdstanr\
**Created:** [February 8, 2024, 2:14pm UTC](https://discourse.mc-stan.org/t/parsing-error-with-random-effect-in-brms/34063 "2024-02-08T14:14:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sven\_De\_Maeyer](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/sven_de_maeyer/32/10872_2.png) [@Sven\_De\_Maeyer](https://discourse.mc-stan.org/u/Sven_De_Maeyer)\
**Post date:** [February 8, 2024, 2:14pm UTC](https://discourse.mc-stan.org/t/parsing-error-with-random-effect-in-brms/34063/1 "2024-02-08T14:14:00Z")

</div>

I am using brms 2.18.0 and get an error message when estimating a model with a random effect.

This is the model code:

```no-highlight
M1 <- brm(
  fluency ~ 1 + Occ2*FL + Occ2*MT + Occ3*FL + Occ3*MT + (1|student) ,
  data = Subtitles,
  cores = 4,
  backend = "cmdstanr",
  seed = 1975,
  prior = Custom_prior1
)

```

This generates the following error:

```no-highlight
Syntax error in '/var/folders/x9/dk2f_b5575ddx5s7sscrgtch0000gn/T/RtmpkeCz4K/model_ca7319f434761380a27341051b9df070.stan', line 12, column 18 to column 19, parsing error:
   -------------------------------------------------
    10: int<lower=1> N_1; // number of grouping levels
    11: int<lower=1> M_1; // number of coefficients per level
    12: int<lower=1> J_1[N]; // grouping indicator per observation
                           ^
    13: // group-level predictor values
    14: vector[N] Z_1_1;
   -------------------------------------------------

";" expected after variable declaration.

Error: Syntax error found! See the message above for more information.

```

When leaving out the `+(1|student)` in the model, the model compiles and gets estimated.

I have no clue what’s happening. But could it be due to the fact that I updated my laptop to macOS Sonoma (v. 14.3)?

Thanks for your help

---

<div class="post-metadata">

**Author:** ![wpetry](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/wpetry/32/4852_2.png) [@wpetry](https://discourse.mc-stan.org/u/wpetry)\
**Post date:** [February 8, 2024, 4:41pm UTC](https://discourse.mc-stan.org/t/parsing-error-with-random-effect-in-brms/34063/2 "2024-02-08T16:41:55Z")

</div>

Under the hood, `brms` translates your formula to raw Stan code and passes the code off to cmdstan to run it. I think this error is because your version of `brms` is doing this translation using an older, now deprecated Stan syntax. Your model fits when you remove the random group-level intercept term for student because the problematic line containing the old syntax isn’t added in.

I suggest updating to the latest versions of these tools:

1. Restart a fresh R session
2. Update `brms` package the usual way
3. Update `cmdstanr` package, then run `cmdstanr::install_cmdstan()`to make sure cmdstan is up to date. This step _may_ not be necessary since it looks like your Stan version is newer and is not allowing the older syntax. Still, it’d be a good idea and might help avoid other version incompatibilities.
4. Re-try your code

If you’re still getting an error, let us know.

---

<div class="post-metadata">

**Author:** ![Sven\_De\_Maeyer](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/sven_de_maeyer/32/10872_2.png) [@Sven\_De\_Maeyer](https://discourse.mc-stan.org/u/Sven_De_Maeyer)\
**Post date:** [February 9, 2024, 10:24am UTC](https://discourse.mc-stan.org/t/parsing-error-with-random-effect-in-brms/34063/3 "2024-02-09T10:24:08Z")

</div>

Thanks! Makes perfect sense. I updated everything and the error is gone.
