Giuseppe Biondi-Zoccai - 1 year ago 166

R Question

I am trying to conduct a survival analysis 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 | death | death_days | non-fatal_event | non-fatal_event_days

1 | 0 | 31 | 0 | 31

2 | 1 | 59 | 1 | 51

3 | 0 | 46 | 1 | 41

4 | 1 | 41 | 0 | 41

How should I proceed further?

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

Answer Source

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$non-fatal_event_days, TempDF$non-fatal_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 = TempTD$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 = TempTD$covariate_td, Event = TempTD$endpoint_td,
StartTime = TempTD$start_td, StopTime = TempTD$stop_td,
method = c("SAS", "Tominaga"), plot=1, landmark=0)
```

Recommended from our users: **Dynamic Network Monitoring from WhatsUp Gold from IPSwitch**. ** Free Download**