| dwscore | R Documentation |
Scores predicted risks at one or more horizons with a decision-weighted
proper score: the loss of the rule "act if predicted risk exceeds c",
averaged over thresholds c with a weight w(c). The weight states which
risk thresholds matter. Every such score equals a weighted area under the
net benefit curve, with weight (1 - c) w(c), so a threshold range
restricts model comparison to the decisions clinicians actually make.
dwscore(
object,
y,
times = NULL,
weight = c("range", "survacc", "brier", "log", "beta"),
thresholds = c(0.05, 0.2),
shape = c(2, 18)
)
object |
A numeric matrix of survival probabilities (rows = subjects,
columns = times), for example from |
y |
A |
times |
Evaluation times. |
weight |
Threshold weight:
|
thresholds |
Length-2 numeric range |
shape |
Length-2 numeric Beta parameters for |
With risk r = 1 - S(t \mid X) and event status D = I(T \le t),
the loss is L_w(r, 0) = \int_0^r w(c)\, c\, dc for a subject event
free at t and L_w(r, 1) = \int_r^1 w(c) (1 - c)\, dc for a subject
with an event by t. Right censoring is handled by inverse probability of
censoring weights from the Kaplan-Meier estimate of the censoring
distribution: subjects event free at t are weighted by 1 / G(t),
subjects with an observed event at U \le t by 1 / G(U-), and
subjects censored before t get weight zero. This assumes censoring is
independent of the covariates. Range and Beta weights integrate to one, so
those losses lie on the scale of an average regret per decision.
In evaluate(), compare() and tune(), use the metric ids "survacc"
(SurvAcc, higher is better) and "range:<lower>-<upper>", for example
"range:0.05-0.20" (loss, lower is better). Both need a single time.
A data frame with columns time, weight and loss (lower is
better for every weight).
m <- fit(Surv(time, status) ~ age + karno, veteran[1:100, ], "coxph")
S <- predict(m, veteran[-(1:100), ], times = c(90, 180))
y <- Surv(veteran$time[-(1:100)], veteran$status[-(1:100)])
dwscore(S, y)
dwscore(S, y, weight = "brier")
dwscore(S, y, weight = "range", thresholds = c(0.10, 0.30))
# the same scores inside the verbs (single time)
S180 <- predict(m, veteran[-(1:100), ], times = 180)
evaluate(S180, y = y, metrics = c("brier", "survacc", "range:0.05-0.20"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.