I am trying to define a non-linear model in Brms using “integrate_1d” but I am having problems dealing with the type of parameter arguments passed to integrate_1d.

Here is a simplified version of the code:

```
wtpdata <- read.table(".../wtpdata_test.csv", header=TRUE, sep=",")
stan_funs <- "
real integrand(real x, real xc, real[] theta, real[] x_r, int[] x_i) {
real a = theta[1];
real p = x_r[1];
return exp(-(-log(x*p))^a);
}
real integralfun(data real p, real a, data int xi) {
return integrate_1d(integrand, 0.0, 1.0, {a}, {p}, {xi}, 0.01);
}
"
stanvars <- stanvar(scode = stan_funs, block = "functions")
nlform <- bf(wtp ~ integralfun(prob, a, id), a ~ (1|id), nl = TRUE)
nlprior <- c(prior(lognormal(2, 1), lb=0, nlpar = "a"))
fit2 <- brm(formula = nlform, data = wtpdata, family = zero_one_inflated_beta,
prior = nlprior, control = list(adapt_delta = 0.9), stanvars = stanvars)
```

Here is a link to the test dataset: wtpdata_test

Here is the error message I get:

Error in compileCode(f, code, language = language, verbose = verbose) : ^/Library/Frameworks/R.framework/Versions/4.1/Resources/library/StanHeaders/include/stan/math/prim/arr/functor/integrate_1d.hpp:195:15: note: candidate function template not viable: no known conversion from ‘vector<local_scalar_t__>’ to ‘const vector’ for 4th argument in line double integrate_1d( ^22 warnings and 1 error generated.make: *** [file5c9845fad7bc.o] Error 1

Error in sink(type = “output”) : invalid connection

- Operating System: MacOS 11.2.3
- brms Version: 2.15.0