Learn R Programming

DevTreatRules (version 1.1.0)

PredictRule: Get the treatment rule implied by BuildRule()

Description

Map the object returned by BuildRule() to the treatment rule corresponding to a particular dataset

Usage

PredictRule(
  BuildRule.object,
  new.X,
  desirable.outcome = NULL,
  clinical.threshold = 0,
  return.predicted.response = FALSE
)

Arguments

BuildRule.object

The object returned by the BuildRule() function.

new.X

A data frame representing the dataset for which the treatment rule is desired.

desirable.outcome

A logical equal to TRUE if higher values of the outcome are considered desirable (e.g. for a binary outcome, 1 is more desirable than 0). The OWL.framework and OWL approaches to treatment rule estimation require a desirable outcome.

clinical.threshold

A numeric equal a positive number above which the predicted outcome under treatment must be superior to the predicted outcome under control for treatment to be recommended. Only used when BuildRuleObject was specified and derived from the split-regression or direct-interactions approach. Defaults to 0.

return.predicted.response

logical indicating whether the predicted response variable (for split.regression, OWL.framework, and OWL approaches) or score function (for direct.interactions) should be returned in addition to its mapping to a binary treatment recommendation. Default is FALSE.

Value

  • If return.predicted.response=FALSE (the default), then the single object returned is a numeric vector of 0s and 1s, with length equal to the number of rows in new.X, where a 0 indicates treatment is not recommended and a 1 indicates treatment is recommended for the corresponding observation in new.X.

  • If return.predicted.response=TRUE, then the object returned is a list with some combination of the following components (depending on which prediction approach underlies the BuildRule.object).

    • recommended.treatment: A numeric vector of 0s and 1s, with length equal to the number of rows in new.X, where a 0 indicates treatment is not recommended and a 1 indicates treatment is recommended for the corresponding observation in new.X.

    • predicted.outcome: A numeric vector showing the predicted values of the score function mapped to recommended.treatment. Only returned if return.predicted.response=TRUE and the approach underlying BuildRule.object. was `direct.interactions'.

    • predicted.outcome.under.control: A numeric vector showing the predicted values of the outcome under no treatment which, along with predicted.outcome.under.treatment, corresponds to recommended.treatment. Only returned if return.predicted.response=TRUE and the approach underlying BuildRule.object. was `split.regression'.

    • predicted.outcome.under.treatment: A numeric vector showing the predicted values of the outcome under treatment which, along with predicted.outcome.under.control, corresponds to recommended.treatment. Only returned if return.predicted.response=TRUE and the approach underlying BuildRule.object. was `split.regression'.

    • predicted.treatment.prob: A numeric vector showing the predicted treatment probability that corresponds to recommended.treatment. Only returned if return.predicted.response=TRUE and the approach underlying BuildRule.object. was `OWL.framework'.

Examples

Run this code
# NOT RUN {
set.seed(123)
example.split <- SplitData(data=obsStudyGeneExpressions,
                                     n.sets=3, split.proportions=c(0.5, 0.25, 0.25))
development.data <- example.split[example.split$partition == "development",]
validation.data <- example.split[example.split$partition == "validation",]
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")
one.prediction <- PredictRule(BuildRule.object=one.rule,
                                        new.X=validation.data[, c("age", paste0("gene_", 1:10))],
                                        desirable.outcome=TRUE,
                                        clinical.threshold=0)
table(one.prediction)
# }

Run the code above in your browser using DataLab