Learn R Programming

ggRandomForests (version 1.1.2)

gg_partial_coplot.ggRandomForests: Data structures for stratified partial coplots

Description

Data structures for stratified partial coplots

Usage

gg_partial_coplot.ggRandomForests(object, xvar, groups, surv_type = c("mort",
  "rel.freq", "surv", "years.lost", "cif", "chf"), time, ...)

Arguments

object
randomForestSRC::rfsrc object
xvar
list of partial plot variables
groups
vector of stratification variable.
surv_type
for survival random forests, c("mort", "rel.freq", "surv", "years.lost", "cif", "chf")
time
vector of time points for survival random forests partial plots.
...
extra arguments passed to randomForestSRC::plot.variable function

Value

Examples

Run this code
data(rfsrc_pbc, package="ggRandomForests")

# Create a 3d coplot, survival as a function of bilirubin and prothrombin
prothrombin_grp <- cut(rfsrc_pbc$xvar$prothrombin, breaks=c(8.9,10,11,12,18))

gg_dta <- gg_partial_coplot(rfsrc_pbc, xvar="bili", groups=prothrombin_grp,
  surv_type="surv", time=1, show.plots=FALSE)

ggpl <- ggplot(gg_dta,
               aes(x=bili, y=yhat, shape=groups, color=groups))+
       geom_point()+geom_smooth(se=FALSE)+
       labs(x="Surgical Date", y="Survival 1 year",
            shape="Prothrombin", color="Prothrombin")+
       scale_color_brewer(palette="Set1")

ggpl

## Build a list of 25 split points
prothrom <- rfsrc_pbc$xvar %>% filter(!is.na(prothrombin))
n.x <- length(unique(prothrom$prothrombin))
npts <- 25
prothrombin_pts <- sort(unique(prothrom$prothrombin))[
   unique(as.integer(seq(1, n.x, length = min(npts, n.x))))]

# Create a 3d coplot, survival as a function of bilirubin and prothrombin
prothrombin_grp <- cut(rfsrc_pbc$xvar$prothrombin, breaks=prothrombin_pts)

gg_dta <- gg_partial_coplot(rfsrc_pbc, xvar="bili", groups=prothrombin_grp,
  surv_type="surv", time=1, show.plots=FALSE)

ggpl <- ggplot(gg_dta,
               aes(x=bili, y=yhat, shape=groups, color=groups))+
       geom_point()+geom_smooth(se=FALSE)+
       labs(x="Surgical Date", y="Survival 1 year",
            shape="Prothrombin", color="Prothrombin")+
       scale_color_brewer(palette="Set1")

ggpl

Run the code above in your browser using DataLab