Nonlinear model using pnorm in brms

Please also provide the following information in addition to your question:

  • Operating System: Win 10
  • brms Version: 2.4.3

I’m trying to do a nonlinear regression involving the pnorm function. Seems brm does not like my using the pnorm function. I’m trying to test something out, which is why I don’t want to use logit, which I know will work. For simplicity, I’ve recreated probit regression as a nonlinear model:

x <- rnorm(1000)
p <- pnorm(x)
y <- rbinom(1000,prob=p,size=1)

brm.out <- brm(bf(y~pnorm(eta),eta~x,family=bernoulli(“identity”),nl=T),
data=dat,inits = “random”, chains = 1, iter = 1000, warmup = floor(1000/2),thin = 1,

I get the following error:


No matches for:


Function pnorm not found.
error in ‘model34a443cc57c7_file34a4e3c531’ at line 23, column 30

21:   for (n in 1:N) { 
22:     // compute non-linear predictor 
23:     mu[n] = pnorm(nlp_eta[n]);
24:   } 

Error in stanc(model_code = paste(program, collapse = “\n”), model_name = model_cppname, :
failed to parse Stan model ‘file34a4e3c531’ due to the above error.

Any ideas on how to code pnorm so brm will like it?

pnorm is not defined in the Stan language. If you look at


it will tell you several Stan functions that correspond to the pnorm function in R, and the one you want is Phi.

1 Like