I’m estimating a model that consists of four equations: One binomial equation in y that has three explanatory variables, x1, x2, and x3, which are measured with error. As the three explanatory variables are bounded to be positive, I specify the measurement error (ME) equations to be lognormal as below:
form.mod ← bf(y | trials(y_tot) ~ mi(x1) + mi(x2) + mi(x3)) + binomial()
form.me1 ← bf(x1 | mi(x1_sd) ~ 1) + lognormal()
form.me2 ← bf(x2 | mi(x2_sd) ~ 1) + lognormal()
form.me3 ← bf(x3 | mi(x3_sd) ~ 1) + lognormal()
This model runs fine.
As a sensitivity check, however, I figured I’d try some alternative distributions for the ME equations, like the shifted_lognormal:
form.mod ← bf(y | trials(y_tot) ~ mi(x1) + mi(x2) + mi(x3)) + binomial()
form.me1 ← bf(x1 | mi(x1_sd) ~ 1) + shifted_lognormal()
form.me2 ← bf(x2 | mi(x2_sd) ~ 1) + shifted_lognormal()
form.me3 ← bf(x3 | mi(x3_sd) ~ 1) + shifted_lognormal()
This model returns the following error when compiling the Stan program:
Compiling Stan program...
Error in stanc(file = file, model_code = model_code, model_name = model_name, : 0
Syntax error in 'string', line 41, column 21 to column 31, parsing error:
Expression expected. Ill-formed expression. Suggested alternatives: a standalone identifier, a function application, an identifier followed by an operator or an identifier followed by an index.
Finally, I thought I’d try the generalised extreme value distribution for the ME equations:
form.mod ← bf(y | trials(y_tot) ~ mi(x1) + mi(x2) + mi(x3)) + binomial()
form.me1 ← bf(x1 | mi(x1_sd) ~ 1) + gen_extreme_value()
form.me2 ← bf(x2 | mi(x2_sd) ~ 1) + gen_extreme_value()
form.me3 ← bf(x3 | mi(x3_sd) ~ 1) + gen_extreme_value()
Which returns the following error during compilation:
Compiling Stan program...
Error in stanc(file = file, model_code = model_code, model_name = model_name, : 0
Semantic error in 'string', line 160, column 9 to column 11:
Identifier 'xi' is already in use.
Has anyone encountered this behaviour in brms before and/or know what I might be doing wrong? I can upload a sample of the data and more code to create a reprex if that would be helpful.