Hi all, I have simulated from the following model.
fit1 <- brm(
bf(y ~ 0 + Intercept + a1 + a2, nl = TRUE) +
lf(Intercept ~ 1, center = FALSE) +
lf(as.formula(paste("a1 ~ 0 + ", paste(names(data_train)[2:16], collapse = " + "))), center = FALSE, cmc = FALSE) +
lf(as.formula(paste("a2 ~ 0 + ", paste(names(data_train)[17:ncol(data_train)], collapse = " + "))), center = FALSE, cmc = FALSE),
data_train,
family = bernoulli(link = "logit"),
prior = prior(cauchy(0, 10), class = "b", nlpar = "Intercept") +
prior(cauchy(0, 2.5), class = "b", nlpar = "a1") +
prior(horseshoe(df_slab = 1, scale_slab = 2.5, par_ratio = 0.003), class = "b", nlpar = "a2"),
warmup = 10,
iter = 20,
thin = 1,
chains = 2,
seed = 1,
cores = 2
)
y is a binary outcome. Following recommendations in the BDA3 book, I have specified a Cauchy(0, 10) prior for the intercept and a Cauchy(0, 2.5) prior for 15 demographic predictors. Again following BDA3, the continuous predictors have mean 0 and standard deviation 0.5, whereas binary predictors have mean 0 and the two possible observed values differ by 1.
Then there is a sparsifying prior on >7000 candidate biomarkers (I expect about 20 of those 7000 to be relevant).
I would normally have used rstanarm with which I am more familiar but believe it is not possible to specify different priors on two subsets of predictors (demographic variables and candidate biomarkers) in rstanarm.
In this example I am saving a total of 20 MCMC simulations (for debugging purposes). The simulation ends and the object fit1 occupies about 280 Mbytes. I am now trying to save that as a serialised object to perform posterior predictive checks, analyse the results, etc.
Oddly, it is impossible to do so and after running
saveRDS(fit1, <path>)
followed by
fit1 <- readRDS( <path>)
on a different R session, I get the output
Error: C stack usage 7969616 is too close to the limit
I suspect the issue is with brms because I have been able to save serialized objects of much larger sizes. I am running brms on an Ubuntu machine and I have tried different versions of R (4.4, 4.3 and 3.6).
Has anybody seen this issue before?
Thanks
Víctor