Dear all, I just started learning Stan/brms and I was wondering if it’s possible to define a regression model in brms where one of the covariates is unknown and, in its place, I measured another covariate that represents the true covariate plus some error. More or less, like this (6.1 Bayesian measurement error model | Stan User’s Guide) example reported in Stan’s user manual. If so, can you please provide an example?
I checked the me() and mi() functions and the corresponding examples, but, I think, they can only be used to specify the standard deviation of the error, not a different covariate.
When we talk about a measurement error, typically what we mean is that we have measured some values for a covariate, but we assume that the true values are not identical to the measured values. In particular, me() in brms assumes that the differences between the measured values and the true values are independent identically distributed Gaussian variates with a known standard deviation.
To map this onto your problem, the covariate that you measured could be treated as the “uncertain” measurement. If you are willing to assume that the true values are distributed about your measured covariate as an i.i.d. Gaussian with known standard deviation, then me() is what you need. This is the second Stan program given at the link you posted. Otherwise, I think some additional details about what you want will be useful. Do you want to relax the assumption of independence? The assumption of known standard deviation? The assumption of a Gaussian?
I use mi() instead of me() since the docs of me() says that it’s soft deprecated.
I would like to relax the assumption of known standard deviation, including that as an extra parameter. Do you know if it’s possible in brms? If so, can you suggest me some references or examples? After fixing that part, I would like to include a spatial random effect (i.e. CAR, PCAR or similar) in the second formula (i.e. the model defining the ME) since I think that in the “real scenario” there is also a spatial dimension in the ME . In that case, I should simply add an extra term in the linear predictor, right?
 Bernadinelli, L., et al. “Disease mapping with errors in covariates.” Statistics in medicine 16.7 (1997): 741-752.
I’m not aware that this is possible in brms. If I am right that it’s not possible, then I think there’s a strong chance that there’s a good reason why it’s not possible. For example, maybe this standard deviation parameter is known to be extremely difficult to estimate. I suspect this is the case, because as this standard deviation parameter gets large, the model gains increasing flexibility to rearrange the “true” covariate such that the residual standard deviation gets tiny.
However, if you want to play around with this, you can use brms to generate your stan code, and then find and remove the fixed sd from the data declaration, and then add a parameter of the same name in the parameters block with an appropriate <lower=0> constraint in the declaration. You’d probably also want to add some suitable prior on this parameter in the model block.