# NOT RUN {
## Load library ##
library(StratifiedMedicine)
## Examples: Continuous Outcome ##
dat_ctns = generate_subgrp_data(family="gaussian")
Y = dat_ctns$Y
X = dat_ctns$X
A = dat_ctns$A
# Run Default: glmnet, ranger (X-learner), lmtree, dr #
res0 = PRISM(Y=Y, A=A, X=X)
summary(res0)
plot(res0)
res1 = PRISM(Y=Y, A=A, X=X, filter="None")
summary(res1)
plot(res1)
# }
# NOT RUN {
# Search for Prognostic Only (omit A from function) #
# }
# NOT RUN {
res3 = PRISM(Y=Y, X=X)
summary(res3)
plot(res3)
# }
# NOT RUN {
## With bootstrap (No filtering) ##
# }
# NOT RUN {
library(ggplot2)
res_boot = PRISM(Y=Y, A=A, X=X, resample = "Bootstrap", R=50, verbose.resamp = TRUE)
# Plot of distributions and P(est>0) #
plot(res_boot, type="resample", estimand = "E(Y|A=1)-E(Y|A=0)")+
geom_vline(xintercept = 0)
aggregate(I(est>0)~Subgrps, data=res_boot$resamp_dist, FUN="mean")
# }
# NOT RUN {
## Examples: Binary Outcome ##
# }
# NOT RUN {
dat_bin = generate_subgrp_data(family="binomial")
Y = dat_bin$Y
X = dat_bin$X
A = dat_bin$A
# Run Default: glmnet, ranger, glmtree, dr #
res0 = PRISM(Y=Y, A=A, X=X)
plot(res0)
# }
# NOT RUN {
# Survival Data ##
# }
# NOT RUN {
library(survival)
library(ggplot2)
require(TH.data); require(coin)
data("GBSG2", package = "TH.data")
surv.dat = GBSG2
# Design Matrices ###
Y = with(surv.dat, Surv(time, cens))
X = surv.dat[,!(colnames(surv.dat) %in% c("time", "cens")) ]
set.seed(513)
A = rbinom( n = dim(X)[1], size=1, prob=0.5 )
# PRISM: glmnet ==> Random Forest to estimate Treatment-Specific RMST
# ==> MOB (Weibull) ==> Cox for HRs#
res_weib = PRISM(Y=Y, A=A, X=X)
plot(res_weib, type="PLE:waterfall")
plot(res_weib)
#PRISM: glmnet ==> Random Forest to estimate Treatment-Specific RMST
#RPART_CATE: Regress RMST on RPART for subgroups #
res_cate = PRISM(Y=Y, A=A, X=X, submod="rpart_cate")
plot(res_cate)
# PRISM: ENET ==> CTREE ==> Cox; with bootstrap #
res_ctree1 = PRISM(Y=Y, A=A, X=X, ple="None", submod = "ctree",
resample="Bootstrap", R=50, verbose.resamp = TRUE)
plot(res_ctree1)
plot(res_ctree1, type="resample", estimand="HR(A=1 vs A=0)")+geom_vline(xintercept = 1)
aggregate(I(est<0)~Subgrps, data=res_ctree1$resamp_dist, FUN="mean")
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab