Extract posteriors and compute odds ratio in multinomial regression

Hi there,

I initially thought something was off with your code but I was thinking of multinomial rather than categorical models (they can be confusing). But for categorical I think you are correct. The key is to compute your derived variable of interest for each draw and then summarise at the end, which is what you did.

I think the only thing I’d change is that your new_dat doesn’t need perc. You can just do

new_dat <- tibble(mimicry=mimicry)
post <- add_fitted_draws(new_dat, fit_ex, re_formula = NA)

This way there’s also no need to call summarise . Depending on your ultimate goal you may also choose to include the uncertainty from the subject effects with something like

new_dat <- expand_grid(mimicry=mimicry, subject=1000) # any new subject level
post <- add_fitted_draws(new_dat, fit_ex, re_formul = NULL, allow_new_levels=TRUE)

Hugo

EDIT: PS, tagging the post with ‘brms’ may be a good idea next time :)

2 Likes