From 63c2883c7e4cb015e357a2c276f0937433dae0cb Mon Sep 17 00:00:00 2001 From: Jens Sauer Date: Mon, 18 Jan 2021 01:46:49 +0100 Subject: [PATCH] coxph: Adjust for cause-specific analysis Since the data specifies death as a competing risk, the cox analysis must be adjusted. Death will now, as it was before, treated as a censor. --- coxph.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coxph.R b/coxph.R index 3ccf4fb..5393f31 100644 --- a/coxph.R +++ b/coxph.R @@ -44,7 +44,7 @@ sma_cox_res <- function(m) { # sma_coxph_univ <- function() { univ_formulas <- sapply(covariates, function(x) as.formula( - paste('Surv(time_at_risk, time_at_risk_status) ~ ', + paste('Surv(time_at_risk, ifelse(time_at_risk_status == 1, 1, 0)) ~ ', x))) univ_models <- lapply(univ_formulas, function(x) {coxph(x, data = secmal)})