coxph: Adjust coxph summary output

Split HR and CI, print logrank values.
This commit is contained in:
Jens Sauer 2021-01-17 11:21:05 +01:00
parent 351b26368d
commit a3c816ad64

15
coxph.R
View File

@ -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)
}