I am attempting to fit a non-liner model with brms but keep getting the following error:

Compiling Stan program…

Error in stanc(file = file, model_code = model_code, model_name = model_name, : 0

Syntax error in ‘string’, line 27, column 38 to column 39, parsing error:

Ill-formed expression. Found identifier. There are many ways to complete this to a well-formed expression.

R 4.2.2

brms 2.18.0

Operating System: Windows 10

Code that reproduces error but with simulated data.

```
library(brms)
#simulate data
set.seed <- 1234
age <- rep(seq(1,10,1),10)
Linf <- 750
K <- 0.5
t0 <- -1.2
noise <- rnorm(length(age),0,35)
tl <- Linf * (1 - exp(-K * (age - t0))) + noise
#Package data
datalst <- data.frame(tl = tl,age=age)
#Set formula
formula <- bf(tl ~ Linf * (1 - exp(-K * (age - t0))),
# Nonlinear variables
Linf + K + t0 ~ 1,
#Nonlinear fit
nl = TRUE)
#Set priors
prior1 <- prior("normal(mean = 600, sd = 100)", nlpar = "Linf") +
prior("normal(mean = 0, sd = 1)", nlpar = "K") +
prior("normal(mean = 0, sd = 5)", nlpar = "t0")
#Set initial values
inits <- list(
Linf = 600,
K = 0.1,
t0 = 2
)
fit1 <- brm(formula,
family=gaussian(),
data = datalst,
prior = prior1,
init = inits,
chains=3,
cores=3,
iter=4000,
warmup = 2000)
#Check code for line 27
stancode <- make_stancode(formula,
family=gaussian(),
data = datalst,
prior = prior1)
```

Line 27 from the stan code is:

```
lprior += normal_lpdf(b_Linf | mean = 600, sd = 100);
```

This does not look suspect to me. I have tried different means and sd for the prior and keep getting the same error.

I am able to run the nonlinear model example at:

https://cran.r-project.org/web/packages/brms/vignettes/brms_nonlinear.html

Which makes me think there is something wrong with the model I am specifying. But I don’t know how that connects to line 27 since the prior on b_Linf looks correct.

Thanks in advance for any help!

Jason