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.