Contrasts in BRMS

The general answer to all these questions is to compare the posterior predictions of the model at different levels of the factor. For example,

data_A1 <- dataset[dataset$factorA == levels(dataset$factorA)[1], ]
PPD_A1 <- posterior_predict(fit, newdata = data_A1)
data_A2 <- data_A1
data_A2$factorA[1:nrow(data_A2)]  <- levels(dataset$factorA)[2]
PPD_A2 <- posterior_predict(fit, newdata = data_A2)
PPD_diff <- PPD_A2 - PPD_A1

Now you have a matrix for the predicted changed in the outcome due to switching someone from the first level of factorA to the second level. You can do things like that for any pair of levels of any factor or even combinations of factors.

2 Likes