Hi all!
I am trying to run a simple intercept-only model for a binary outcome variable, and at this point, I am running into a problem with autocorrelation. In the toy example below, I encounter the same problem: under different priors, autocorrelation for the estimated intercept remains high.
library(brms)
library(bayesplot)
library(tidybayes)
df <- data.frame(y = rep(c(0, 0, 1), times=25))
model1 <- brm(data = df,
family = "bernoulli",
formula = y ~ 1,
prior(normal(0, 2), class = Intercept),
iter = 10000,
cores=4,
sample_prior = TRUE,
seed = 12345)
intercept_posteriors <- brms::as_draws_df(model1) %>%
mutate(posterior = inv_logit_scaled(b_Intercept),
prior = inv_logit_scaled(prior_Intercept))
mcmc_trace(intercept_posteriors, pars=c("b_Intercept", "prior_Intercept"))
intercept_posteriors %>%
bayesplot::mcmc_acf(pars = vars(b_Intercept, prior_Intercept))
I am wondering how concerning it is. Does the autocorrelation arise because of the family = "bernoulli"
specification?
- Operating System: Windows 10
- brms Version: ‘2.16.3’
Thanks a lot in advance for looking into it.
Best,
Alyona