di4oi4
August 17, 2020, 10:30am
1
My model:
m = brm(y ~ age + (1 | region), data = data, family = categorical(link = "logit"), cores = 3, chains = 3)
Defining conditions argument:
conditions = data.frame(region = unique(data$region),
row.names = unique(data@region))
I am interested in plotting the probabilities of each y-variable level for each region (not interested in age specific effects, I just needed to adjust for age). How to code this? The following did not work:
conditional_effects(m, conditions = conditions, categorical = T)
torkar
August 17, 2020, 12:33pm
2
Hi
perhaps this can be of use?
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 sw…