Here, we illustrate the DevTreatRules package by building and evaluating treatment rules based on the example dataset included with the package.

library(DevTreatRules)
head(obsStudyGeneExpressions)
##   no_relapse intervention prognosis clinic age gene_1 gene_2 gene_3 gene_4
## 1          1            0      Good      1  46  0.531  0.071 0.1294  0.427
## 2          0            1      Poor      3  51  0.744  0.711 1.3532  1.939
## 3          1            0      Poor      3  62  1.146  0.498 1.4707  1.456
## 4          1            0      Good      5  51  1.816  1.758 0.2226  0.688
## 5          1            1      Good      4  52  0.403  0.636 0.0933  0.288
## 6          1            1      Poor      6  51  1.797  0.642 0.2618  0.277
##   gene_5 gene_6 gene_7 gene_8 gene_9 gene_10
## 1  0.421  0.402  0.831 0.0136  1.186  1.8831
## 2  0.230  0.228  0.282 1.3413  1.106  0.6606
## 3  0.291  0.543  0.915 0.4839  1.193  0.6233
## 4  0.620  1.571  1.606 1.9986  0.785  1.7684
## 5  0.300  1.276  0.642 1.9003  0.521  0.0126
## 6  1.053  0.939  1.736 0.2348  1.480  1.3908

Split the Dataset

First, we split obsStudyGeneExpressions into independent development/validation/evaluation partitions by calling the SplitData() function

set.seed(123)
example.split <- SplitData(data=obsStudyGeneExpressions, n.sets=3, split.proportions=c(0.5, 0.25, 0.25))
table(example.split$partition)
## 
## development  validation  evaluation 
##        2500        1250        1250

and then forming independent datasets based on the partition variable created above.

library(dplyr)
development.data <- example.split %>% filter(partition == "development")
validation.data <-  example.split %>% filter(partition == "validation")
evaluation.data <-  example.split %>% filter(partition == "evaluation")

Specify Variable Roles

Suppose we believe the variables prognosis, clinic, and age may have influenced treatment assignment. We would codify this knowledge into DevTreatRules by specifying the argument

names.influencing.treatment=c("prognosis", "clinic", "age")

in functions we will call later in this vignette. Further suppose that we don't expect prognosis and clinic to be measured on the same scale in independent clinical settings where we would like to apply our estimated rule (so they are not sensible rule inputs). However, we do expect the gene expression measurements in gene_1, …, gene_10 to potentially influence treatment response and also to be reliably measured in future settings (so they are sensible rule inputs). We specify this knowledge in DevTreatRules with the argument

names.influencing.rule=c("age", paste0("gene_", 1:10))

On the Development Dataset, Build the Treatment Rule

Although we could directly estimate a single treatment rule on the development dataset with BuildRule() using, for example,

one.rule <- BuildRule(development.data=development.data,
                      study.design="observational",
                      prediction.approach="split.regression",
                      name.outcome="no_relapse",
                      type.outcome="binary",
                      desirable.outcome=TRUE,
                      name.treatment="intervention",
                      names.influencing.treatment=c("prognosis", "clinic", "age"),
                      names.influencing.rule=c("age", paste0("gene_", 1:10)),
                      propensity.method="logistic.regression",
                      rule.method="glm.regression")

this has limited utility because it required us to specify just one value for the prediction.approach argument (even if we don't have a priori knowledge about which of split-regression, OWL framework, and direct-interactions approaches will perform best) and to specify just one regression method for the propensity.score and rule.method arguments (even if we are not sure whether standard logistic regression or lasso/ridge logistic regression will yield a better rule).

Instead, it would be more useful to perform model selection to estimate rules for different combinations of split-regression/OWL framework/direct-interactions and standard/lasso/ridge logistic regression (e.g. by looping over calls to BuildRule()). The model-selection process is automated in CompareRulesOnValidation().

On the Validation Dataset, Perform Model Selection

Here we will perform model selection by calling CompareRulesOnValidation() with the arguments

vec.approaches=c("OWL", "split.regression", "OWL.framework", "direct.interactions")
vec.rule.methods=c("glm.regression", "lasso", "ridge")

which are actually the default values of CompareRulesOnValidation(), and with

vec.propensity.methods="logistic.regression"

Now we perform model selection by calling CompareRulesOnValidation()

set.seed(123)
model.selection <- CompareRulesOnValidation(development.data=development.data,
                validation.data=validation.data,
                study.design.development="observational",
                vec.approaches=c("split.regression", "OWL.framework", "direct.interactions"),
                vec.rule.methods=c("glm.regression", "lasso", "ridge"),
                vec.propensity.methods="logistic.regression",
                name.outcome.development="no_relapse",
                type.outcome.development="binary",
                name.treatment.development="intervention",
                names.influencing.treatment.development=c("prognosis", "clinic", "age"),
                names.influencing.rule.development=c("age", paste0("gene_", 1:10)),
                desirable.outcome.development=TRUE)

We can compare these estimates for the nine treatment rules (three approaches, three combinations of rule/propensity methods) to decide which rules to bring forward to the evaluation dataset. For context, the estimates for the naive “treat.all” and “treat.none” strategies are always provided by CompareRulesOnValidation().

First, for rules estimated with the split-regression approach, we obtain the estimates \footnotesize

model.selection$list.summaries[["split.regression"]] 
##                                                    Positives Negatives
## propensity_logistic.regression_rule_glm.regression       787       463
## propensity_logistic.regression_rule_lasso               1089       161
## propensity_logistic.regression_rule_ridge               1250         0
## treat.all                                               1250         0
## treat.none                                                 0      1250
##                                                    ATE in Positives
## propensity_logistic.regression_rule_glm.regression           0.1112
## propensity_logistic.regression_rule_lasso                    0.0600
## propensity_logistic.regression_rule_ridge                    0.0383
## treat.all                                                    0.0383
## treat.none                                                       NA
##                                                    ATE in Negatives
## propensity_logistic.regression_rule_glm.regression          -0.1053
## propensity_logistic.regression_rule_lasso                   -0.2576
## propensity_logistic.regression_rule_ridge                        NA
## treat.all                                                        NA
## treat.none                                                   0.0383
##                                                        ABR
## propensity_logistic.regression_rule_glm.regression  0.1090
## propensity_logistic.regression_rule_lasso           0.0855
## propensity_logistic.regression_rule_ridge           0.0383
## treat.all                                           0.0383
## treat.none                                         -0.0383

\normalsize Next, for the OWL framework we have \footnotesize

model.selection$list.summaries[["OWL.framework"]] 
##                                                    Positives Negatives
## propensity_logistic.regression_rule_glm.regression       783       467
## propensity_logistic.regression_rule_lasso               1245         5
## propensity_logistic.regression_rule_ridge               1250         0
## treat.all                                               1250         0
## treat.none                                                 0      1250
##                                                    ATE in Positives
## propensity_logistic.regression_rule_glm.regression           0.1030
## propensity_logistic.regression_rule_lasso                    0.0408
## propensity_logistic.regression_rule_ridge                    0.0383
## treat.all                                                    0.0383
## treat.none                                                       NA
##                                                    ATE in Negatives
## propensity_logistic.regression_rule_glm.regression          -0.0964
## propensity_logistic.regression_rule_lasso                   -0.5689
## propensity_logistic.regression_rule_ridge                        NA
## treat.all                                                        NA
## treat.none                                                   0.0383
##                                                        ABR
## propensity_logistic.regression_rule_glm.regression  0.1005
## propensity_logistic.regression_rule_lasso           0.0429
## propensity_logistic.regression_rule_ridge           0.0383
## treat.all                                           0.0383
## treat.none                                         -0.0383

\normalsize and, last, for the direct-interactions approach \footnotesize

model.selection$list.summaries[["direct.interactions"]] 
##                                                    Positives Negatives
## propensity_logistic.regression_rule_glm.regression       784       466
## propensity_logistic.regression_rule_lasso                852       398
## propensity_logistic.regression_rule_ridge               1250         0
## treat.all                                               1250         0
## treat.none                                                 0      1250
##                                                    ATE in Positives
## propensity_logistic.regression_rule_glm.regression           0.0973
## propensity_logistic.regression_rule_lasso                    0.1056
## propensity_logistic.regression_rule_ridge                    0.0383
## treat.all                                                    0.0383
## treat.none                                                       NA
##                                                    ATE in Negatives
## propensity_logistic.regression_rule_glm.regression          -0.0866
## propensity_logistic.regression_rule_lasso                   -0.1833
## propensity_logistic.regression_rule_ridge                        NA
## treat.all                                                        NA
## treat.none                                                   0.0383
##                                                        ABR
## propensity_logistic.regression_rule_glm.regression  0.0933
## propensity_logistic.regression_rule_lasso           0.1304
## propensity_logistic.regression_rule_ridge           0.0383
## treat.all                                           0.0383
## treat.none                                         -0.0383

\normalsize Based on the above estimates in the validation set, we decide to select three rules to bring forward to the evaluation set: (1) split-regression with logistic/logistic as the propensity/rule methods,

model.selection$list.summaries$split.regression["propensity_logistic.regression_rule_glm.regression", ]
##        Positives        Negatives ATE in Positives ATE in Negatives 
##          787.000          463.000            0.111           -0.105 
##              ABR 
##            0.109

along with (2) OWL framework with logistic/logistic as the propensity/rule methods

model.selection$list.summaries$OWL.framework["propensity_logistic.regression_rule_glm.regression", ]
##        Positives        Negatives ATE in Positives ATE in Negatives 
##         783.0000         467.0000           0.1030          -0.0964 
##              ABR 
##           0.1005

and (3) direct-interactions with logistic/lasso as the propensity/rule methods.

model.selection$list.summaries$direct.interactions["propensity_logistic.regression_rule_lasso", ]
##        Positives        Negatives ATE in Positives ATE in Negatives 
##          852.000          398.000            0.106           -0.183 
##              ABR 
##            0.130

We can also see the underlying coefficient estimates for these rules with

rule.split <- model.selection$list.rules$split.regression[["propensity_logistic.regression_rule_glm.regression"]]
coef(rule.split$rule.object.control)
## (Intercept)         age      gene_1      gene_2      gene_3      gene_4 
##     0.38852     0.01230    -0.41212     0.04748    -0.09793    -0.12845 
##      gene_5      gene_6      gene_7      gene_8      gene_9     gene_10 
##    -0.04439    -0.13591    -0.24607     0.09746    -0.00498     0.05026
coef(rule.split$rule.object.treat)
## (Intercept)         age      gene_1      gene_2      gene_3      gene_4 
##    -0.20436    -0.00212     0.29588    -0.07918    -0.03679     0.01469 
##      gene_5      gene_6      gene_7      gene_8      gene_9     gene_10 
##     0.30874    -0.00162     0.02854    -0.04625     0.08332     0.08870
rule.OWL <- model.selection$list.rules$OWL.framework[["propensity_logistic.regression_rule_glm.regression"]]
coef(rule.OWL$rule.object)
## (Intercept)         age      gene_1      gene_2      gene_3      gene_4 
##    -0.21180    -0.00787     0.32037    -0.05444     0.02265     0.07921 
##      gene_5      gene_6      gene_7      gene_8      gene_9     gene_10 
##     0.15891     0.07133     0.11260    -0.07641     0.05433     0.01959
rule.DI <- model.selection$list.rules$direct.interactions[["propensity_logistic.regression_rule_lasso"]]
coef(rule.DI$rule.object)
## 13 x 1 sparse Matrix of class "dgCMatrix"
##                         1
## (Intercept)        .     
## treatment.neg.pos -0.0413
## age                .     
## gene_1             0.1277
## gene_2             .     
## gene_3             .     
## gene_4             .     
## gene_5             .     
## gene_6             .     
## gene_7             .     
## gene_8             .     
## gene_9             .     
## gene_10            .

On the Evaluation Dataset, Evaluate the Selected Rules

Since the validation dataset informed our model selection (i.e. we selected these particular two rules because they appeared best on the validation set), the estimates from the validation set itself are not trustworthy estimates of performance in independent settings. To obtain a trustworthy estimate of the rules' performance in independent samples drawn from the same population, we turn to the EvaluateRule() function applied to the independent evaluation dataset.

First, we obtain the estimated performance of the rule using split-regression with

set.seed(123)
split.eval <- EvaluateRule(evaluation.data=evaluation.data,
                           BuildRule.object=rule.split,
                           study.design="observational",
                           name.outcome="no_relapse",
                           type.outcome="binary",
                           desirable.outcome=TRUE,
                           name.treatment="intervention",
                           names.influencing.treatment=c("prognosis", "clinic", "age"),
                           names.influencing.rule=c("age", paste0("gene_", 1:10)),
                           propensity.method="logistic.regression",
                           bootstrap.CI=FALSE)
split.eval$summaries
##                n.positives ATE.positives n.negatives ATE.negatives     ABR
## estimated.rule         772        0.0557         478       -0.1800  0.1032
## treat.all             1250       -0.0256           0            NA -0.0256
## treat.none               0            NA        1250       -0.0256  0.0256

And last, the rule from OWL framework yields the following estimates

set.seed(123)
OWL.eval <- EvaluateRule(evaluation.data=evaluation.data,
                              BuildRule.object=rule.OWL,
                              study.design="observational",
                              name.outcome="no_relapse",
                              type.outcome="binary",
                              desirable.outcome=TRUE,
                              name.treatment="intervention",
                              names.influencing.treatment=c("prognosis", "clinic", "age"),
                              names.influencing.rule=c("age", paste0("gene_", 1:10)),
                              propensity.method="logistic.regression",
                              bootstrap.CI=FALSE)
OWL.eval$summaries
##                n.positives ATE.positives n.negatives ATE.negatives     ABR
## estimated.rule         777        0.0521         473       -0.1756  0.0988
## treat.all             1250       -0.0256           0            NA -0.0256
## treat.none               0            NA        1250       -0.0256  0.0256

And last, the rule from OWL framework yields the following estimates

set.seed(123)
DI.eval <- EvaluateRule(evaluation.data=evaluation.data,
                              BuildRule.object=rule.DI,
                              study.design="observational",
                              name.outcome="no_relapse",
                              type.outcome="binary",
                              desirable.outcome=TRUE,
                              name.treatment="intervention",
                              names.influencing.treatment=c("prognosis", "clinic", "age"),
                              names.influencing.rule=c("age", paste0("gene_", 1:10)),
                              propensity.method="logistic.regression",
                              bootstrap.CI=FALSE)
DI.eval$summaries
##                n.positives ATE.positives n.negatives ATE.negatives     ABR
## estimated.rule         820        0.0326         430       -0.1563  0.0752
## treat.all             1250       -0.0256           0            NA -0.0256
## treat.none               0            NA        1250       -0.0256  0.0256

We could have also obtained bootstrap-based CIs for the ATE/ABR estimates (in both the validation and evaluation datasets) by specifying the following arguments to BuildRulesOnValidation and EvaluateRule()

bootstrap.CI=TRUE
booststrap.CI.replications=1000 # or any other number of replications

but we chose not to compute CIs in this example to minimize run-time.

References