Greetings.
I have binary response data y, covariates x1, x2, x3, and a strata variable. I want to fit quadratic models, but not necessarily the same for all strata. First, I ran the full model:
brms_out <- brm(bf(y~ 0 + stratum + stratum:(x1+x2+x3)+stratum:(I(x1)^2)+I(x2)^2)+I(x3)^2),
family=bernoulli),
data=dat, inits = "0", chains = 4, iter = 2000, warmup = 1000,thin = 1, cores = 4,
control = list(max_treedepth = 12), sample_prior = "yes")
This takes 12 hours to run. I did some Bayes Factors to select which quadratic effects to keep, and I reran the model using indicator variables. Here is the code:
dat$stratum1 <- factor(1*(dat$stratum=="s1"))
dat$stratum2 <- factor(1*(dat$stratum=="s2"))
dat$stratum3 <- factor(1*(dat$stratum=="s3"))
brms_out <- brm(bf(y~ 0 + stratum1 + stratum2 + stratum3 +
stratum1:(x1+x2+x3) +stratum2:(x1+x2+x3) + stratum3:(x1+x2+x3) +
stratum1:(I(x2)^2))+stratum2:(I(x3)^2)+stratum3:(I(x1)^2)+I(x2)^2)+I(x3)^2),
family=bernoulli),
data=dat, inits = "0", chains = 4, iter = 2000, warmup = 1000,thin = 1, cores = 4,
control = list(max_treedepth = 12), sample_prior = "yes")
However, this code has now been running 12 hours and the progress is still at 1/2000 iterations for all chains.
So my question is why did the indicators slow the code down so much? How can I speed it up so it finished in about 12 hours again?
- Operating System: Win 10
- brms Version: 2.12.0