data(pbc_rf)
data(pbc_vs)
# For the top 6 covariates of the rfsrc object by minimal depth
xvar <- pbc_vs$topvars[1:6]
# Calculate the 1 year partial dependence
pbc_prtl <- plot.variable(pbc_rf, surv.type="surv",
time=1,
xvar.names=xvar, partial=TRUE,
show.plots = FALSE)
# Calculate the 3 year partial dependence
pbc_prtl.3 <- plot.variable(pbc_rf, surv.type="surv",
time=3,
xvar.names=xvar, partial=TRUE,
show.plots = FALSE)
# Create gg_partial objects
gg_dta <- gg_partial(pbc_prtl)
gg_dta.3 <- gg_partial(pbc_prtl.3)
# Combine the objects to get multiple time curves
# along variables on a single figure.
pbc_ggpart <- combine(gg_dta, gg_dta.3,
labels=c("1 Year", "3 Years"))
Run the code above in your browser using DataLab