I encountered a warning message from brms after training a simple binomial model with “meanfield” as the algorithm. Here is the warning message:
In names(x$fit@sim$samples[[i]])[change$pos] ← change$fnames :
** number of items to replace is not a multiple of replacement length**
The problem is not about the warning message, but rather, the impact when I closely look into the model object return by brms and also the predictions made using the same model - the results are completely wrong.
I also realized that the same model when trained on different computer with the same specs and model definition returns the expected results. Is there a way to fix this issue?
This warning indicates a bug in brms, but it may be unrelated to the issues you linked to (which have been resolved) since it may happen for a completely different model type. The warning basically tells you that renaming some of the parameters has failed for some reason.
Do both computers have the latest brms version? In order to fix this, can you please provide a minimal reproducible example?
Regarding your questions, No, the one with the warning message has brms version 2.9.0 whilst the one that works fine has brms version 2.8.9. I have include the model (but am not sure if that is what you are looking for). In the model, “day” is days of the week (Mon - Sun).
m <- brms::brm(
formula = Alive|trials(Total) + weights(weight) ~ 1 +
day + (1|day*location),
data = d,
family = stats::binomial(link = 'logit'),
cores = 4,
save_ranef = TRUE,
future = TRUE,
seed = 111
iter = 50000,
algorithm = "meanfield",
control = list(adapt_delta = 0.999, max_treedepth = 15
)
)
(1) For an example to be minimally reproducible it needs to run out of the box just by copying the code, so we not only need the model code but also some (possibly fake) data. Otherwise, I may not see the error just because it is caused by specifics in the data that I didn’t have. I created some fake data by myself this time, but in generally it would be good if you also included it in your code
(2) I recommend not to use ADVI (meanfield and fullrank) right now especially for multilevel models as the results are likely to be very far off. I hope we get bette diagnostics implemented in Stan soon and also some improvements to the algorithms themselves.
Regarding the second comment (#2), I used meanfield because of the time it takes to train a multilevel model with say 50000 observations seems to take a significant amount of time. However, I agree with you on the results produce by the different methods.
I’m currently looking at the Rstan installation for possible clues to the problem.