-
-
Notifications
You must be signed in to change notification settings - Fork 86
Closed
Labels
Description
Hi, I'm attempting to relabel the parameters in a mcmc_interval
plot by adding a ggplot2::scale_y_discrete(labels = new_labels)
approach.
The problem I'm having is that when I do this, the labels are correctly relabelled, but the order of the yaxis changes, such that the Intercept term now is at the bottom as opposed to the top (I prefer to have the intercept on top). I've played around with trying to set the breaks or inverting the limits of the axis but have had no success. Also because the mcmc plot functions make a variety of changes to the underlying data prior to plotting I don't really see an obvious way to set the order. Is there something obvious I'm missing here?
# MWE example
prior1 <- prior(normal(0,10), class = b) +
prior(cauchy(0,2), class = sd)
fit1 <- brm(count ~ zAge + zBase * Trt + (1|patient),
data = epilepsy, family = poisson(), prior = prior1)
# Default (no relabelling but correct order)
mcmc_intervals(fit1, regex_pars="b_"
# Relabelling (but order of pars changes)
mcmc_intervals(fit1, regex_pars ="b_") +
ggplot2::scale_y_discrete(labels = c("b_Intercept" ="Intercept",
"b_zAge" = "Age",
"b_zBase" = "Base",
"b_Trt1" = "Treatment",
"b_zBase:Trt1" = "Base x Treatment"))