簡體   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