I was playing with Measurement Error models in brms and extended the example from the documentation so the outcome is correlated with the predictors. Ran into fitting issues, divergent transitions. Figure I must be have something wrong.
library(brms)
N <- 100
dat <- data.frame(sdx = abs(rnorm(N, 0, 0.2)))
dat[['x1_real']] <- rnorm(N)
dat[['x2_real']] <- rnorm(N)
dat[['x1_meas']] <- rnorm(N,dat[['x1_real']],dat[['sdx']])
dat[['x2_meas']] <- rnorm(N,dat[['x2_real']],dat[['sdx']])
dat[['y']] <- dat$x1_real - dat$x2_real
# fit a simple error-in-variables model
fit1 <- brm(bf(y ~ me(x1_meas, sdx) + me(x2_meas, sdx)) + set_mecor(FALSE) , data = dat,
save_mevars = TRUE,iter=6000,control=list(adapt_delta=0.95,max_treedepth=12))
R version 4.0.2 (2020-06-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux bullseye/sid
brms_2.13.5