Greetings,
I was excited to find that brms has a built in function for incorporating the measurement error of predictors into models (see: me: Predictors with Measurement Error in 'brms' Models in brms: Bayesian Regression Models using 'Stan'). I am interesting in running a simple linear model (y~x) in which both the x and y variables include measurement area.
It seems to me that the me() function cannot be implemented as a response variable on the left side of the equation (see sample code below).
Does anyone know of a way around this to implement such a model?
I am using brms version 2.11.1 on a mac High Sierra OS.
Thanks!
Dan
#generate simple dataframe with measurement error on x and y
N <- 100
dat <- data.frame(
y = rnorm(N), sdy = abs(rnorm(N, 1)),
x = rnorm(N), sdx = abs(rnorm(N, 1))
)
library(brms)
# try to fit an error in variable model and fail
fit1 <- brm(me(y,sdy) ~ me(x, sdx), data = dat,
save_mevars = TRUE)