The package rmda (risk model decision analysis) provides tools to evaluate the value of using a risk prediction instrument to decide treatment or intervention (versus no treatment or intervention). Given one or more risk prediction instruments (risk models) that estimate the probability of a binary outcome, rmda provides functions to estimate and display decision curves and other figures that help assess the population impact of using a risk model for clinical decision making. Here, “population” refers to the relevant patient population.

Decision curves display estimates of the (standardized) net benefit over a range of probability thresholds used to categorize observations as ‘high risk.’ The curves help evaluate a treatment policy that recommends treatment for patients who are estimated to be ‘high risk’ by comparing the population impact of a risk-based policy to “treat all” and “treat none” intervention policies. Curves can be estimated using data from a prospective cohort. In addition, rmda can estimate decision curves using data from a case-control study if an estimate of the population outcome prevalence is available. Version 1.5 and higher of the package provides an alternative framing of the decision problem for situations where treatment is the standard-of-care and a risk model might be used to recommend that low-risk patients (i.e., patients below some risk threshold) opt-out of treatment.

Confidence intervals calculated using the bootstrap can be computed and displayed. A wrapper function to calculate cross-validated curves using k-fold cross-validation is also provided.

Key functions are:

  • decision_curve: Estimate (standardized) net benefit curves with bootstrap confidence intervals.

  • plot_decision_curve: Plot a decision curve or multiple curves.

  • plot_clinical_impact and plot_roc_components: Alternative plots for the output of decision_curve showing measures of clinical impact or the components of the ROC curve (true/false positive rates) across a range of risk thresholds. See help files or tutorial for more info.

  • cv_decision_curve: Calculate k-fold cross-validated estimates of a decision curve and its components.

Install the package

The easiest way to get the package is directly from CRAN:

install.packages("rmda")

You may also download the current version of the package here:

https://github.com/mdbrown/rmda/releases

navigate to the source package and use

install.packages("../rmda_1.5.tar.gz", repos = NULL, type = "source")

or install the package directly from github using devtools.

## install.packages("devtools")
library(devtools)
install_github("mdbrown/rmda")

Getting started

Load the package and the provided simulated data set.

library(rmda)

#load simulated data 
data(dcaData)

head(dcaData)
## # A tibble: 6 x 6
##     Age Female Smokes   Marker1     Marker2 Cancer
##   <int>  <dbl>  <lgl>     <dbl>       <dbl>  <int>
## 1    33      1  FALSE 0.2453110  1.02108482      0
## 2    29      1  FALSE 0.9429660 -0.25576212      0
## 3    28      1  FALSE 0.7735939  0.33184401      0
## 4    27      0  FALSE 0.4063595 -0.00568574      0
## 5    23      1  FALSE 0.5075153  0.20753273      0
## 6    35      1  FALSE 0.1856706  1.41251020      0

First we use the function decision_curve to create a decision curve object for a logistic model to predict cancer status using age, gender and smoking status. We then plot it using plot_decision_curve.

set.seed(123)
#first use rmda with the default settings (set bootstraps = 50 here to reduce computation time). 
baseline.model <- decision_curve(Cancer~Age + Female + Smokes, #fitting a logistic model
                                data = dcaData, 
                                study.design = "cohort", 
                                policy = "opt-in",  #default 
                                bootstraps = 50)

#plot the curve
plot_decision_curve(baseline.model,  curve.names = "baseline model")