Difference between conditional_effects plot and predicted probability plot

Hi everyone,

I’m working on a longitudinal analysis of a binary outcome across 4 intervention arms using a GLMM and I am confused about the response values shown in the plots generated by conditional_effects().

This is the plot of predicted probabilities from predict():

The numbers roughly match an earlier plot I made when looking at the outcome at each follow-up visit. The percentage of the outcome event for the AMMI + PS + Coach group goes above 20% and the predicted probability in the last plot goes above 0.20.

However, when I use conditional_effects(), I get the following plot where the magnitude of the response is much smaller. (the x-scale is different, but the result is the same if transform back to days since baseline)

Is conditional_effects() giving me predicted probabilities or something else? I’m also thinking it might be due to differences in handling the random effect or the smoothing I apply in the first plot.

Here is my code:

# code for plotting raw data at each visit
d %>% group_by(VISIT, arm, PREP_RE) %>% summarise(n = n(), .groups="drop_last") %>%
  mutate(`%` = n/sum(n) * 100) %>%
  filter(PREP_RE == 1) %>%
  ggplot(aes(x = VISIT, y = `%`, group = arm, color = arm)) +
  geom_line() + geom_point()

# model
mod_quad = brm(PREP_RE ~ arm*scaled_time + (1|ENROLLMENT_ID) + I(scaled_time^2),
               data = d, cores = 4, iter = 2000,
               family = bernoulli(link = "logit"))

# conditional effects plot

# get predicted probabilities
d2 = d %>%
  filter(!is.na(PREP_RE)) %>%
  mutate(predicted = predict(mod_quad, type = "response")[ , 1])

# plot predicted probability
ggplot(d2, aes(x = time, y = predicted, color = arm)) +
  geom_smooth(se = F) +
  labs(x = "Days since baseline", y = "predicted probability")
  • Operating System: Windows 10
  • brms Version: 2.15.0

Thanks in advance