Multimodality in latent variable model

Hi all. I have a data generating process with hidden continuous latent variable that determines some binomial output variable amd I am trying to recover the latent variable via latent variable model.

To generate some data:


n <- 80
dat3 <- data.frame(x = rnorm(n, 0, 1))
dat3$ystar <- 2 * dat3$x + rnorm(n, 0, 0.01)
dat3$y <- rbinom(n, 1, 1/(1 + exp(-dat3$ystar)))
dat3$ystar2 <- NA_real_

ystar2 is setup as missings to support the latent variable model which Im’ specifying as follows:

bf5a <- bf(ystar2 | mi() ~ x) +
    bf(y ~ mi(ystar2), family = "bernoulli")
fit5a <- brm(bf5a, dat3, chains = 4, cores = 4,
            save_pars = save_pars(latent = TRUE))

When I fit this model, it’s warnings all over:

Next, I made a pairs plot and looked at conditional effects too:

me5a <- conditional_effects(fit5a, effects = c("x"), ndraws = 200, spaghetti = TRUE)
plot(me5a, points = TRUE)

So from both plots it seems obvious there is multi-modality at play. However I don’t really understand why, or what to do about it? I also don’t know what the variable bsp_y_miystar2 is for. I looked at the stancode but could not find this variable. Any ideas anyone how to improve this fit?