Brms: discrepancy between conditional effects plots and calculations based on posterior

Model
m = brm(bf(acute_therapy ~ year_centered + (1 | town)), data = data, family = hurdle_lognormal(), cores = 3, chains = 3)

Conditional effects plot for lognormal part of the hurdle model
conditional_effects(m, robust = TRUE)

Comment: all median values are below 2.0 on y-axis

Let’s calculate the median value and CIs for the year 0

m %>% spread_draws(b_Intercept) %>% median_qi(intercept = exp(b_Intercept))

2.05 [1.87; 2.26]

Comment: median value is above 2, not matching the conditional effects plot

The same happens, when I calculate means instead of medians, using formula as follows:
exp((b_Intercept) + 1/2 * (sigma)**2)

What am I doing wrong here and why there is a discrepancy between the two outcomes?

Or are there better options for making such calculations. E.g. calculation mean Y value in year “-4” and in year “4”? I checked fitted() and predict() function, however, did not understand how to receive predictions for year “-4” for example (including all towns).

1 Like

Those are computing two quite different values - from the docs of conditional_effects:

When creating conditional_effects for a particular predictor (or interaction of two predictors), one has to choose the values of all other predictors to condition on. By default, the mean is used for continuous variables and the reference category is used for factors

I.e. the conditional_effects show predictions taking into account all model coefficients, while your second approach is only looking at the particular coefficient.

Does that make sense?

Best of luck with your model!

1 Like