Hi all, I’m fitting the below multivariate model:
bfLSI2<-bf(logLSI~1+ZHIP+GHQ_28_total_cat)
bfFSFI1<-bf(logFSFI~1+ZHIP)
fit21<-brm(bfLSI2 + bfFSFI1 + set_rescor(TRUE),
data=Dataset, prior=prior1, iter=4000, warmup=1500, control = list(adapt_delta = 0.95, max_treedepth=15), seed=12345)
I want to predict fitted values over ZHIP (-1,1) , thus I create a conditions grid:
conditions<- expand.grid(ZHIP = seq(-1,1,by=0.2),GHQ_28_total_cat=c("no distress", "probable distress"))
conditions<- within(conditions, {
GHQ_28_total_cat <- as.factor(GHQ_28_total_cat)
})
and I fit my predictions:
predictedfit21 <- fit21 %>%
epred_draws(newdata =conditions, allow.new.levels=TRUE,re_formula = NA)
plot_predictedfit21 <- ggplot(predictedfit21, aes(x = ZHIP, y = exp(.epred/100),color=.category))+
stat_lineribbon(.width = c(.90)) + scale_fill_brewer(palette = "Greys") + labs(x = "ZHIP", y = "Predicted LSI-FSFI", fill = "Credible interval") +
theme(legend.position = "bottom", panel.background = element_blank())+ theme(panel.border= element_blank()) +theme(axis.line = element_line(color="black", size = 1))+facet_wrap(~GHQ_28_total_cat)+ylim(10,70)
plot_predictedfit21
However, in the plot, FSFI is also shown as what I’d expect if I had adjusted ZHIP for GHQ_28_total_cat; I would normally expect a plot where FSFI~ZHIP is the same for both levels of GHQ_28_total_cat ,given my FSFI model formula, but that is not the case. What am I missing here?
Most likely this is not the best way to plot both responses in the same plot, but given that their values are on similar scale (~20-70) -and of course my current low level of r programming- it was the best I could come up with.
Thank you in advance.