I’m using R2D2 priors for a complicated model and I’ve noticed that under certain circumstances I’m getting divergences using the prior. I’ve managed to make s simple reprex:
library(brms)
library(bayesplot)
# set pairs plot colours
color_scheme_set("brightblue")
set.seed(1234)
dat <- mgcv::gamSim(1, n = 100, scale = 2)
dat$rand <- runif(nrow(dat))/1000
# fit some GP models
fit1 <- brm(y ~ x1 + rand, dat, chains = 2,
prior = set_prior(R2D2(mean_R2 = 0.7, prec_R2 = 5), class = "b"))
posterior1 <- as.array(fit1)
np1 <- nuts_params(fit1)
mcmc_pairs(posterior1, pars = c("b_x1", "sdb_x1", "b_rand", "sdb_rand"), np = np)
The pairs plot:
As can be seen there is a funnel like behaviour between b_rand
and sdb_rand
when beta has the value of 0. Any suggestions on fixing/avoiding this funnel?
I guess one reply might be - just don’t include a variable with 0 value for beta. But, In my real data this came about by including a variable I thought would be important but it turns out seemingly is not. This was unexpected and looking into it led me to make the reprex here, since including unimportant variables could happen often.