I’m attempting to follow this tutorial from Monica Alexander on using brms for multilevel regression and post-stratification. The twist is that in my use case the outcome is an ordered factor with 4 levels. The tutorial deals with a proportion.
Therefore, rather than run:
mod <- brm(kept_name ~ (1|age_group) + (1|educ_group) +
(1|state_name) + (1|decade_married),
data = d_mncs,
family=bernoulli())
I followed @paul.buerkner’s lead in his ordinal regression tutorial and fit the model with family = cumulative("probit")
.
The next step in Monica’s tutorial is to use the results of the regression to predict the outcome and multiply the .prediction
by the proportion (prop
). This is the post-stratification step.
res_age <- mod %>%
add_predicted_draws(newdata=age_prop %>%
filter(age_group>20,
age_group<80,
decade_married>1969),
allow_new_levels=TRUE) %>%
rename(kept_name_predict = .prediction) %>%
mutate(kept_name_predict_prop = kept_name_predict*prop) %>%
group_by(age_group, .draw) %>%
summarise(kept_name_predict = sum(kept_name_predict_prop)) %>%
group_by(age_group) %>%
summarise(mean = mean(kept_name_predict),
lower = quantile(kept_name_predict, 0.025),
upper = quantile(kept_name_predict, 0.975))
This works in her example with a binary outcome (1/0) because the .prediction
is numeric and can be multiplied by the population proportion. In my use case with an ordinal outcome, .prediction
is a factor.
Any thoughts about how to apply this MRP example when your outcome is ordinal, not binary?