Is the tidybayes package capable of handling multivariate models? Looking at the tutorials, the walkthroughs are all for bivariate models.
I have a multivariate model, and I would like to get the posterior estimates for a single IV in the model equation. For my example, I’ll choose AgeGroups4.
I have the following model estimated using brms:
model1 <- brm(Q3 ~ AgeGroups4 +
Gender +
Education +
INCOME_5 +
IncomeFeelings +
EMP_2010 +
HouseholdSize +
Urbanicity +
CC.EST_gmc +
GE.EST_gmc +
PV.EST_gmc +
RQ.EST_gmc +
RL.EST_gmc +
VA.EST_gmc +
Year +
(1 | Country),
data = dataframe10PC,
family = categorical(link = "logit"),
chains = 4,
cores = 4,
threads = threading(4),
iter = 1000,
warmup = 500)
summary(model1)
To get posterior estimates for AgeGroup4, my code using the tidybayes shell code would be:
age_plot <- dataframe10PC %>%
filter(!is.na(AgeGroups4)) %>%
data_grid(AgeGroups4) %>%
add_epred_draws(model1,
category = c("Q3")) %>%
ggplot(aes(x = .epred,
y = Q3)) +
coord_cartesian(expand = FALSE) +
facet_grid(. ~ AgeGroups4,
switch = "x") +
theme(strip.background = element_blank(),
strip.placement = "outside") +
xlab("Age group") +
theme_tufte()
However, when I put this code in I get:
*Error: The following variables can neither be found in 'data*' *nor in 'data2*
This is followed by a string of the rest of the IVs in the model equation for model 1.
Is it possible to get the estimates for a single IV in a multivariate model using tidybayes? If so, how is this done? Note that the code works when estimated as a bivariate model (Q3 ~ AgeGroups4).
Thanks in advance.
EDIT (Aki): added codeblock formating