It is generally not possible to estimate the survival function when competing risks are present. It is, however, possible to estimate the cause-specific cumulative incidence function, which is very similar. Multiple methods to adjust these curves for confounding factors have also been proposed in the literature. The adjustedCurves
package implements most of these methods in the adjustedcif
function. Here is an example from the documentation:
library(adjustedCurves)
library(survival)
library(riskRegression)
set.seed(42)
# simulate some example data
sim_dat <- sim_confounded_crisk(n=1000, max_t=1.2)
sim_dat$group <- as.factor(sim_dat$group)
# treatment assignment model to estimate the
# propensity score (which can be converted to inverse probability weights)
glm_mod <- glm(group ~ x2 + x3 + x5 + x6, data=sim_dat, family="binomial")
# using inverse probability of treatment weighting
adjcif <- adjustedcif(data=sim_dat,
variable="group",
ev_time="time",
event="event",
cause=1,
method="iptw",
treatment_model=glm_mod,
conf_int=TRUE)
plot(adjcif, conf_int=TRUE)

A rigorous description can be found in the excellent article by Ozenne et al. (https://onlinelibrary.wiley.com/doi/epdf/10.1002/bimj.201800298). A review and simulation studies for adjusted survival curves without competing risks can be found in my recent article on the topic (https://onlinelibrary.wiley.com/doi/full/10.1002/sim.9681).