'survival plot problems: ggsurvplot with multiple variables? interaction terms?
I am doing a survival analysis for a migration study using "survival" and the "survminer" packages. There are two variables (matt_ncdem and flood_risk_simple), whose effect I care about. Then I have a number of control variables. I want to show the kaplan-meier curve graph for the two important variables, but controlled for the other variables. However, I cannot figure out how to do thi.
Can I use ggsurvplot to plot the variables I care about and suppress the ones I don't? For example, I am using the following equation with the following plot (please ignore how ugly the graph is, that's a problem I can deal with later):
sfit <- survfit(Surv(flo_tmove, flo.2yr.move) ~ fl0.ncdem.fl + flo_flood_risk_simple, data=flo_timeadd)
summary(sfit, times=seq(0, 730, 30))
ggsurvplot(sfit, conf.int=TRUE, pval=TRUE, risk.table=TRUE,
title="Kaplan-Meier Curve for Migration", ylim=c(.75,1), xscale = "d_m",
risk.table.height=.3)
but really I'd like to make a km curve graph for this equation but that just shows the lines for matt_ncdem*flood_risk_simple, but controlling for the other variables.
c_sfit <- coxph(Surv(matt_tmove, matt.2yr.move)~
matt_ncdem*flood_risk_simple + tenure.yr + CurrentAge + percap.inc.k + employment + rentership + pop.change + pop.den.k,
data=matt_timeadd)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

