You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to include an unused factor level for a fixed effect in the brms model, but that does not work, since drop.unused.levels is by default TRUE and there is no way to change that. Instead I have to use a hack to get what I like to have. Here is an example:
library(brms)
AS_region<- bind_cols(RBesT::AS, region=sample(c("asia", "europe", "north_america"), 8, TRUE))
AS_region_all<-data.frame(region=c("asia", "europe", "north_america", "other")) %>%
mutate(study=paste("new_study", region, sep="_"), r=0, n=6)
## to get brms to include the other factor level in the model, we have## to add a fake row with region "other" and n=0AS_region_2<- mutate(bind_rows(AS_region, mutate(AS_region_all, n=0)[4,]),
region=factor(region, levels=c("asia", "europe", "north_america", "other")))
model_fixed<- bf(r| trials(n) ~1+region+ (1|study), family=binomial)
model_fixed_prior<- prior(normal(0, 2), class="Intercept") +
prior(normal(0, 1), class="sd", coef="Intercept", group="study") +
prior(normal(0, log(2)/1.96), class="b")
fixed_mc_brms<- brm(model_fixed, AS_region_2, prior=model_fixed_prior,
seed=4767,
silent=2, refresh=0, control=list(adapt_delta=0.99))
It would be nice to control the drop.unused.levels from validate_data somehow.
The text was updated successfully, but these errors were encountered:
I wanted to include an unused factor level for a fixed effect in the brms model, but that does not work, since drop.unused.levels is by default TRUE and there is no way to change that. Instead I have to use a hack to get what I like to have. Here is an example:
It would be nice to control the drop.unused.levels from validate_data somehow.
The text was updated successfully, but these errors were encountered: