From a3c816ad64408a884610c16ed79ebe8c7dd4b4fe Mon Sep 17 00:00:00 2001 From: Jens Sauer Date: Sun, 17 Jan 2021 11:21:05 +0100 Subject: [PATCH] coxph: Adjust coxph summary output Split HR and CI, print logrank values. --- coxph.R | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/coxph.R b/coxph.R index 189c691..a6cb293 100644 --- a/coxph.R +++ b/coxph.R @@ -21,20 +21,21 @@ covariates <- c("dx_age", "asct_age", "time_dx_to_asct", "sex", # # Extract data from Cox PH results # -sma_cox_res <- function(x) { - x <- summary(x) +sma_cox_res <- function(m) { + x <- summary(m) p.value<-signif(x$wald["pvalue"], digits=2) wald.test<-signif(x$wald["test"], digits=2) beta<-signif(x$coef[1], digits=2);#coeficient beta HR <-signif(x$coef[2], digits=2);#exp(beta) HR.confint.lower <- signif(x$conf.int[,"lower .95"], 2) HR.confint.upper <- signif(x$conf.int[,"upper .95"],2) - HR <- paste0(HR, " (", - HR.confint.lower, "-", HR.confint.upper, ")") + HR.confint <- paste0(HR.confint.lower, "-", HR.confint.upper) + logtest <- signif(x$logtest["test"], digits = 2) + logtest.pvalue <- x$logtest["pvalue"] - res<-c(beta, HR, wald.test, p.value) - names(res)<-c("beta", "HR (95% CI for HR)", "wald.test", - "p.value") + res<-c(beta, HR, HR.confint, wald.test, p.value, logtest, logtest.pvalue) + names(res)<-c("beta", "HR", "95% CI for HR", "wald test", + "p value", "logtest", "logtest p value") return(res) }