#######################################################################
# Function to summarize posterior samples of RD, RR and OR
# Author: Chenyang Gu
# Date: 02/23/2019
#######################################################################
postSumm = function(RD_est, RR_est, OR_est) {
# Risk difference (RD)
RD_mean = mean(RD_est)
RD_se = sd(RD_est)
RD_lower = quantile(RD_est, probs=0.025, na_rm = T)
RD_upper = quantile(RD_est, probs=0.975, na_rm = T)
# Relative risk (RR)
RR_mean = mean(RR_est)
RR_se = sd(RR_est)
RR_lower = quantile(RR_est, probs=0.025, na_rm = T)
RR_upper = quantile(RR_est, probs=0.975, na_rm = T)
# Odds ratio (OR)
OR_mean = mean(OR_est)
OR_se = sd(OR_est)
OR_lower = quantile(OR_est, probs=0.025, na_rm = T)
OR_upper = quantile(OR_est, probs=0.975, na_rm = T)
# summarize results
RD = c(RD_mean, RD_se, RD_lower, RD_upper)
RR = c(RR_mean, RR_se, RR_lower, RR_upper)
OR = c(OR_mean, OR_se, OR_lower, OR_upper)
res = rbind(RD, RR, OR)
colnames(res) = c("EST","SE","LOWER","UPPER")
return(res)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.