# 如何使用 R 中的“forestplot”函数在置信区间上叠加预测区间How to overlay prediction intervals over confidence intervals using the 'forestplot' function in R

``````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)))
``````

## 本文未有回复，本站智能推荐：

2回复

### Metafor森林图显示了不正确的比值置信区间

I'm trying to plot odds ratios and corresponding 90% confidence intervals, which I have previously obtained from a proportional odds model using packa
2回复

### 如何使用R中的“bootstrap函数”计算置信区间

I am trying to calculate the confidence interval in R. Due to some special reasons, I have to do it with the functions in "bootstrap" package.(which m
1回复

### ggplot2图中的置信区间与使用R中的预测函数获得的值不同

This is my data (EXAMPLE): 这是我的数据（示例）： EXAMPLE<-data.frame( X=c(99.6, 98.02, 96.43, 94.44, 92.06, 90.08, 87.3, 84.92, 82.14, 79.76, 76.98, 74.2
1回复

### 绘制R中的预测概率和置信区间

This is a plot I did, I want the confidence intervals for the plot, both upper and lower. 这是我做的图，我想要该图的置信区间（上下限）。 I have come so far that I have prod
3回复

### 如何使用glmmTMB的预测函数拟合置信区间

I am running a mixed model using the package glmmTMB and using the predict function to calculate predicted means using the following code:我正在使用包 glmmT
2回复

### R中的置信区间计算

I'm finding differences when trying to calculate the CI in R :我在尝试计算R中的CI时发现差异：x=c(25,30,15,45,22,54)#IC 1install.packages("Rmisc")library(Rmisc)CI(x,