Reputation: 1
can I make "number at risk "table for cox plot if I have more than one independent variable? if it possible where can I find the relevant code (I searched but couldn't find) the code I used on my data:
fit <- coxph(Surv(time,event) ~chr1q21_status+CCND1+CRTM1+IRF4,data = myeloma)
ggsurvplot(fit, data = myeloma,
risk.table=TRUE, break.time.by=365, xlim = c(0,4000),
risk.table.y.text=FALSE, legend.labs = c("2","3","4+"))
got this message- object 'ggsurv' not found' although for only one variable and the function survfit it worked.
Upvotes: 0
Views: 1442
Reputation: 3038
"number at risk "table for cox plot
It's not a Cox plot, it's a Kaplan-Meier plot. You're trying to plot a Cox model, when what you want is to fit KM curves using survfit
and then to plot the resulting fit:
library("survival")
library("survminer")
fit <- survfit(Surv(time,status) ~ ph.ecog + sex , data = lung)
ggsurvplot(fit, data = lung, risk.table = TRUE)
Since you now mention that you have continuous predictors, perhaps you could think about what you expect an at-risk table or KM plot to show. Here's an example of binning a continuous measure (age):
library("survival")
library("survminer")
#> Loading required package: ggplot2
#> Loading required package: ggpubr
#> Loading required package: magrittr
lung$age_bin <- cut(lung$age, quantile(lung$age))
fit <- survfit(Surv(time,status) ~ age_bin + sex , data = lung)
ggsurvplot(fit, data = lung, risk.table = TRUE)
Upvotes: 0