dca: Decision curve analysis: net benefit.

View source: R/dca.R

dcaR Documentation

Decision curve analysis: net benefit.

Description

Computes net benefit across a range of risk thresholds for a binary classifier's predicted probabilities, alongside the "treat all" and "treat none" reference strategies (Vickers and Elkin, 2006).

Usage

dca(truth, prob, positive = NULL, thresholds = seq(0.01, 0.99, by = 0.01))

Arguments

truth

Factor (or coercible to factor) of true class labels.

prob

Predicted probability of the positive class, or a probability matrix/data frame with one column per class level.

positive

Optional positive class level. Defaults to the second factor level.

thresholds

Numeric vector of risk thresholds in (0, 1).

Value

A data frame with threshold, model, treat_all, and treat_none net benefit columns.

Examples

set.seed(1)
truth <- factor(rbinom(200, 1, 0.3))
prob <- pmin(pmax(rnorm(200, mean = ifelse(truth == 1, 0.6, 0.3), sd = 0.15), 0), 1)
dca(truth, prob)

funcml documentation built on Aug. 22, 2026, 5:08 p.m.