Multivariate nonlinear model in brms with "The following priors do not correspond to any model parameter" error

Hi all,

I’m trying to estimate a system of equations as a multivariate nonlinear model, as part of an attempt to estimate an econometric model. However, I keep running into the following error:

Error: The following priors do not correspond to any model parameter: 
b_log(z1)_E1 ~ normal(0, 1)
<upper=0> b_log(z1)_E2 ~ normal(-0.09, 0.04)

Proceeding to list all the priors in my model in this manner.

My code is below:

z1_fm <- formula(log(z1) ~  E1 + E2*((log(z2) + log(z3)) + E3*log(y1) + (1-E3)*log(z5) + ((E2)/(-1))*log(z6))
x1_fm <- formula(log(x1) ~  W1 + W2*(log(x2)  - log(x3))+ W3*log(x4)+(1-W3)*log(x5)+W4*(x6))
y1_fm <- formula(log(y1) ~ P1 + P2*(log(x1) - log(y3)) -1*P2*log(y4))

bf_x1 <- brmsformula(x1_fm, nonlinear = W1+W2+W3+W4~1, nl = TRUE)
bf_y1 <- brmsformula(y1_fm, nonlinear = P1+P2~1, nl = TRUE)
bf_z1 <- brmsformula(z1_fm, nonlinear = E1+E2+E3~1, nl = TRUE)

priors_xyz <- prior(normal(0,1),nlpar = E1, resp = "log(z1)") + prior(normal(-0.09,0.04),nlpar = E2, ub = 0, resp = "log(z1)") + prior(normal(0.30,0.08),nlpar = E3, ub = 1, lb = 0, resp = "log(z1)") + prior(normal(0,1),nlpar = W1, resp = "log(x1)") + prior(normal(-0.1,0.05),nlpar = W2, ub = 0, resp = "log(x1)") + prior(normal(0.5,0,2),nlpar = W3, ub = 1, lb = 0, resp = "log(x1)")+ prior(normal(-0.002,0.001),nlpar = W4, ub = 0, resp = "log(x1)") + prior(normal(0,1),nlpar = P1, resp = "log(y1)") + prior(normal(-0.1,0.05),nlpar = P2, ub = 0, resp = "log(y1)")

eq_wpe <- brm(bf_x1 + bf_y1 + bf_z1 + set_rescor(rescor = TRUE), prior = priors_xyz, data = DATA_EXTRACT, control = list(adapt_delta = 0.90), cores = 4)

My ultimate aim is to have some parameters shared across the equations (so the -1 in the first equation at ((E2)/(-1))*log(z6)) would eventually be replaced by W2) but I thought I would try and troubleshoot without the added complication of sharing parameters first- one step at a time and all.

I would greatly appreciate any advice or support on where I may be going wrong and what is causing this error!

The get_prior() function can help you figure out how to specify the priors so that brms understands them.

get_prior(
  bf_x1 + bf_y1 + bf_z1 + set_rescor(rescor = TRUE),
  data = DATA_EXTRACT
)
#>                 prior  class      coef group  resp dpar nlpar lb ub
#>                (flat)      b                                       
#>                lkj(1) rescor                                       
#>  student_t(3, 0, 2.5)  sigma                 logx1             0   
#>                (flat)      b                 logx1         W1      
#>                (flat)      b Intercept       logx1         W1      
#>                (flat)      b                 logx1         W2      
#>                (flat)      b Intercept       logx1         W2      
#> .....  

Notice that the response is denoted logx1 and not log(x1). So try changing:

prior(normal(0, 1), nlpar = W1, resp = "log(x1)")

to:

prior(normal(0, 1), nlpar = W1, resp = "logx1")

and so on for all the priors on the non-linear parameters.

1 Like