Search code examples
rsurvival-analysis

Mantel-Byar test and Simon-Makuch plot for survival analysis with time-dependent covariate in R


I am trying to conduct a survival analysis with a time-dependent covariate using the Mantel-Byar test and then adding the Simon-Makuch survival plot in R, using the Rcmdr package.

Unfortunately the corresponding R documentation is not complete and I am stuck.

The corresponding mock dataset is the following:

id <- c(1, 2, 3, 4)
death <- c(0, 1, 0, 1)
death_days <- c(31, 59, 46, 41)
nonfatal_event <- c(0, 1, 1, 0)
nonfatal_event_days <- c(31, 51, 41, 41)
dataset <- data.frame(id, death, death_days, nonfatal_event, nonfatal_event_days)

How should I proceed further?


Solution

  • I have figured out that after installing the Rcmdr and the RcmdrPlugin.EZR packages, I needed to call the Rcmdr package, then call the RcmdrPlugin.EZR from the Tools menu.

    Then, I needed to load the dataset, call the Cox proportional hazard regression with time-dependent covariate, and finally call first the Mantel-Byar test and then the Simon-Makuch plot.

    A sample code is provided below, which can be directly called in R Commander.

    #####Cox proportional hazard regression with time-dependent covariate#####
    library(survival, pos=15)
    library(aod, pos=16)
    TempDF <- Dataset
    TempTD <- stsplit(TempDF, TempDF$death_days, TempDF$death, 
      TempDF$nonfatal_event_days, TempDF$nonfatal_event, TempDF$death_days)
    CoxModel.1 <- coxph(Surv(start_td, stop_td, endpoint_td==1) ~ covariate_td, 
      data=TempTD, method="breslow")
    res <- NULL
    (res <- summary(CoxModel.1))
    cox.table <- NULL
    cox.table <- signif(cbind(t(res$conf.int[,c(1,3,4)]), 
      p.value=res$coefficients[,5]), digits=4)
    rownames(cox.table) <- rownames(res$coefficients)
    colnames(cox.table) <- gettext(domain="R-RcmdrPlugin.EZR",c("Hazard ratio", 
      "Lower 95%CI", "Upper 95%CI", "p.value"))
    cox.table
    waldtest(CoxModel.1)
    windows(width=7, height=7); par(lwd=1, las=1, family="sans", cex=1, 
      mgp=c(3.0,1,0))
    oldpar <- par(oma=c(0,0,3,0), mfrow=c(1,1))
    plot(cox.zph(CoxModel.1), df=2)
    par(oldpar)
    print(cox.zph(CoxModel.1))
    
    #####Mantel-Byer test#####
    Mantel.Byar(Group = "covariate_td", Event = TempTD$endpoint_td, 
    StartTime = TempTD$start_td, StopTime = TempTD$stop_td, 
    method = c("SAS", "Tominaga"), plot=0, landmark=0)
    
    #####Simon-Makuch plot#####
    Mantel.Byar(Group = "covariate_td", Event = TempTD$endpoint_td, 
    StartTime = TempTD$start_td, StopTime = TempTD$stop_td, 
    method = c("SAS", "Tominaga"), plot=1, landmark=0)