This document contains the plot of predicted probabilities from each individual study, as well as the weighted average effect, from the cross-sectional analyses.
The following packages were used to generate this figure:
library(tidyverse)
library(metafor)
library(here)
The files needed for this table are available at osf.io/mzfu9 in the Meta Analysis Output folder.
First we load the meta-analysis objects. To see how these objects were created, see the meta-analysis scripts titled hbp_cross_sectional.R
, diabetes_cross_sectional.R
, and heart_cross_sectional.R
that are available at osf.io/35etv.
load(here("chronic/meta output/hbp_cross.Rdata"))
weighted.cross.hbp <- weighted.vals
load(here("chronic/meta output/diabetes_cross.Rdata"))
weighted.cross.diab <- weighted.vals
load(here("chronic/meta output/heart_cross.Rdata"))
weighted.cross.heart <- weighted.vals
rm(weighted.vals)
Next we merge the data frames from the different objects.
weighted.cross.hbp$outcome = "Hypertension"
weighted.cross.diab$outcome = "Diabetes"
weighted.cross.heart$outcome = "Heart Disease"
weighted.cross.all <- weighted.cross.hbp %>%
full_join(weighted.cross.diab) %>%
full_join(weighted.cross.heart) %>%
mutate(outcome = factor(outcome,
levels = c("Hypertension", "Diabetes", "Heart Disease")))
hbp.cross.plot$outcome = "Hypertension"
diab.cross.plot$outcome = "Diabetes"
heart.cross.plot$outcome = "Heart Disease"
plot.cross.all <- hbp.cross.plot %>%
full_join(diab.cross.plot) %>%
full_join(heart.cross.plot) %>%
mutate(outcome = factor(outcome,
levels = c("Hypertension", "Diabetes", "Heart Disease")))
Finally, we plot the values.
plot.cross.all %>%
ggplot(aes(x = x, y = predicted)) +
geom_ribbon(aes(ymin=lower, ymax=upper), fill="black", alpha=.15,
data = weighted.cross.all)+
geom_line(aes(color = study), lty="dashed") +
geom_line(data = weighted.cross.all, color="black") +
scale_x_continuous("Neuroticism")+
scale_y_continuous("Probability of \n having chronic condition") +
facet_grid(outcome~group)+
theme_minimal()+
theme(legend.position = "bottom")