繁体   English   中英

如何使用 R 显示 plot 的非劣效性

[英]How can I show non-inferiority with a plot using R

我比较两种治疗方法 A 和 B。目的是表明 A 不劣于 B。非劣效边际增量 =-2 比较治疗 A 后 - 治疗 BI 有这些结果

平均差和 95% CI = -0.7 [-2.1, 0.8]

我想通过 package 或手动将其发送到 plot。 我不知道该怎么做。

    Welch Two Sample t-test

data:  mydata$outcome[mydata$traitement == "Bras S"] and mydata$outcome[mydata$traitement == "B"]
t = 0.88938, df = 258.81, p-value = 0.3746
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -2.133224  0.805804
sample estimates:
mean of x mean of y 
 8.390977  9.054688 

我想创建这种 plot:

在此处输入图像描述

您可以从t.test结果中提取相关数据,然后使用segmentspoints plot 数据的abline在基数 R 中提取数据并绘制相关的垂直线。 由于没有可重现的数据,我做了一些,但过程大体相同。

#sample data
set.seed(123)
tres <- t.test(runif(10), runif(10))

# get values to plot from t test results
ci <- tres$conf.int
ests <- tres$estimate[1] - tres$estimate[2]

# plot
plot(x = ci, ylim = c(0,2), xlim = c(-4, 4), type = "n", # blank plot
     bty = "n", xlab = "Treatment A - Treatment B", ylab = "",
     axes = FALSE)
points(x = ests, y = 1, pch = 20) # dot for point estimate
segments(x0 = ci[1], x1 = ci[2], y0 = 1) #CI line
abline(v = 0, lty = 2) # vertical line, dashed
abline(v = 2, lty = 1, col = "darkblue") # vertical line, solid, blue
axis(1, col = "darkblue") # add in x axis, blue

在此处输入图像描述

编辑:

如果您想更准确地用 x 轴按降序重新创建图形并使用您的语句“平均差和 95% CI = -0.7 [-2.1, 0.8]”,您可以对上述方法进行以下操作:

diff <- -0.7 
ci <- c(-2.1, 0.8)

# plot
plot(1, xlim = c(-4, 4), type = "n", 
     bty = "n", xlab = "Treatment A - Treatment B", ylab = "",
     axes = FALSE)
points(x = -diff, y = 1, pch = 20)
segments(x0 = -ci[2], x1 = -ci[1], y0 = 1)
abline(v = 0, lty = 2) 
abline(v = 2, lty = 1, col = "darkblue") 
axis(1, at = seq(-4,4,1), labels = seq(4, -4, -1), col = "darkblue")

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM