How to overlay prediction intervals over confidence intervals using the 'forestplot' function in R

Viewed 59

I want to overlay prediction intervals over confidence intervals in a non-overall forest plot to compare the width between these intervals. The example of the desired forest plot is as follows:

enter image description here

However, I can't seem to find the right function with the 'forestplot' package. Does anyone has any clue as of how to create the analysis in R?

Update: To illustrate, I made a dummy dataset as follows:

names <- c("Variable", "Diabetes", "Hypertension", "Cancer", "Asthma")
n <- c("N", 5, 5, 5, 5)
coef <- c(1.10, 1.05, 1.20, 1.25)
ci.low <- c(1.05, 1.02, 1.18, 1.21)
ci.high <- c(1.12, 1.07, 1.24, 1.29)
pi.low <- c(0.80, 0.99, 0.97, 0.95)
pi.high <- c(1.45, 1.30, 1.44, 1.66)
boxsize <- c(0.2,0.2,0.2,0.2)
test_data <- data.frame(coef=coef, low=ci.low,high=ci.high, boxsize=boxsize)
test_data <- rbind(NA,  test_data)
row_names <- cbind(names, n, c("OR [95% CI]", "1.10 [1.05-1.12]", "1.05 [1.02-1.07]", "1.20 [1.18-1.24]", "1.25 [1.21-1.29]"))

#Forest plot
forestplot(labeltext = row_names,
           mean = test_data$coef, upper = test_data$high,
           lower = test_data$low,
           is.summary=c(TRUE, FALSE, FALSE, FALSE, FALSE, FALSE),
           boxsize = test_data$boxsize,
           zero = 1,
           xlog = FALSE,
           xlab = "OR (95% CI)",
           clip = c(0,2),
           col = fpColors(lines="black", box="black"),
           colgap = unit(0.03,'npc'),
           hrzl_lines= TRUE,
           lineheight = unit(1.1,"cm"),
           graphwidth = "auto",
           txt_gp=fpTxtGp(label = gpar(cex = 0.8),
                          title = gpar(cex = 1),
                          ticks = gpar(cex = 0.7),
                          xlab = gpar(cex = 0.7)))

Which returns this figure: enter image description here

However, I still can't seem to find the appropriate function to overlay the prediction intervals over the confidence intervals. Thank you very much in advance.

0 Answers
Related