I want to understand how to use the mi
function to specify a measurement error model that will be the same as that specified by me
. Maybe there’s a good reason this might not be possible. If so, I would like to understand the reason.
Here’s an example:
library(brms)
N <- 100
dat <- data.frame(
y = rnorm(N), x1 = rnorm(N),
x2 = rnorm(N), sdx = abs(rnorm(N, 1))
)
# fit a simple error-in-variables model
model1 <- brm(y ~ me(x1, sdx) , data = dat, chains=4, cores=4)
model2 <- brm( bf(y ~ mi(x1)) + bf(x1 | mi(sdx) ~ 0), data=dat, chains=4,cores=4)
What’s the difference between model1
and model2
?
From reading the stancode I see thatmodel1
corresponds to the model (ignoring priors):
y \sim N(Bx^* + I, \sigma)
x^* \sim N(x , sd_x)
and estimates B,I and \sigma.
I also see that model2
corresponds to the model (ignoring priors):
y \sim N(Bx^* + I, \sigma_y)
x^* \sim N(x^*_{\mu}, \sigma_x )
x^*_{\mu} \sim N(x, sd_x)
Is it possible to fit model1
using the mi
forumla syntax?
Is there some reason to prefer model2
to model1
? For what it’s worth, based on my limited statistical knowledge I expect to prefer model1
.
- Operating System: Debian 11.1
- brms Version: brms_2.15.6