This is an example of how to visualize odds ratio using R package {ggplot2}.
### Not to run ###
library(ggplot2)
library(ggpubr)
# visualize the effect estimates from Stata
p.bpsys <-
ggplot(res[res$outcome == 'bpsys',],
aes(x = model, y = coeff, ymin = CI_l, ymax = CI_u, col = abm)) +
geom_point(size=2) +
geom_errorbar(width=0.2) +
geom_hline(yintercept = 0, linetype = 2) +
scale_x_discrete(name = '') +
scale_y_continuous(name = '') +
scale_color_manual(values=c('#eb8050', '#488f31')) +
coord_flip() +
labs(title='Systolic blood pressure', color=NULL) +
theme(plot.title = element_text(hjust = 0.5),
plot.margin = unit(c(0.5,0.5,0,0.5), "cm")) +
guides(color = guide_legend(reverse=T))
p.bpdia <-
ggplot(res[res$outcome == 'bpdia',],
aes(x = model, y = coeff, ymin = CI_l, ymax = CI_u, col = abm)) +
geom_point(size=2) +
geom_errorbar(width=0.2) +
geom_hline(yintercept = 0, linetype = 2) +
scale_x_discrete(name = '') +
scale_y_continuous(name = '') +
scale_color_manual(values=c('#eb8050', '#488f31')) +
coord_flip() +
labs(title='Diastolic blood pressure', color=NULL) +
theme(plot.title = element_text(hjust = 0.5),
plot.margin = unit(c(0.5,1,0,0), "cm"),
axis.text.y = element_blank(), axis.ticks.y = element_blank()) +
guides(color = guide_legend(reverse=T))
p.all <- ggarrange(p.bpsys, p.bpdia, widths = c(1.4,1), nrow=1, ncol=2,
common.legend = TRUE, legend = 'bottom')
png('results/assoc_bp_s3_all.png', height = 1500, width = 3000, res = 300)
print(p.all)
dev.off()