简体   繁体   English

执行成对测试和生存趋势测试

[英]Performing Pairwise test and test for survival trend

I am trying to perform pairwise tests to determine if there is any difference in survival between pairs of groups.我正在尝试执行成对测试以确定成对的组之间的生存率是否存在任何差异。

the data used:使用的数据:

在此处输入图片说明

time_Untreated<- c(20, 21, 23, 24, 24, 26, 26, 27, 28, 30)
censor_Untreated<- c(rep(1,10), rep(0,0))
censor_Untreated

time_Radiated<- c(26,28, 29, 29, 30, 30, 31, 31, 32, 35)
censor_Radiated<- c(rep(1,9), rep(0,1))
censor_Radiated

time_Radiated_BPA <- c(31, 32, 34, 35, 36, 38, 38, 39, 42, 42)
censor_Radiated_BPA <- c(rep(1,8), rep(0,2))
censor_Radiated_BPA

myData <- data.frame(time=c(time_Untreated, time_Radiated, time_Radiated_BPA),
                     status=c(censor_Untreated, censor_Radiated, censor_Radiated_BPA),
                     group= rep(1:3, each=10))

library(KMsurv)
library(survival)

I have tried to use the function: pairwise_survdiff but I could not build a code on it.我曾尝试使用函数: pairwise_survdiff但我无法在其上构建代码。

Also, I want to perform the test for trend which would test this ordered hypothesis (untreated animals will have the worst survival, radiated rats will have slightly improved survival, and the radiated rats+BPA should have the best survival.)此外,我想进行趋势测试,以测试这个有序的假设(未经治疗的动物的存活率最差,辐射大鼠的存活率会略有提高,而辐射大鼠 + BPA 的存活率应该最好。)

Here is what I have done with the output, but I am unsure which is the value of Chi square and for p-value:这是我对输出所做的,但我不确定卡方的值和 p 值:
Is this correct?这样对吗?

KM.fit<-survfit(Surv(time,status)~group, conf.type="none", data=myData)
KM.fit

Call: survfit(formula = Surv(time, status) ~ group, data = myData, conf.type = "none") 

         n events median
group=1 10     10     25
group=2 10      9     30
group=3 10      8     37

myData.fit<-ten(Surv(time,status)~group, data=myData)
comp(myData.fit, p=0, q=0,scores =c(1,2,3))
            chiSq df     pChisq    
1          33.380  2 5.6436e-08 ***
n          30.255  2 2.6925e-07 ***
sqrtN      32.037  2 1.1046e-07 ***
S1         29.657  2 3.6307e-07 ***
S2         29.496  2 3.9349e-07 ***
FH_p=0_q=0 33.380  2 5.6436e-08 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
$tft
                   Q       Var      Z      pNorm    
1            16.0869    8.6116 5.4819 4.2081e-08 ***
n           364.0000 4741.0509 5.2864 1.2471e-07 ***
sqrtN        76.0224  196.2111 5.4272 5.7230e-08 ***
S1           11.1539    4.5558 5.2257 1.7351e-07 ***
S2           10.6871    4.2060 5.2110 1.8779e-07 ***
FH_p=0_q=0   16.0869    8.6116 5.4819 4.2081e-08 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

$scores
[1] 1 2 3

Please remember to specify all required packages when posting a question.请记住在发布问题时指定所有必需的包。 You've omitted the survminer package, which is required for using the pairwise_survdiff function.你省略了survminer包,这是需要使用pairwise_survdiff功能。

library(survminer)

The following code works on your dataset, myData, so I'm not sure what code you tried.以下代码适用于您的数据集 myData,因此我不确定您尝试了哪些代码。

pairwise_survdiff(Surv(time,status)~group, data=myData)

    Pairwise comparisons using Log-Rank test 

data:  myData and group 

  1       2     
2 0.0011  -     
3 9.7e-06 0.0014

P value adjustment method: BH  # Bonferroni-Holm method of adjustment (default)

So all three groups have a significantly different survival.因此,所有三组的生存率都存在显着差异。

The group variable should be converted into a factor, not just for labeling purposes on survival curves, but many modelling functions will assume the variable is continuous otherwise, which is clearly not the case here.组变量应该被转换成一个因子,不仅仅是为了在生存曲线上做标记,但是许多建模函数会假设变量是连续的,否则在这里显然不是这种情况。

myData$group <- factor(myData$group, labels=c("Untreated","Radiated","Rad+BPA"))

KM.fit <- survfit(Surv(time,status)~group, data=myData)

ggsurvplot(KM.fit, data=myData,

       # Add median survival times (horizontal and vertical)
       surv.median.line = "hv", 

       # Legend placement, title, and labels
       legend = c(0.25, 0.75),
       legend.title = "Treatment Group",
       legend.labs = c("Untreated","Radiated","Rad+BPA"),
       # Add p-value and 95% confidence intervals
       pval = TRUE,
       conf.int = TRUE,

       # Add risk table
       risk.table = TRUE,
       tables.theme = theme_cleantable(),

       # Color palette
       palette = c("green4", "orange", "red"),
       ggtheme = theme_bw()
)

在此处输入图片说明


myData.fit <- ten(Surv(time,status)~group, data=myData)
comp(myData.fit, p=0, q=0, scores=1:3) # Scores 1, 2, 3 will be the default 

            chiSq df     pChisq    
1          33.380  2 5.6436e-08 ***  # log-rank test
n          30.255  2 2.6925e-07 ***  # Gehan-Breslow generalized Wilcoxon
sqrtN      32.037  2 1.1046e-07 ***  # Tarone-Ware
S1         29.657  2 3.6307e-07 ***  # Peto-Peto’s modified survival estimate
S2         29.496  2 3.9349e-07 ***  # modified Peto-Peto (by Andersen)
FH_p=0_q=0 33.380  2 5.6436e-08 ***  # Fleming-Harrington

Which is the value of the Chi-square and p-value?卡方值和 p 值哪个是值? All of them are!他们都是! The function gives you six to choose from.该功能为您提供六种选择。 Here they are all significant.在这里,它们都很重要。 See the package documentation for more details.有关更多详细信息,请参阅 包文档

The $tst section (not shown) gives the results of the test for trends. $tst部分(未显示)给出了趋势测试的结果。 All comparisons and tests for trends indicate that there is a statistically significant difference in the survival of the rats in the three groups.趋势的所有比较和检验表明,三组大鼠的存活率存在统计学显着差异。 Untreated rats have the worst survival (median=25 days), followed by radiated rats (median=30 days) and radiated+BPA (median=37 days).未治疗大鼠的存活率最差(中位数 = 25 天),其次是辐射大鼠(中位数 = 30 天)和辐射 + BPA(中位数 = 37 天)。


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

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