How can I add a p-value to my plot of the matching index in R?

In my survival analysis task, I used the proportional cox model to compute the value of the matching index (c-index) in different groups of my data set. I was wondering how can I add a p-value to my c-index graph to compare different groups to look like this?

enter image description here

here is my code:

 surv <- with(group, Surv(group$survival, group$time))

# calculate survival
 sum.surv_1 <-  with(group, summary(coxph(surv ~ group$1)))
 sum.surv.1_2 <-  with(group, summary(coxph(surv ~ group$1 + group$2,ties = T)))


c_index.1 <- sum.surv_1$concordance
c_index.1_2 <- sum.surv.1_2$concordance

Comb_cIndex = data.frame(rbind(c_index.1["concordance.concordant"],
                           c_index.1_2["concordance.concordant"]))

barplot(as.matrix(Comb_cIndex), beside=TRUE, axis.lty=1, 
    ylab = "C Index", ylim = c(0, 0.8), 
    col = c("green", "blue")) 

Thanks in advance,

+4
source share
1 answer

I managed to find the answer by calculating the matching values ​​with / without relationships for my dataset. following this example:

p-value for testing two c-indices ignoring relationships

round(cindex.comp(c_index_no_ties1, c_index_no_ties2)$p.value,3)

p- c-, t- - ,

cindex.p.ties <- function(c_index_ties1, c_index_ties2, c_index_no_ties1, c_index_no_ties2) {
    eps <- 1E-15
    n <- c_index_no_ties1$n
    r <- cor(c_index_no_ties1$data$x, c_index_no_ties2$data$x, use="complete.obs", method="spearman")
    if ((1 - abs(r)) > eps) {
      t.stat <- (c_index_ties1$concordance - c_index_ties2$concordance) / sqrt(c_index_ties1$std.err^2 + c_index_ties2$std.err^2 - 2 * r * c_index_ties1$std.err * c_index_ties2$std.err)
      diff.ci.p <- pt(q=t.stat, df=n - 1, lower.tail=FALSE)
    } else { diff.ci.p <- 1 }
    return(list("p.value"=diff.ci.p))
  }
cindex.p.ties(c_index_ties1=c_index_ties1, c_index_ties2=c_index_ties2, c_index_no_ties1=c_index_no_ties1, c_index_no_ties2=c_index_no_ties2)
0

All Articles