Syntax error brms multivariate model

Hi,

I’m trying to estimate a multivariate multiple membership model using brms. I’m only getting started so are first estimating an intercept only model. When using univariate models, everything seems OK but I get an error message when trying the multivariate syntax.

This is my syntax:

intercept.model ← brm(mvbind(PMindT3, PMastT3, PApT3, PAvT3, PExT3) ~ 1 + (1 |p| mm(T1_ID, T2_ID, T3_ID, T4_ID, weights = cbind(W_T1, W_T2, W_T3, W_T4))) + (1 |q| mm(C1_ID, C2_ID, C3_ID, C4_ID, weights = cbind(W_C1, W_C2, W_C3, W_C4))), data=d_main, family=skew_normal())

And this is the error message

Setting ‘rescor’ to FALSE by default for this model
SYNTAX ERROR, MESSAGE(S) FROM PARSER:
variable “W_1_1” does not exist.
error in ‘model3ffd3cdae4a7_file3ffd36f7a69a’ at line 207, column 27 -------------------------------------------------
205: real omega_PExT3;
206: for (n in 1:N_PMindT3) {
207: mu_PMindT3[n] += W_1_1[n] * r_1_PMindT3_1[J_1_PMindT3_1[n]] * Z_1_PMindT3_1_1[n] + W_1_2[n] * r_1_PMindT3_1[J_1_PMindT3_2[n]] * Z_1_PMindT3_1_2[n] + W_1_3[n] * r_1_PMindT3_1[J_1_PMindT3_3[n]] * Z_1_PMindT3_1_3[n] + W_1_4[n] * r_1_PMindT3_1[J_1_PMindT3_4[n]] * Z_1_PMindT3_1_4[n] + W_2_1[n] * r_2_PMindT3_1[J_2_PMindT3_1[n]] * Z_2_PMindT3_1_1[n] + W_2_2[n] * r_2_PMindT3_1[J_2_PMindT3_2[n]] * Z_2_PMindT3_1_2[n] + W_2_3[n] * r_2_PMindT3_1[J_2_PMindT3_3[n]] * Z_2_PMindT3_1_3[n] + W_2_4[n] * r_2_PMindT3_1[J_2_PMindT3_4[n]] * Z_2_PMindT3_1_4[n];
^ 208: } -------------------------------------------------
Error in stanc(model_code = paste(program, collapse = “\n”), model_name = model_cppname, :
failed to parse Stan model ‘file3ffd36f7a69a’ due to the above error.
In addition: Warning message:
Rows containing NAs were excluded from the model.
SYNTAX ERROR, MESSAGE(S) FROM PARSER:
variable “W_1_1” does not exist.
error in ‘model3ffd7d7a4dc7_file3ffd36f7a69a’ at line 207, column 27
------------------------------------------------- 205: real omega_PExT3;
206: for (n in 1:N_PMindT3) {
207: mu_PMindT3[n] += W_1_1[n] * r_1_PMindT3_1[J_1_PMindT3_1[n]] * Z_1_PMindT3_1_1[n] + W_1_2[n] * r_1_PMindT3_1[J_1_PMindT3_2[n]] * Z_1_PMindT3_1_2[n] + W_1_3[n] * r_1_PMindT3_1[J_1_PMindT3_3[n]] * Z_1_PMindT3_1_3[n] + W_1_4[n] * r_1_PMindT3_1[J_1_PMindT3_4[n]] * Z_1_PMindT3_1_4[n] + W_2_1[n] * r_2_PMindT3_1[J_2_PMindT3_1[n]] * Z_2_PMindT3_1_1[n] + W_2_2[n] * r_2_PMindT3_1[J_2_PMindT3_2[n]] * Z_2_PMindT3_1_2[n] + W_2_3[n] * r_2_PMindT3_1[J_2_PMindT3_3[n]] * Z_2_PMindT3_1_3[n] + W_2_4[n] * r_2_PMindT3_1[J_2_PMindT3_4[n]] * Z_2_PMindT3_1_4[n];
^
208: }
-------------------------------------------------Error in stanc(model_code = paste(program, collapse = “\n”), model_name = model_cppname, :
failed to parse Stan model ‘file3ffd36f7a69a’ due to the above error.

Any ideas what I’m doing wrong?

Thanks

Does someone know where else I can seek help if no one has an idea here? Thanks.

Which version of brms are you using? If the error still occurs with brms 2.9.0 (current CRAN version), can you please provide a minimal reproducible example of this error for me to check what’s going wrong?

You may also want to open an issue on https://github.com/paul-buerkner/brms/issues so that we better keep track of fixing this problem, if it turns out being a bug.

I’m using version 2.9.0. Sorry, I should have mentioned that before. So you mean I should send you my data and syntax?

Ideally only a small subset of the data (or simulated data) and only minimal code to that is sufficient to reproduce the error you see. Otherwise, it is super hard for me to work through all the code people send me to extract what’s relevant to reproduce the problem.

Thanks for the clarification. Here are the data and syntax files. d_subset.csv (74.3 KB) syntax_pia.R (958 Bytes)

Thanks a lot for providing a reproducible example! The problem is now fixed in the github version of brms to be installed via

if (!requireNamespace("devtools")) {
  install.packages("devtools")
}
devtools::install_github("paul-buerkner/brms")

Brilliant! Thanks so much for your quick help. I’ll try it tomorrow.

Hi Paul,

I ran into the same issue again using a more complicated model. The estimation for the univariate models work fine but as soon as I estimate the models together using the multivariate context, I get the error message:

SYNTAX ERROR, MESSAGE(S) FROM PARSER:
variable “W_1_1” does not exist.
error in ‘model159d15fabbf49_file159d15d07c1f’ at line 833, column 67-------------------------------------------------
831: }
832: for (n in 1:N_asorderedPMalAttT3) {
833: mu_asorderedPMalAttT3[n] += (bsp_asorderedPMalAttT3[1] + W_1_1[n] * r_1_asorderedPMalAttT3_55[J_1_asorderedPMalAttT3_1[n]] + W_1_2[n] * r_1_asorderedPMalAttT3_55[J_1_asorderedPMalAttT3_2[n]] + W_1_3[n] * r_1_asorderedPMalAttT3_55[J_1_asorderedPMalAttT3_3[n]] + W_1_4[n] * r_1_asorderedPMalAttT3_55[J_1_asorderedPMalAttT3_4[n]]) * mo(simo_asorderedPMalAttT3_1, Xmo_asorderedPMalAttT3_1[n]) + (bsp_asorderedPMalAttT3[1] + W_2_1[n] * r_2_asorderedPMalAttT3_55[J_2_asorderedPMalAttT3_1[n]] + W_2_2[n] * r_2_asorderedPMalAttT3_55[J_2_asorderedPMalAttT3_2[n]] + W_2_3[n] * r_2_asorderedPMalAttT3_55[J_2_asorderedPMalAttT3_3[n]] + W_2_4[n] * r_2_asorderedPMalAttT3_55[J_2_asorderedPMalAttT3_4[n]]) * mo(simo_asorderedPMalAttT3_1, Xmo_asorderedPMalAttT3_1[n]) + W_1_asorderedPMalAttT3_1[n] * r_1_asorderedPMalAttT3_47[J_1_asorderedPMalAttT3_1[n]] * Z_1_asorderedPMalAttT3_47_1[n] + W_1_asorderedPMalAttT3_2[n] * r_1_asorderedPMalAttT3_47[J_1_asorderedPMalAttT3_2[n]] * Z_1_asorderedPMalAttT3_47_2[n] + W_1_asorderedPMalAttT3_3[n] * r_1_asorderedPMalAttT3_47[J_1_asorderedPMalAttT3_3[n]] * Z_1_asorderedPMalAttT3_47_3[n] + W_1_asorderedPMalAttT3_4[n] * r_1_asorderedPMalAttT3_47[J_1_asorderedPMalAttT3_4[n]] * Z_1_asorderedPMalAttT3_47_4[n] + W_1_asorderedPMalAttT3_1[n] * r_1_asorderedPMalAttT3_48[J_1_asorderedPMalAttT3_1[n]] * Z_1_asorderedPMalAttT3_48_1[n] + W_1_asorderedPMalAttT3_2[n] * r_1_asorderedPMalAttT3_48[J_1_asorderedPMalAttT3_2[n]] * Z_1_asorderedPMalAttT3_48_2[n] + W_1_asorderedPMalAttT3_3[n] * r_1_asorderedPMalAttT3_48[J_1_asorderedPMalAttT3_3[n]] * Z_1_asorderedPMalAttT3_48_3[n] + W_1_asorderedPMalAttT3_4[n] * r_1_asorderedPMalAttT3_48[J_1_asorderedPMalAttT3_4[n]] * Z_1_asorderedPMalAttT3_48_4[n] + W_1_asorderedPMalAttT3_1[n] * r_1_asorderedPMalAttT3_49[J_1_asorderedPMalAttT3_1[n]] * Z_1_asorderedPMalAttT3_49_1[n] + W_1_asorderedPMalAttT3_2[n] * r_1_asorderedPMalAttT3_49[J_1_asorderedPMalAttT3_2[n]] * Z_1_asorderedPMalAttT3_49_2[n] + W_1_asorderedPMalAttT3_3[n] * r_1_asorderedPMalAttT3_49[J_1_asorderedPMalAttT3_3[n]] * Z_1_asorderedPMalAttT3_49_3[n] + W_1_asorderedPMalAttT3_4[n] * r_1_asorderedPMalAttT3_49[J_1_asorderedPMalAttT3_4[n]] * Z_1_asorderedPMalAttT3_49_4[n] + W_1_asorderedPMalAttT3_1[n] * r_1_asorderedPMalAttT3_50[J_1_asorderedPMalAttT3_1[n]] * Z_1_asorderedPMalAttT3_50_1[n] + W_1_asorderedPMalAttT3_2[n] * r_1_asorderedPMalAttT3_50[J_1_asorderedPMalAttT3_2[n]] * Z_1_asorderedPMalAttT3_50_2[n] + W_1_asorderedPMalAttT3_3[n] * r_1_asorderedPMalAttT3_50[J_1_asorderedPMalAttT3_3[n]] * Z_1_asorderedPMalAttT3_50_3[n] + W_1_asorderedPMalAttT3_4[n] * r_1_asorderedPMalAttT3_50[J_1_asorderedPMalAttT3_4[n]] * Z_1_asorderedPMalAttT3_50_4[n] + W_1_asorderedPMalAttT3_1[n] * r_1_asorderedPMalAttT3_51[J_1_asorderedPMalAttT3_1[n]] * Z_1_asorderedPMalAttT3_51_1[n] + W_1_asorderedPMalAttT3_2[n] * r_1_asorderedPMalAttT3_51[J_1_asorderedPMalAttT3_2[n]] * Z_1_asorderedPMalAttT3_51_2[n] + W_1_asorderedPMalAttT3_3[n] * r_1_asorderedPMalAttT3_51[J_1_asorderedPMalAttT3_3[n]] * Z_1_asorderedPMalAttT3_51_3[n] + W_1_asorderedPMalAttT3_4[n] * r_1_asorderedPMalAttT3_51[J_1_asorderedPMalAttT3_4[n]] * Z_1_asorderedPMalAttT3_51_4[n] + W_1_asorderedPMalAttT3_1[n] * r_1_asorderedPMalAttT3_52[J_1_asorderedPMalAttT3_1[n]] * Z_1_asorderedPMalAttT3_52_1[n] + W_1_asorderedPMalAttT3_2[n] * r_1_asorderedPMalAttT3_52[J_1_asorderedPMalAttT3_2[n]] * Z_1_asorderedPMalAttT3_52_2[n] + W_1_asorderedPMalAttT3_3[n] * r_1_asorderedPMalAttT3_52[J_1_asorderedPMalAttT3_3[n]] * Z_1_asorderedPMalAttT3_52_3[n] + W_1_asorderedPMalAttT3_4[n] * r_1_asorderedPMalAttT3_52[J_1_asorderedPMalAttT3_4[n]] * Z_1_asorderedPMalAttT3_52_4[n] + W_1_asorderedPMalAttT3_1[n] * r_1_asorderedPMalAttT3_53[J_1_asorderedPMalAttT3_1[n]] * Z_1_asorderedPMalAttT3_53_1[n] + W_1_asorderedPMalAttT3_2[n] * r_1_asorderedPMalAttT3_53[J_1_asorderedPMalAttT3_2[n]] * Z_1_asorderedPMalAttT3_53_2[n] + W_1_asorderedPMalAttT3_3[n] * r_1_asorderedPMalAttT3_53[J_1_asorderedPMalAttT3_3[n]] * Z_1_asorderedPMalAttT3_53_3[n] + W_1_asorderedPMalAttT3_4[n] * r_1_asorderedPMalAttT3_53[J_1_asorderedPMalAttT3_4[n]] * Z_1_asorderedPMalAttT3_53_4[n] + W_1_asorderedPMalAttT3_1[n] * r_1_asorderedPMalAttT3_54[J_1_asorderedPMalAttT3_1[n]] * Z_1_asorderedPMalAttT3_54_1[n] + W_1_asorderedPMalAttT3_2[n] * r_1_asorderedPMalAttT3_54[J_1_asorderedPMalAttT3_2[n]] * Z_1_asorderedPMalAttT3_54_2[n] + W_1_asorderedPMalAttT3_3[n] * r_1_asorderedPMalAttT3_54[J_1_asorderedPMalAttT3_3[n]] * Z_1_asorderedPMalAttT3_54_3[n] + W_1_asorderedPMalAttT3_4[n] * r_1_asorderedPMalAttT3_54[J_1_asorderedPMalAttT3_4[n]] * Z_1_asorderedPMalAttT3_54_4[n] + W_2_asorderedPMalAttT3_1[n] * r_2_asorderedPMalAttT3_47[J_2_asorderedPMalAttT3_1[n]] * Z_2_asorderedPMalAttT3_47_1[n] + W_2_asorderedPMalAttT3_2[n] * r_2_asorderedPMalAttT3_47[J_2_asorderedPMalAttT3_2[n]] * Z_2_asorderedPMalAttT3_47_2[n] + W_2_asorderedPMalAttT3_3[n] * r_2_asorderedPMalAttT3_47[J_2_asorderedPMalAttT3_3[n]] * Z_2_asorderedPMalAttT3_47_3[n] + W_2_asorderedPMalAttT3_4[n] * r_2_asorderedPMalAttT3_47[J_2_asorderedPMalAttT3_4[n]] * Z_2_asorderedPMalAttT3_47_4[n] + W_2_asorderedPMalAttT3_1[n] * r_2_asorderedPMalAttT3_48[J_2_asorderedPMalAttT3_1[n]] * Z_2_asorderedPMalAttT3_48_1[n] + W_2_asorderedPMalAttT3_2[n] * r_2_asorderedPMalAttT3_48[J_2_asorderedPMalAttT3_2[n]] * Z_2_asorderedPMalAttT3_48_2[n] + W_2_asorderedPMalAttT3_3[n] * r_2_asorderedPMalAttT3_48[J_2_asorderedPMalAttT3_3[n]] * Z_2_asorderedPMalAttT3_48_3[n] + W_2_asorderedPMalAttT3_4[n] * r_2_asorderedPMalAttT3_48[J_2_asorderedPMalAttT3_4[n]] * Z_2_asorderedPMalAttT3_48_4[n] + W_2_asorderedPMalAttT3_1[n] * r_2_asorderedPMalAttT3_49[J_2_asorderedPMalAttT3_1[n]] * Z_2_asorderedPMalAttT3_49_1[n] + W_2_asorderedPMalAttT3_2[n] * r_2_asorderedPMalAttT3_49[J_2_asorderedPMalAttT3_2[n]] * Z_2_asorderedPMalAttT3_49_2[n] + W_2_asorderedPMalAttT3_3[n] * r_2_asorderedPMalAttT3_49[J_2_asorderedPMalAttT3_3[n]] * Z_2_asorderedPMalAttT3_49_3[n] + W_2_asorderedPMalAttT3_4[n] * r_2_asorderedPMalAttT3_49[J_2_asorderedPMalAttT3_4[n]] * Z_2_asorderedPMalAttT3_49_4[n] + W_2_asorderedPMalAttT3_1[n] * r_2_asorderedPMalAttT3_50[J_2_asorderedPMalAttT3_1[n]] * Z_2_asorderedPMalAttT3_50_1[n] + W_2_asorderedPMalAttT3_2[n] * r_2_asorderedPMalAttT3_50[J_2_asorderedPMalAttT3_2[n]] * Z_2_asorderedPMalAttT3_50_2[n] + W_2_asorderedPMalAttT3_3[n] * r_2_asorderedPMalAttT3_50[J_2_asorderedPMalAttT3_3[n]] * Z_2_asorderedPMalAttT3_50_3[n] + W_2_asorderedPMalAttT3_4[n] * r_2_asorderedPMalAttT3_50[J_2_asorderedPMalAttT3_4[n]] * Z_2_asorderedPMalAttT3_50_4[n] + W_2_asorderedPMalAttT3_1[n] * r_2_asorderedPMalAttT3_51[J_2_asorderedPMalAttT3_1[n]] * Z_2_asorderedPMalAttT3_51_1[n] + W_2_asorderedPMalAttT3_2[n] * r_2_asorderedPMalAttT3_51[J_2_asorderedPMalAttT3_2[n]] * Z_2_asorderedPMalAttT3_51_2[n] + W_2_asorderedPMalAttT3_3[n] * r_2_asorderedPMalAttT3_51[J_2_asorderedPMalAttT3_3[n]] * Z_2_asorderedPMalAttT3_51_3[n] + W_2_asorderedPMalAttT3_4[n] * r_2_asorderedPMalAttT3_51[J_2_asorderedPMalAttT3_4[n]] * Z_2_asorderedPMalAttT3_51_4[n] + W_2_asorderedPMalAttT3_1[n] * r_2_asorderedPMalAttT3_52[J_2_asorderedPMalAttT3_1[n]] * Z_2_asorderedPMalAttT3_52_1[n] + W_2_asorderedPMalAttT3_2[n] * r_2_asorderedPMalAttT3_52[J_2_asorderedPMalAttT3_2[n]] * Z_2_asorderedPMalAttT3_52_2[n] + W_2_asorderedPMalAttT3_3[n] * r_2_asorderedPMalAttT3_52[J_2_asorderedPMalAttT3_3[n]] * Z_2_asorderedPMalAttT3_52_3[n] + W_2_asorderedPMalAttT3_4[n] * r_2_asorderedPMalAttT3_52[J_2_asorderedPMalAttT3_4[n]] * Z_2_asorderedPMalAttT3_52_4[n] + W_2_asorderedPMalAttT3_1[n] * r_2_asorderedPMalAttT3_53[J_2_asorderedPMalAttT3_1[n]] * Z_2_asorderedPMalAttT3_53_1[n] + W_2_asorderedPMalAttT3_2[n] * r_2_asorderedPMalAttT3_53[J_2_asorderedPMalAttT3_2[n]] * Z_2_asorderedPMalAttT3_53_2[n] + W_2_asorderedPMalAttT3_3[n] * r_2_asorderedPMalAttT3_53[J_2_asorderedPMalAttT3_3[n]] * Z_2_asorderedPMalAttT3_53_3[n] + W_2_asorderedPMalAttT3_4[n] * r_2_asorderedPMalAttT3_53[J_2_asorderedPMalAttT3_4[n]] * Z_2_asorderedPMalAttT3_53_4[n] + W_2_asorderedPMalAttT3_1[n] * r_2_asorderedPMalAttT3_54[J_2_asorderedPMalAttT3_1[n]] * Z_2_asorderedPMalAttT3_54_1[n] + W_2_asorderedPMalAttT3_2[n] * r_2_asorderedPMalAttT3_54[J_2_asorderedPMalAttT3_2[n]] * Z_2_asorderedPMalAttT3_54_2[n] + W_2_asorderedPMalAttT3_3[n] * r_2_asorderedPMalAttT3_54[J_2_asorderedPMalAttT3_3[n]] * Z_2_asorderedPMalAttT3_54_3[n] + W_2_asorderedPMalAttT3_4[n] * r_2_asorderedPMalAttT3_54[J_2_asorderedPMalAttT3_4[n]] * Z_2_asorderedPMalAttT3_54_4[n];
^
834: }-------------------------------------------------
Error in stanc(model_code = paste(program, collapse = “\n”), model_name = model_cppname, :
failed to parse Stan model ‘file159d15d07c1f’ due to the above error.
Show Traceback
Error in stanc(model_code = paste(program, collapse = “\n”), model_name = model_cppname, : failed to parse Stan model ‘file159d15d07c1f’ due to the above error.

I think the difference to the previous model (for which you solved the error) is that I used an as.ordered(variable) in my model.

My syntax for the part of the model that seems to cause the problem is:

bf_Attr.random ← bf(as.ordered(PMalAttT3) ~ 1 + Gen + mo(PMalAttT1) + PTaskDif + PPubEva + PResp + PValue + PLearnPerform + FAPsAgg + (1 + Gen + mo(PMalAttT1) + PTaskDif + PPubEva + PResp + PValue + PLearnPerform + FAPsAgg |p| mm(T1_ID, T2_ID, T3_ID, T4_ID, weights = cbind(W_T1, W_T2, W_T3, W_T4))) + (1 + Gen + mo(PMalAttT1) + PTaskDif + PPubEva + PResp + PValue + PLearnPerform + FAPsAgg |q| mm(C1_ID, C2_ID, C3_ID, C4_ID, weights = cbind(W_C1, W_C2, W_C3, W_C4))), family = cumulative(link = “probit”))

When I leave this part out, the multivariate model runs well.

Any advice?

Thanks,
Pia

I think this is a problem I have fixed one or two weeks ago. Can you try out if it works in the latest github version of brms to be installed via

if (!requireNamespace("devtools")) {
  install.packages("devtools")
}
devtools::install_github("paul-buerkner/brms")

That doesn’t fix it unfortunately. I’m still getting the same error message.

I think I found the problem. Can you please try it again?

Brilliant! The model compiled now, so it should be fixed. It’s running for hours already but I guess that’s because it’s a very complex model.

Forgot to say thanks!