The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

An Introduction to StratifiedMedicine

Thomas Jemielita

Introduction

Welcome to the StratifiedMedicine R package. The overall goal of this package is to develop analytic and visualization tools to aid in stratified and personalized medicine. Stratified medicine aims to find subsets or subgroups of patients with similar treatment effects, for example responders vs non-responders, while personalized medicine aims to understand treatment effects at the individual level (does a specific individual respond to treatment A?).

Currently, the main tools in this package area: (1) Filter Models (identify important variables and reduce input covariate space), (2) Patient-Level Estimate Models (using regression models, estimate counterfactual quantities, such as the conditional average treatment effect or CATE), (3) Subgroup Models (identify groups of patients using tree-based approaches), and (4) Parameter Estimation (across the identified subgroups), and (5) PRISM (Patient Response Identifiers for Stratified Medicine; combines tools 1-4). Development of this package is ongoing.

As a running example, consider a continuous outcome (ex: % change in tumor size) with a binary treatment (study treatment vs control). The estimand of interest is the average treatment effect, \(\theta_0 = E(Y|A=1)-E(Y|A=0)\). First, we simulate continuous data where roughly 30% of the patients receive no treatment-benefit for using \(A=1\) vs \(A=0\). Responders (should receive study treatment) vs non-responders (should receive control) are defined by the continuous predictive covariates \(X_1\) and \(X_2\) for a total of four subgroups. Subgroup treatment effects are: \(\theta_{1} = 0\) (\(X_1 \leq 0, X_2 \leq 0\)), \(\theta_{2} = 0.25 (X_1 > 0, X_2 \leq 0)\), \(\theta_{3} = 0.45 (X_1 \leq 0, X2 > 0\)), \(\theta_{4} = 0.65 (X_1>0, X_2>0)\).

library(ggplot2)
library(dplyr)
library(partykit)
library(StratifiedMedicine)
library(survival)
dat_ctns = generate_subgrp_data(family="gaussian")
Y = dat_ctns$Y
X = dat_ctns$X # 50 covariates, 46 are noise variables, X1 and X2 are truly predictive
A = dat_ctns$A # binary treatment, 1:1 randomized 
length(Y)
#> [1] 800
table(A)
#> A
#>   0   1 
#> 409 391
dim(X)
#> [1] 800  50

Filter Models

The aim of filter models is to potentially reduce the covariate space such that subsequent analyses focus on the “important” variables. For example, we may want to identify variables that are prognostic and/or predictive of the outcome across treatment levels. Filter models can be run using the “filter_train” function. The default is search for prognostic variables using elastic net (Y~ENET(X); Hou and Hastie 2005). Random forest based importance (filter=“ranger”) is also available. See below for an example. Note that the object “filter.vars” contains the variables that pass the filter, while “plot_importance” shows us the relative importance of the input variables. For glmnet, this corresponds to the standardized regression coefficients (variables with coefficients=0 are not shown).

res_f <- filter_train(Y, A, X, filter="glmnet")
res_f$filter.vars
#>  [1] "X1"  "X2"  "X3"  "X5"  "X7"  "X8"  "X10" "X12" "X16" "X18" "X24" "X26"
#> [13] "X31" "X40" "X46" "X50"
plot_importance(res_f)

An alternative approach is to search for variables that are potentially prognostic and/or predictive by forcing variable by treatment interactions, or Y~ENET(X,XA). Variables with estimated coefficients of 0 in both the main effects (X) and interaction effects (XA) are filtered. This can be implemented by tweaking the hyper-parameters:

Here, note that both the main effects of X1 and X2, along with the interaction effects (labeled X1_trtA and X2_trtA), have relatively large estimated coefficients.

Patient-level Estimate (PLE) Models

The aim of PLE models is to estimate counterfactual quantities, for example the CATE. This is implemented through the “ple_train” function. The “ple_train” follows the framework of Kunzel et al 2019, which utilizes base learners and meta learners to obtain estimates of interest. For family=“gaussian”, “binomial”, this output estimates of and treatment differences. For family=“survival”, either logHR or restricted mean survival time (RMST) estimates are obtained. Current base-leaner options include “linear” (lm/glm/or cox), “ranger” (random forest through ranger R package), “glmnet” (elastic net), and “bart” (Bayesian Additive Regression Trees through BART R package). Meta-learners include the “T-Leaner” (treatment specific models), “S-learner” (single regression model), and “X-learner” (2-stage approach, see Kunzel et al 2019). See below for an example. Note that the object “mu_train” contains the training set patient-level estimates (outcome-based and propensity scores), “plot_ple” shows a waterfall plot of the estimated CATEs, and “plot_dependence” shows the partial dependence plot for variable “X1” with respect to the estimated CATE.

res_p1 <- ple_train(Y, A, X, ple="ranger", meta="T-learner")
summary(res_p1$mu_train)
#>       mu_0             mu_1           diff_1_0             pi_0       
#>  Min.   :0.6493   Min.   :0.5308   Min.   :-1.12502   Min.   :0.5112  
#>  1st Qu.:1.4166   1st Qu.:1.5707   1st Qu.:-0.02003   1st Qu.:0.5112  
#>  Median :1.6217   Median :1.8048   Median : 0.20715   Median :0.5112  
#>  Mean   :1.6340   Mean   :1.8458   Mean   : 0.21181   Mean   :0.5112  
#>  3rd Qu.:1.8422   3rd Qu.:2.1153   3rd Qu.: 0.46391   3rd Qu.:0.5112  
#>  Max.   :2.6318   Max.   :3.0649   Max.   : 1.20451   Max.   :0.5112  
#>       pi_1       
#>  Min.   :0.4888  
#>  1st Qu.:0.4888  
#>  Median :0.4888  
#>  Mean   :0.4888  
#>  3rd Qu.:0.4888  
#>  Max.   :0.4888
plot_ple(res_p1)

plot_dependence(res_p1, X=X, vars="X1")

Next, let’s illustrate how to change the meta-learner and the hyper-parameters. See below, along with a 2-dimension PDP example.

res_p2 <- ple_train(Y, A, X, ple="ranger", meta="T-learner", hyper=list(mtry=5))
plot_dependence(res_p2, X=X, vars=c("X1", "X2"))

Subgroup Models

Subgroup models are called using the “submod_train” function and currently only include tree-based methods (ctree, lmtree, glmtree from partykit R package and rpart from rpart R package). First, let’s run the default (for continuous, uses lmtree). This aims to find subgroups that are either prognostic and/or predictive.

res_s1 <- submod_train(Y, A, X, submod="lmtree")
summary(res_s1)
#> $submod_call
#> submod_train(Y = Y, A = A, X = X, submod = "lmtree")
#> 
#> $`Number of Identified Subgroups`
#> [1] 4
#> 
#> $`Variables that Define the Subgroups`
#> [1] "X1, X2"
#> 
#> $`Treatment Effect Estimates (observed)`
#>    Subgrps   N  estimand     est     SE     LCL    UCL         pval alpha
#> 3        3 149 mu_1-mu_0 -0.0745 0.1775 -0.4253 0.2762 0.6751291856  0.05
#> 31       4 277 mu_1-mu_0 -0.0025 0.1178 -0.2344 0.2294 0.9830298696  0.05
#> 32       6 267 mu_1-mu_0  0.3930 0.1285  0.1399 0.6460 0.0024593995  0.05
#> 33       7 107 mu_1-mu_0  0.7351 0.1963  0.3459 1.1243 0.0002942317  0.05
#> 1     ovrl 800 mu_1-mu_0  0.2147 0.0727  0.0720 0.3574 0.0032352410  0.05
#> 
#> attr(,"class")
#> [1] "summary.submod_train"
plot_tree(res_s1)

At each node, “naive” treatment estimates are provided. Without some type of resampling or penalization, subgroup-specific estimates tend to be overly positive or negative, as the same data that trains the subgroup model is used for parameter estimation. Resampling methods, such as bootstrapping, can help mitigate biased treatment estimates (more details in later Sections). See the “resample” argument for more details.

Another generic approach is “rpart_cate”, which corresponds to regressing CATE~rpart(X) where CATE corresponds to estimates of E(Y|A=1,X)-E(Y|A=0,X). For survival endpoints, the treatment difference would correspond to either logHR or RMST. For the example below, we set the clinically meaningful threshold to 0.1 (delta=“>0.10”).

res_s2 <- submod_train(Y, A, X,  mu_train=res_p2$mu_train, submod="rpart_cate")
summary(res_s2)
#> $submod_call
#> submod_train(Y = Y, A = A, X = X, mu_train = res_p2$mu_train, 
#>     submod = "rpart_cate")
#> 
#> $`Number of Identified Subgroups`
#> [1] 5
#> 
#> $`Variables that Define the Subgroups`
#> [1] "X1, X37, X17, X39"
#> 
#> $`Treatment Effect Estimates (observed)`
#>    Subgrps   N  estimand     est     SE     LCL     UCL         pval alpha
#> 3        4 199 mu_1-mu_0 -0.4171 0.1534 -0.7196 -0.1145 7.141175e-03  0.05
#> 31       5  96 mu_1-mu_0  0.2516 0.2030 -0.1514  0.6546 2.182638e-01  0.05
#> 32       6 131 mu_1-mu_0  0.3567 0.1694  0.0216  0.6918 3.714100e-02  0.05
#> 33       8 136 mu_1-mu_0 -0.0067 0.1858 -0.3742  0.3609 9.715056e-01  0.05
#> 34       9 238 mu_1-mu_0  0.7732 0.1402  0.4970  1.0494 9.082100e-08  0.05
#> 1     ovrl 800 mu_1-mu_0  0.2137 0.0745  0.0674  0.3601 4.247613e-03  0.05
#> 
#> attr(,"class")
#> [1] "summary.submod_train"

Treatment Effect Estimation

The “param” argument within “submod_train” and “PRISM” determines the method for treatment effect estimation across the identified subgroups. Options include param=“lm”, “dr”, “gcomp”, “cox”, and “rmst” which correspond respectively to linear regression, the doubly robust estimator, average the patient-level estimates (G-computation), cox regresson, and RMST (as in survRM2 R package). Notably, if the subgroups are determined adaptively (for example through lmtree), without resampling corrections, point-estimates tend to be overly optimistic. Resampling-based methods are described later.

Given a candidate set of subgroups, a “naive” approach is to fit linear regression models within each subgroup to obtain treatment effect estimates (A=1 vs A=0). See below.

param.dat1 <- param_est(Y, A, X, Subgrps = res_s1$Subgrps.train, param="lm")
param.dat1
#>    Subgrps   N  estimand          est         SE         LCL       UCL
#> 1     ovrl 800 mu_1-mu_0  0.214721873 0.07270356  0.07200932 0.3574344
#> 3        3 149 mu_1-mu_0 -0.074540934 0.17749849 -0.42529970 0.2762178
#> 31       4 277 mu_1-mu_0 -0.002507699 0.11778878 -0.23438626 0.2293709
#> 32       6 267 mu_1-mu_0  0.392978208 0.12852946  0.13991368 0.6460427
#> 33       7 107 mu_1-mu_0  0.735079896 0.19631153  0.34587320 1.1242866
#>            pval alpha
#> 1  0.0032352410  0.05
#> 3  0.6751291856  0.05
#> 31 0.9830298696  0.05
#> 32 0.0024593995  0.05
#> 33 0.0002942317  0.05

PRISM: Patient Response Identifiers for Stratified Medicine

While the above tools individually can be useful, PRISM (Patient Response Identifiers for Stratified Medicine; Jemielita and Mehrotra (to appear), https://arxiv.org/abs/1912.03337) combines each component for a stream-lined analysis. Given a data-structure of \((Y, A, X)\) (outcome(s), treatments, covariates), PRISM is a five step procedure:

  1. Estimand: Determine the question(s) or estimand(s) of interest. For example, \(\theta_0 = E(Y|A=1)-E(Y|A=0)\), where A is a binary treatment variable. While this isn’t an explicit step in the PRISM function, the question of interest guides how to set up PRISM.

  2. Filter (filter): Reduce covariate space by removing variables unrelated to outcome/treatment.

  3. Patient-level estimate (ple): Estimate counterfactual patient-level quantities, for example the conditional average treatment effect (CATE), \(\theta(x) = E(Y|X=x,A=1)-E(Y|X=x,A=0)\). These can be used in the subgroup model and/or parameter estimation.

  4. Subgroup model (submod): Identify subgroups of patients with potentially varying treatment response. Based on initial subgroups (ex: tree nodes), we may also pool patients into “benefitting” and “non-benefitting” (see “pool” argument). With or without pooling, subgroup-specific treatment estimates and variability metrics are also provided.

  5. Resampling: Repeat Steps 1-3 across \(R\) resamples for improved statistical performance of subgroup-specific estimates.

Ultimately, PRISM provides information at the patient-level and the subgroup-level (if any). While there are defaults in place, the user can also input their own functions/model wrappers into the PRISM algorithm. We will demonstrate this later. PRISM can also be run without treatment assignment (A=NULL); in this setting, the focus is on finding subgroups based on prognostic effects. The below table describes default PRISM configurations for different family (gaussian, biomial, survival) and treatment (no treatment vs treatment) settings, including the associated estimands. Note that OLS refers to ordinary least squares (linear regression), GLM refers to generalized linear model, and MOB refers to model based partitioning (Zeileis, Hothorn, Hornik 2008; Seibold, Zeileis, Hothorn 2016). To summarise, default models include elastic net (Zou and Hastie 2005) for filtering, random forest (“ranger” R package) for patient-level /counterfactual estimation, and MOB (through “partykit” R package; lmtree, glmtree, and ctree (Hothorn, Hornik, Zeileis 2005)). When treatment assignment is provided, parameter estimation for continuous and binary outcomes uses the double-robust estimator (based on the patient-level estimates). For survival outcomes, the cox regression hazard ratio (HR) or RMST (from the survR2 package) is used.

Default PRISM Configurations (With Treatment)
Step gaussian binomial survival
estimand(s) E(Y|A=0)
E(Y|A=1)
E(Y|A=1)-E(Y|A=0)
E(Y|A=0)
E(Y|A=1)
E(Y|A=1)-E(Y|A=0)
HR(A=1 vs A=0)
filter Elastic Net
(glmnet)
Elastic Net
(glmnet)
Elastic Net
(glmnet)
ple X-learner: Random Forest
(ranger)
X-learner: Random Forest
(ranger)
T-learner: Random Forest
(ranger)
submod MOB(OLS)
(lmtree)
MOB(GLM)
(glmtree)
MOB(OLS)
(lmtree)
param Double Robust
(dr)
Doubly Robust
(dr)
Hazard Ratios
(cox)
Default PRISM Configurations (Without Treatment, A=NULL)
Step gaussian binomial survival
estimand(s) E(Y) Prob(Y) RMST
filter Elastic Net
(glmnet)
Elastic Net
(glmnet)
Elastic Net
(glmnet)
ple Random Forest
(ranger)
Random Forest
(ranger)
Random Forest
(ranger)
submod Conditional Inference Trees
(ctree)
Conditional Inference Trees
(ctree)
Conditional Inference Trees
(ctree)
param OLS
(lm)
OLS
(lm)
RMST
(rmst)

Example: Continuous Outcome with Binary Treatment

For continuous outcome data (family=“gaussian”), the default PRISM configuration is: (1) filter=“glmnet” (elastic net), (2) ple=“ranger” (X-learner with random forest models), (3) submod=“lmtree” (model-based partitioning with OLS loss), and (4) param=“dr” (doubly-robust estimator). To run PRISM, at a minimum, the outcome (Y), treatment (A), and covariates (X) must be provided. See below. The summary gives a high-level overview of the findings (number of subgroups, parameter estimates, variables that survived the filter). The default plot() function currently combines tree plots with parameter estimates using the “ggparty” package.

# PRISM Default: filter_glmnet, ranger, lmtree, dr #
res0 = PRISM(Y=Y, A=A, X=X)
#> Observed Data
#> Filtering: glmnet
#> Counterfactual Estimation: ranger (X-learner)
#> Subgroup Identification: lmtree
#> Treatment Effect Estimation: dr
summary(res0)
#> $call
#> PRISM(Y = Y, A = A, X = X)
#> 
#> $`PRISM Configuration`
#> [1] "[Filter] glmnet => [PLE] ranger => [Subgroups] lmtree => [Param] dr"
#> 
#> $`Variables that Pass Filter`
#>  [1] "X1"  "X2"  "X3"  "X5"  "X7"  "X8"  "X10" "X12" "X16" "X18" "X24" "X26"
#> [13] "X31" "X40" "X46" "X50"
#> 
#> $`Number of Identified Subgroups`
#> [1] 6
#> 
#> $`Variables that Define the Subgroups`
#> [1] "X1, X2, X50, X26"
#> 
#> $`Treatment Effect Estimates (observed)`
#>    Subgrps   N  estimand     est     SE     LCL    UCL         pval alpha
#> 36      10 168 mu_1-mu_0  0.1915 0.1314 -0.0661 0.4491 1.451029e-01  0.05
#> 31      11 107 mu_1-mu_0  0.7141 0.1761  0.3688 1.0593 5.037003e-05  0.05
#> 32       3 149 mu_1-mu_0 -0.0344 0.1539 -0.3360 0.2673 8.232592e-01  0.05
#> 33       5 110 mu_1-mu_0  0.2160 0.1587 -0.0950 0.5270 1.734921e-01  0.05
#> 34       6 167 mu_1-mu_0 -0.1415 0.1303 -0.3968 0.1138 2.774311e-01  0.05
#> 35       9  99 mu_1-mu_0  0.6343 0.1879  0.2659 1.0026 7.386936e-04  0.05
#> 3     ovrl 800 mu_1-mu_0  0.2080 0.0633  0.0838 0.3321 1.024355e-03  0.05
#> 
#> attr(,"class")
#> [1] "summary.PRISM"
plot(res0) # same as plot(res0, type="tree")

We can also directly look for prognostic effects by specifying omitting A (treatment) from PRISM (or submod_train):

# PRISM Default: filter_glmnet, ranger, ctree, param_lm #
res_prog = PRISM(Y=Y, X=X)
#> No Treatment Variable (A) Provided: Searching for Prognostic Effects
#> Observed Data
#> Filtering: glmnet
#> Counterfactual Estimation: ranger (none)
#> Subgroup Identification: ctree
#> Treatment Effect Estimation: lm
# res_prog = PRISM(Y=Y, A=NULL, X=X) #also works
summary(res_prog)
#> $call
#> PRISM(Y = Y, X = X)
#> 
#> $`PRISM Configuration`
#> [1] "[Filter] glmnet => [PLE] ranger => [Subgroups] ctree => [Param] lm"
#> 
#> $`Variables that Pass Filter`
#>  [1] "X1"  "X2"  "X3"  "X5"  "X7"  "X8"  "X10" "X12" "X16" "X18" "X24" "X26"
#> [13] "X31" "X40" "X46" "X50"
#> 
#> $`Number of Identified Subgroups`
#> [1] 6
#> 
#> $`Variables that Define the Subgroups`
#> [1] "X2, X1, X26"
#> 
#> $`Treatment Effect Estimates (observed)`
#>   Subgrps   N estimand    est     SE    LCL    UCL          pval alpha
#> 2      10  87       mu 1.9091 0.1006 1.7091 2.1091  1.724030e-32  0.05
#> 3      11  80       mu 2.6842 0.1133 2.4586 2.9097  1.216018e-37  0.05
#> 4       4 132       mu 1.1119 0.0970 0.9200 1.3038  1.706125e-21  0.05
#> 5       5 266       mu 1.5107 0.0636 1.3855 1.6360  1.363491e-67  0.05
#> 6       7 113       mu 1.7016 0.0995 1.5045 1.8987  5.105329e-33  0.05
#> 7       8 122       mu 2.1780 0.0856 2.0085 2.3474  2.060358e-50  0.05
#> 1    ovrl 800       mu 1.7343 0.0363 1.6630 1.8056 2.950234e-236  0.05
#> 
#> attr(,"class")
#> [1] "summary.PRISM"

Next, circling back to the first PRISM model with treatment included, let’s review other core PRISM outputs. Results relating to the filter include “filter.mod” (model output) and “filter.vars” (variables that pass the filter). The “plot_importance” function can also be called:

Results relating to “ple_train” include “ple.fit” (fitted “ple_train”), “mu.train” (training predictions), and “mu.test” (test predictions). “plot_ple” and “plot_dependence” can also be used with PRISM objects. For example,

summary(res0$mu_train)
#>       mu_0             mu_1           diff_1_0             pi_0       
#>  Min.   :0.5603   Min.   :0.3861   Min.   :-0.35736   Min.   :0.5112  
#>  1st Qu.:1.3811   1st Qu.:1.5032   1st Qu.: 0.08576   1st Qu.:0.5112  
#>  Median :1.6256   Median :1.7852   Median : 0.21017   Median :0.5112  
#>  Mean   :1.6362   Mean   :1.8394   Mean   : 0.20659   Mean   :0.5112  
#>  3rd Qu.:1.8839   3rd Qu.:2.1530   3rd Qu.: 0.32836   3rd Qu.:0.5112  
#>  Max.   :2.6528   Max.   :3.1353   Max.   : 0.85339   Max.   :0.5112  
#>       pi_1       
#>  Min.   :0.4888  
#>  1st Qu.:0.4888  
#>  Median :0.4888  
#>  Mean   :0.4888  
#>  3rd Qu.:0.4888  
#>  Max.   :0.4888
plot_ple(res0)

plot_dependence(res0, vars=c("X2"))
#> `geom_smooth()` using method = 'loess' and formula 'y ~ x'

Next, the subgroup model (lmtree), identifies 4-subgroups based on varying treatment effects. By plotting the subgroup model object (“submod.fit$mod”)“, we see that partitions are made through X1 (predictive) and X2 (predictive). At each node, parameter estimates for node (subgroup) specific OLS models, \(Y\sim \beta_0+\beta_1*A\). For example, patients in nodes 4 and 6 have estimated treatment effects of 0.47 and 0.06 respectively. Subgroup predictions for the train/test set can be found in the”out.train” and “out.test” data-sets.

plot(res0$submod.fit$mod, terminal_panel = NULL)

table(res0$out.train$Subgrps)
#> 
#>  10  11   3   5   6   9 
#> 168 107 149 110 167  99
table(res0$out.test$Subgrps)
#> < table of extent 0 >

Lastly, the “param.dat” object contain point-estimates, standard errors, lower/upper confidence intervals and p-values. This output feeds directly into previously shown default (“tree”) plot.

## Overall/subgroup specific parameter estimates/inference
res0$param.dat
#>    Subgrps   N  estimand         est         SE         LCL       UCL
#> 36      10 168 mu_1-mu_0  0.19150660 0.13143459 -0.06610046 0.4491137
#> 31      11 107 mu_1-mu_0  0.71409160 0.17614914  0.36884562 1.0593376
#> 32       3 149 mu_1-mu_0 -0.03437557 0.15390554 -0.33602488 0.2672737
#> 33       5 110 mu_1-mu_0  0.21599764 0.15869712 -0.09504300 0.5270383
#> 34       6 167 mu_1-mu_0 -0.14146807 0.13025227 -0.39675782 0.1138217
#> 35       9  99 mu_1-mu_0  0.63425265 0.18793785  0.26590124 1.0026041
#> 3     ovrl 800 mu_1-mu_0  0.20798067 0.06333631  0.08384378 0.3321176
#>            pval alpha  Prob(>0)
#> 36 1.451029e-01  0.05 0.9274485
#> 31 5.037003e-05  0.05 0.9999748
#> 32 8.232592e-01  0.05 0.4116296
#> 33 1.734921e-01  0.05 0.9132540
#> 34 2.774311e-01  0.05 0.1387155
#> 35 7.386936e-04  0.05 0.9996307
#> 3  1.024355e-03  0.05 0.9994878

The hyper-parameters for the individual steps of PRISM can also be easily modified. For example, “glmnet” by default selects covariates based on “lambda.min”, “ranger” requires nodes to contain at least 10% of the total observations, and “lmtree” requires nodes to contain at least 10% of the total observations. See below for a different set of hyper-parameters.

res_new_hyper = PRISM(Y=Y, A=A, X=X, filter.hyper = list(lambda="lambda.1se"),
                      ple.hyper = list(min.node.pct=0.05), 
                      submod.hyper = list(minsize=200, maxdepth=3), verbose=FALSE)
summary(res_new_hyper)

Example: Binary Outcome with Binary Treatment

Consider a binary outcome (ex: % overall response rate) with a binary treatment (study drug vs standard of care). The estimand of interest is the risk difference, \(\theta_0 = E(Y|A=1)-E(Y|A=0)\). Similar to the continous example, we simulate binomial data where roughly 30% of the patients receive no treatment-benefit for using \(A=1\) vs \(A=0\). Responders vs non-responders are defined by the continuous predictive covariates \(X_1\) and \(X_2\) for a total of four subgroups. Subgroup treatment effects are: \(\theta_{1} = 0\) (\(X_1 \leq 0, X_2 \leq 0\)), \(\theta_{2} = 0.11 (X_1 > 0, X_2 \leq 0)\), \(\theta_{3} = 0.21 (X_1 \leq 0, X2 > 0\)), \(\theta_{4} = 0.31 (X_1>0, X_2>0)\).

For binary outcomes (Y=0,1), the default settings are: filter=“glmnet”, ple=“ranger”, submod=“glmtree”” (GLM MOB with identity link), and param=“dr”.

dat_bin = generate_subgrp_data(family="binomial", seed = 5558)
Y = dat_bin$Y
X = dat_bin$X # 50 covariates, 46 are noise variables, X1 and X2 are truly predictive
A = dat_bin$A # binary treatment, 1:1 randomized 

res0 = PRISM(Y=Y, A=A, X=X)
#> Observed Data
#> Filtering: glmnet
#> Counterfactual Estimation: ranger (X-learner)
#> Subgroup Identification: glmtree
#> Treatment Effect Estimation: dr
summary(res0)
#> $call
#> PRISM(Y = Y, A = A, X = X)
#> 
#> $`PRISM Configuration`
#> [1] "[Filter] glmnet => [PLE] ranger => [Subgroups] glmtree => [Param] dr"
#> 
#> $`Variables that Pass Filter`
#>  [1] "X1"  "X2"  "X3"  "X5"  "X7"  "X9"  "X15" "X16" "X17" "X19" "X21" "X28"
#> [13] "X31" "X34" "X35" "X38" "X45"
#> 
#> $`Number of Identified Subgroups`
#> [1] 5
#> 
#> $`Variables that Define the Subgroups`
#> [1] "X1, X2, X5, X3"
#> 
#> $`Treatment Effect Estimates (observed)`
#>    Subgrps   N  estimand    est     SE     LCL    UCL         pval alpha
#> 35       4  86 mu_1-mu_0 0.0559 0.0553 -0.0524 0.1642 3.116956e-01  0.05
#> 31       5 199 mu_1-mu_0 0.1668 0.0511  0.0666 0.2670 1.101960e-03  0.05
#> 32       6 156 mu_1-mu_0 0.0565 0.0688 -0.0782 0.1913 4.108557e-01  0.05
#> 33       8 128 mu_1-mu_0 0.3478 0.0683  0.2139 0.4818 3.591681e-07  0.05
#> 34       9 231 mu_1-mu_0 0.1532 0.0542  0.0471 0.2594 4.675260e-03  0.05
#> 3     ovrl 800 mu_1-mu_0 0.1584 0.0274  0.1047 0.2122 7.616802e-09  0.05
#> 
#> attr(,"class")
#> [1] "summary.PRISM"

Example: Survival Outcome with Binary Treatment

Survival outcomes are also allowed in PRISM. The default settings use glmnet to filter (“glmnet”), ranger patient-level estimates (“ranger”; for survival, the output is the restricted mean survival time treatment difference), “lmtree” (log-rank score transformation on outcome Y, then fit MOB OLS) for subgroup identification, and subgroup-specific cox regression models). Another subgroup option is to use “ctree”“, which uses the conditional inference tree (ctree) algorithm to find subgroups; this looks for partitions irrespective of treatment assignment and thus corresponds to finding prognostic effects.

# Load TH.data (no treatment; generate treatment randomly to simulate null effect) ##
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(6345)
A = rbinom(n = dim(X)[1], size=1, prob=0.5)

# Default: glmnet ==> ranger (estimates patient-level RMST(1 vs 0) ==> mob_weib (MOB with Weibull) ==> cox (Cox regression)
res_weib = PRISM(Y=Y, A=A, X=X)
#> Observed Data
#> Filtering: glmnet
#> Counterfactual Estimation: ranger (T-learner)
#> Subgroup Identification: lmtree
#> Treatment Effect Estimation: cox
summary(res_weib)
#> $call
#> PRISM(Y = Y, A = A, X = X)
#> 
#> $`PRISM Configuration`
#> [1] "[Filter] glmnet => [PLE] ranger => [Subgroups] lmtree => [Param] cox"
#> 
#> $`Variables that Pass Filter`
#> [1] "horTh"    "menostat" "tsize"    "tgrade"   "pnodes"   "progrec" 
#> 
#> $`Number of Identified Subgroups`
#> [1] 4
#> 
#> $`Variables that Define the Subgroups`
#> [1] "pnodes, progrec"
#> 
#> $`Treatment Effect Estimates (observed)`
#>   Subgrps   N        estimand     est     SE     LCL    UCL      pval alpha
#> 2       3 254 logHR_1-logHR_0 -0.0838 0.2071 -0.4898 0.3222 0.6857103  0.05
#> 3       4 122 logHR_1-logHR_0  0.5185 0.4087 -0.2825 1.3195 0.2045043  0.05
#> 4       6 144 logHR_1-logHR_0 -0.1730 0.1979 -0.5608 0.2149 0.3821403  0.05
#> 5       7 166 logHR_1-logHR_0 -0.1107 0.2281 -0.5578 0.3364 0.6275185  0.05
#> 1    ovrl 686 logHR_1-logHR_0 -0.0019 0.1262 -0.2498 0.2460 0.9879133  0.05
#> 
#> attr(,"class")
#> [1] "summary.PRISM"
plot(res_weib)

Resampling

Resampling methods are also a feature in PRISM and submod_train. Bootstrap (resample=“Bootstrap”), permutation (resample=“Permutation”), and cross-validation (resample=“CV”) based-resampling are included. Resampling can be used for obtaining de-biased or “honest” subgroup estimates, inference, and/or probability statements. For each resampling method, the sampling mechanism can be stratified by the discovered subgroups and/or treatment (default: stratify=“trt”). To summarize:

Bootstrap Resampling

Given observed data \((Y, A, X)\), fit \(PRISM(Y,A,X)\). Based on the identified \(k=1,..,K\) subgroups, output subgroup assignment for each patient. For the overall population \(k=0\) and each subgroup (\(k=0,...,K\)), store the associated parameter estimates (\(\hat{\theta}_{k}\)). For \(r=1,..,R\) resamples with replacement (\((Y_r, A_r, X_r)\)), fit \(PRISM(Y_r, A_r, X_r)\) and obtain new subgroup assignments \(k_r=1,..,K_r\) with associated parameter estimates \(\hat{\theta}_{k_r}\). For subjects \(i\) within subgroup \(k_r\), note that everyone has the same assumed point-estimate, i.e., \(\hat{\theta}_{k_r}=\hat{\theta}_{ir}\). For resample \(r\), the bootstrap estimates based for the original identified subgroups (\(k=0,...,K\)) are calculated respectively as: \[ \hat{\theta}_{rk} = \sum_{k_r} w_{k_r} \hat{\theta}_{k_r}\] where \(w_{k_r} = \frac{n(k \cap k_r)}{\sum_{k_r} n(k \cap k_r)}\), or the # of subjects that are in both the original subgroup \(k\) and the resampled subgroup \(k_r\) divided by the total #. The bootstrap mean estimate and standard error, as well as probability statements, are calculated as: \[ \tilde{\theta}_{k} = \frac{1}{R} \sum_r \hat{\theta}_{rk} \] \[ SE(\hat{\theta}_{k})_B = \sqrt{ \frac{1}{R} \sum_r (\hat{\theta}_{rk}-\tilde{\theta}_{k})^2 } \] \[ \hat{P}(\hat{\theta}_{k}>c) = \frac{1}{R} \sum_r I(\hat{\theta}_{rk}>c) \] If resample=“Bootstrap”, the default is to use the bootstrap smoothed estimates, \(\tilde{\theta}_{k}\), along with percentile-based CIs (i.e. 2.5,97.5 quantiles of bootstrap distribution). Bootstrap bias is also calculated, which can be used to assess the bias of the initial subgroup estimates.

Returning to the survival example, see below for an example of PRISM with 50 bootstrap resamples (for increased accuracy, use >1000). The bootstrap mean estimates, bootstrap standard errors, bootstrap bias, and percentile CI correspond to “est_resamp”, “SE_resamp”, “bias.boot”, and “LCL.pct”/“UCL.pct” respectively. A density plot of the bootstrap distributions can be viewed through the plot(…,type=“resample”) option.

res_boot = PRISM(Y=Y, A=A, X=X, resample = "Bootstrap", R=50, ple="None")
summary(res_boot)
# Plot of distributions #
plot(res_boot, type="resample", estimand = "HR(A=1 vs A=0)")+geom_vline(xintercept = 1)

Cross-Validation

Cross-validation resampling (resample=“CV”) also follows the same general procedure as bootstrap resampling. Given observed data \((Y, A, X)\), fit \(PRISM(Y,A,X)\). Based on the identified \(k=1,..,K\) subgroups, output subgroup assignment for each patient. Next, split the data into \(R\) folds (ex: 5). For fold \(r\) with sample size \(n_r\), fit PRISM on \((Y[-r],A[-r], X[-r])\) and predict the patient-level estimates and subgroup assignments (\(k_r=1,...,K_r\)) for patients in fold \(r\). The data in fold \(r\) is then used to obtain parameter estimates for each subgroup, \(\hat{\theta}_{k_r}\). For fold \(r\), estimates and SEs for the original subgroups (\(k=1,...,K\)) are then obtained using the same formula as with bootstrap resampling, again, denoted as (\(\hat{\theta}_{rk}\), \(SE(\hat{\theta}_{rk})\)). This is repeated for each fold and “CV” estimates and SEs are calculated for each identified subgroup. Let \(w_r = n_r / \sum_r n_r\), then:

\[ \hat{\theta}_{k,CV} = \sum w_r * \hat{\theta}_{rk} \] \[ SE(\hat{\theta}_k)_{CV} = \sqrt{ \sum_{r} w_{r}^2 SE(\hat{\theta}_{rk})^2 }\] CV-based confidence intervals can then be formed, \(\left[\hat{\theta}_{k,CV} \pm 1.96*SE(\hat{\theta}_k)_{CV} \right]\).

Conclusion

Overall, the StratifiedMedicine package contains a variety of tools (“filter_train”, “ple_train”, “submod_train”, and “PRISM”) and plotting features (“plot_dependence”, “plot_importance”, “plot_ple”, “plot_tree”) for the exploration of heterogeneous treatment effects. Each tool is also customizable, allowing the user to plug-in specific models (for example, xgboost with built-in hyper-parameter tuning). More details on creating user-specific models can be found in the “User_Specific_Models_PRISM” vignette User_Specific_Models. The StratifiedMedicine R package will be continually updated and improved.

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.