I’m fitting an ordinal regression model and I would like to transform the draws of the model to obtain the posterior distributions of the estimates on the original response scale (for example, a 5-point Likert scale).
As an example, I here create a fake dataset:
library(brms)
nSubj <- 100
dataSurvey <- data.frame(
SubjectID = rep(seq(1, nSubj), 2),
Condition = rep(c("Control", "Treatment"), each = nSubj),
Response = c(
sample(c(1, 2, 3, 4, 5), size = nSubj, prob = c(1/8, 1/2, 1/4, 1/8, 0), replace = TRUE),
sample(c(1, 2, 3, 4, 5), size = nSubj, prob = c(0, 1/8, 1/4, 1/2, 1/8), replace = TRUE)
)
)
dataSurvey$SubjectID <- factor(dataSurvey$SubjectID)
Then I fit the ordinal regression (probit) model:
priors_fit <- c(
prior(normal(0, 4), class = Intercept),
prior(normal(0, 4), class = b)
)
fit <- brm(
Response ~ 1 + Condition + (1|SubjectID),
family = cumulative("probit"),
data = dataSurvey,
prior = priors_fit,
inits = 0,
chains = 4,
cores = 4,
warmup = 1000,
iter = 2000,
sample_prior = TRUE
)
The object fit
contains the intercept (thresholds) and the estimate of the categorical variable Condition
. With as_draws_df
I can obtain the individual draws, but I don’t know how to transform them to obtain the posteriors on the response scale. In other words, I would like to obtain the estimates (for all draws) on the same scale as the one display here in the column labeled estimate__
:
conditional_effects(fit)$Condition
which are the estimated averages of the Control and Treatment groups in my dataset.
library(tidyverse)
dataSurvey %>%
group_by(Condition) %>%
summarise(
mResponse = mean(Response)
)
Thanks!