Tutorials › Joint Modeling of Longitudinal and Time-to-Event Data › Threshold-Based Classification From Predicted Risk

Calibration and Prediction Validation · Tutorial 589 of 697

Threshold-Based Classification From Predicted Risk

You will learn to define threshold-based classification at a fixed horizon and estimate its performance using inverse-probability-of-censoring weights when outcomes are incompletely observed.

Advanced 11 min read

What You'll Learn

  • Define predicted-risk classifications using a prespecified risk threshold and prediction horizon.
  • Distinguish sensitivity, specificity, positive predictive value, negative predictive value, and event detection.
  • Explain why censoring before the horizon leaves some binary outcomes unknown.
  • Calculate inverse-probability-of-censoring weighted performance measures.
  • Check the assumptions and diagnostics needed for weighted estimates to be useful.
  • Compare threshold-based measures with discrimination and decision-analytic summaries.

From Predicted Risk to a Classification

A predicted risk is a number; a threshold turns it into an action-oriented label. For example, a prediction rule might label a person “positive” when their predicted probability of an event within the next year is at least 20%. That classification makes it possible to summarize how well the rule detects events and how often it flags people who remain event-free. Such summaries are useful only when the event definition, horizon, threshold, and handling of censoring are all made explicit.

Consider a validation cohort assessed at a prediction time \(t\). Let \(h\) be the prediction horizon, and include people who are event-free and under observation at \(t\). A joint model supplies each person’s predicted risk using information available at \(t\), including the longitudinal history observed up to that time. Let \(T_i\) be the time from \(t\) to the event for person \(i\), and let \(\hat r_i(t,h)\) be their predicted probability of experiencing the event by \(t+h\), conditional on being event-free at \(t\) and on the information available then.

Definition: For a prespecified threshold \(q\), classify person \(i\) as predicted positive if \(\hat r_i(t,h)\ge q\), and predicted negative otherwise. Define the horizon outcome \(Y_i=1\) if the event occurs by \(t+h\), and \(Y_i=0\) if the person remains event-free through \(t+h\). Sensitivity is the proportion of people with \(Y_i=1\) classified positive; specificity is the proportion with \(Y_i=0\) classified negative. Positive predictive value (PPV) is the proportion of predicted positives who have \(Y_i=1\); negative predictive value (NPV) is the proportion of predicted negatives who have \(Y_i=0\).

These are horizon-specific, threshold-specific quantities. Sensitivity describes event detection among people who experience the event by the horizon; it is not the proportion of all positive classifications that are events. That latter proportion is PPV. “Event detection” is sometimes used informally for sensitivity, so a report should state the exact denominator. The proportion of the cohort classified positive is another quantity, the positive classification rate, and is not itself a measure of accuracy.

Complete Outcomes: The Basic Calculation

If every person’s event status at the horizon is known, the measures come from a two-by-two table. True positives (TP) are predicted positives with an event by the horizon; false negatives (FN) are predicted negatives with an event. False positives (FP) are predicted positives without an event by the horizon; true negatives (TN) are predicted negatives without an event.

$$ \text{Sensitivity}=\frac{TP}{TP+FN},\qquad \text{Specificity}=\frac{TN}{TN+FP}, $$
$$ \text{PPV}=\frac{TP}{TP+FP},\qquad \text{NPV}=\frac{TN}{TN+FN}. $$

Sensitivity and specificity condition on the observed horizon outcome. PPV and NPV condition on the classification. In particular, PPV and NPV depend on how common the event is in the population being evaluated, as well as on the threshold and the model’s performance.

Worked Example: Complete Follow-Up at a Fixed Horizon

Hypothetical data. A validation cohort has 50 people, all followed long enough to determine whether the event occurred within 12 months. At a prespecified threshold \(q=0.20\), 18 are classified positive. Of these, 12 experience the event and 6 do not. Among the 32 classified negative, 8 experience the event and 24 do not. The classification rule uses only information available at the prediction time, and the 12-month outcome is observed for everyone, so censoring adjustment is not needed.

There are \(TP=12\), \(FP=6\), \(FN=8\), and \(TN=24\). Thus sensitivity is \(12/(12+8)=0.600\): the rule flags 60.0% of people who experience the event within 12 months. Specificity is \(24/(24+6)=0.800\): it classifies 80.0% of those who remain event-free through 12 months as negative.

PPV is \(12/(12+6)=0.667\), so 66.7% of those classified positive experience the event within 12 months. NPV is \(24/(24+8)=0.750\), so 75.0% of those classified negative remain event-free through 12 months. The positive classification rate is \(18/50=0.360\). It is not sensitivity: its denominator is everyone in the cohort, rather than only those who experience the event.

Why Censoring Changes the Calculation

In time-to-event validation, some people are lost to follow-up or reach the end of data collection before \(t+h\). If a person has not had the event when follow-up ends at month 7, their 12-month outcome is unknown; they cannot simply be counted as event-free. Excluding everyone censored before the horizon can also distort performance if those people differ systematically from those with complete follow-up.

Inverse-probability-of-censoring weighting (IPCW) addresses this by giving more weight to people whose observed follow-up represents others with similar measured censoring patterns. Let \(C_i\) be the time from \(t\) to censoring, and let \(Z_i\) denote variables used in an appropriate censoring model. Define \(G_i(s)=P(C_i\ge s\mid Z_i)\), the probability of remaining uncensored through time \(s\), conditional on those variables. Write \(\hat G_i(s)\) for its estimate. For an observed event at time \(T_i\), use the probability of remaining uncensored just before that event, \(\hat G_i(T_i-)\); for an observed event-free outcome at the horizon, use \(\hat G_i(h)\).

Assumptions for IPCW: Censoring must be conditionally independent of the event time, given the variables in the censoring model; the censoring probabilities must be correctly estimated well enough for the intended use; and there must be a positive probability of remaining uncensored through the relevant times in the covariate patterns being evaluated. Risk predictions and their predictor information must use only information available at the prediction time. The censoring model may be estimated using appropriate observed follow-up and censoring data collected after that time, provided it is suitable for the validation procedure and does not leak future information into the risk predictions.

Let \(D_i\) indicate an event observed before censoring and by \(h\). A person censored before \(h\) without a prior event has an unknown binary outcome and contributes to neither observed event cases nor observed event-free controls. Define the IPCW contribution \(W_i\) as \(1/\hat G_i(T_i-)\) for an observed event by \(h\), \(1/\hat G_i(h)\) for a person observed event-free through \(h\), and zero for someone censored before \(h\) without a prior event. If \(A_i=I\{\hat r_i(t,h)\ge q\}\), the weighted totals are:

$$ TP_w=\sum_i W_i A_iD_i,\qquad FN_w=\sum_i W_i(1-A_i)D_i, $$
$$ FP_w=\sum_i W_i A_i(1-D_i),\qquad TN_w=\sum_i W_i(1-A_i)(1-D_i). $$

The weighted sensitivity, specificity, PPV, and NPV use the same ratios as in the complete-outcome case, replacing the four counts with their weighted versions. These are estimates: the weighted totals need not be integers, and their sum need not equal the number of people in the cohort.

Why the Weights Work

The key idea is to compensate for the chance that an outcome would be observed. For a person whose event occurs at time \(s\), the event is observed if censoring has not occurred by \(s\). Conditional on the censoring-model variables, this observation probability is \(G_i(s-)\). If censoring is conditionally independent of the event time, weighting an observed event by \(1/G_i(s-)\) cancels that observation probability. Similarly, an event-free status at \(h\) is observed only if the person remains uncensored through \(h\), with probability \(G_i(h)\).

$$ E\left[\frac{I(C_i\ge T_i)}{G_i(T_i-)}\ \middle|\ T_i,Z_i\right]=1 \quad\text{when }T_i\le h, $$

For event-free people at the horizon, the corresponding identity is \(E[I(C_i\ge h)/G_i(h)\mid T_i>h,Z_i]=1\). Thus, under the stated assumptions, the weighted event and event-free totals estimate the totals that would have been available with complete follow-up. Dividing the appropriate weighted totals estimates the conditional proportions of interest. The argument fails if censoring depends on unmeasured event-related information after conditioning, or if some relevant group has essentially no chance of remaining under observation.

Worked Example: IPCW With Censoring Before 12 Months

Hypothetical data. Eight people are assessed at a prediction time and classified at a 12-month horizon. Four are predicted positive and four negative. Among the positive group, two have an observed event before 12 months, one is observed event-free through 12 months, and one is censored at month 7 without an event. Among the negative group, two have observed events before 12 months, one is observed event-free through 12 months, and one is censored at month 6 without an event. Suppose a suitable censoring model estimates \(\hat G_i(T_i-)=0.80\) at each observed event time and \(\hat G_i(12)=0.50\) for the two observed event-free people. Assume conditional independent censoring and positivity for these data.

Each observed event receives weight \(1/0.80=1.25\), and each person known to be event-free through month 12 receives weight \(1/0.50=2\). The two censored people have unknown 12-month status, so each contributes zero to the outcome-specific totals. The positive group therefore contributes \(TP_w=2(1.25)=2.50\) and \(FP_w=2\). The negative group contributes \(FN_w=2(1.25)=2.50\) and \(TN_w=2\).

Weighted sensitivity is \(2.50/(2.50+2.50)=0.500\), and weighted specificity is \(2/(2+2)=0.500\). Weighted PPV is \(2.50/(2.50+2)=0.556\), while weighted NPV is \(2/(2+2.50)=0.444\). These are illustrative IPCW estimates, not exact population proportions. Their fractional weighted totals reflect the adjustment for incomplete observation. The calculation depends on the supplied censoring probabilities and would not be justified if those probabilities were unsuitable or if censoring were conditionally informative.

Thresholds, Comparisons, and Diagnostics

A lower threshold generally classifies more people as positive, which can increase sensitivity while reducing specificity; a higher threshold generally does the reverse. The change is not guaranteed to be strict at every threshold, because predicted risks may tie or because of the observed data. The threshold should be selected for a stated practical purpose and, when possible, prespecified rather than chosen to maximize apparent performance on the validation cohort.

Worked Example: Comparing Two Prespecified Thresholds

Hypothetical data. In a fully observed validation cohort of 200 people, 40 experience the event by 12 months and 160 remain event-free. At \(q=0.10\), the classification gives \(TP=30\), \(FN=10\), \(FP=30\), and \(TN=130\). At the higher threshold \(q=0.25\), it gives \(TP=20\), \(FN=20\), \(FP=10\), and \(TN=150\). Both classifications use only prediction-time information, and complete 12-month outcomes mean no censoring adjustment is needed.

At \(q=0.10\), sensitivity is \(30/40=0.750\), specificity is \(130/160=0.813\), PPV is \(30/(30+30)=0.500\), and NPV is \(130/(130+10)=0.929\). The rule flags \(60/200=0.300\), or 30.0%, of the cohort.

At \(q=0.25\), sensitivity is \(20/40=0.500\), specificity is \(150/160=0.938\), PPV is \(20/(20+10)=0.667\), and NPV is \(150/(150+20)=0.882\). The rule flags \(30/200=0.150\), or 15.0%, of the cohort. In this example, the higher threshold flags fewer people and detects a smaller fraction of events, while the fraction of positive classifications that are events is higher. These results alone do not determine which threshold is preferable; that depends on the consequences of missed events, unnecessary alerts, and available resources.

Threshold measures answer a different question from discrimination measures such as the area under a receiver operating characteristic curve: they describe performance at a particular decision boundary rather than ranking across many boundaries. They also differ from decision-curve analysis, which combines threshold-based classifications with specified relative consequences of false positives and false negatives. Reporting threshold measures alongside predicted-risk calibration and other relevant performance summaries gives a more complete evaluation than reporting any single measure alone.

Several checks help identify problems. Confirm that each prediction corresponds to the intended horizon and uses only information available at its prediction time. Check that the horizon outcome and event definition are applied consistently. Examine estimated censoring probabilities across relevant times and covariate patterns: values near zero create large weights and unstable estimates. Report how many outcomes were censored before the horizon and, where useful, summarize the distribution of weights or the impact of unusually large weights. Weight truncation can reduce instability but changes the estimator and may introduce bias; it should not be presented as a cure for severe positivity violations. Uncertainty intervals should account for the estimation process, including censoring-model estimation; resampling people and repeating the relevant fitting steps is one possible approach.

The formulas above assume a single event type. When the target is one event type in the presence of competing events, define the horizon outcome using the target cumulative incidence and treat competing events as observed competing outcomes, not as ordinary censoring. The event definition and estimator must match the cumulative-incidence estimand; treating competing events as if they were loss to follow-up can give misleading results.

Common Mistakes and Limits

  • Calling a censored person event-free. No event observed before censoring does not establish that the person remained event-free through the horizon. Their horizon outcome is unknown unless the event occurred before censoring.
  • Using the wrong denominator. Sensitivity divides by all observed event cases; PPV divides by all predicted positives. A statement about “the proportion detected” should identify which of these is intended.
  • Ignoring the prediction horizon. A 12-month sensitivity is not interchangeable with a 6-month sensitivity. State the horizon and the time origin for the prediction.
  • Using future information in predictions. A prediction for time \(t\) must be based on information available by \(t\). This restriction does not mean the censoring model must ignore later follow-up: appropriate post-prediction follow-up data may be used to estimate censoring probabilities for validation.
  • Interpreting a high PPV as universal performance. PPV depends on event frequency in the evaluated population. A change in population can change PPV even if sensitivity and specificity are similar.

IPCW cannot recover information without assumptions. Misspecified censoring models, unmeasured predictors of both censoring and event time, or near-zero probabilities of remaining observed can undermine the estimates. Threshold metrics also discard information about how far predicted risks lie above or below the cutoff. They should be interpreted as summaries for a particular horizon, population, and decision threshold, not as complete evidence of model quality or as evidence that using the rule improves outcomes.

Check Your Understanding

Answer each question, then compare your reasoning with the solutions below.

  1. At a fixed horizon, a threshold gives \(TP=18\), \(FN=6\), \(FP=12\), and \(TN=64\). Calculate sensitivity, specificity, PPV, and NPV.
  2. Why is it incorrect to count a person censored before the horizon, without a prior event, as a true negative?
  3. An observed event occurs at month 5, and the estimated probability of remaining uncensored just before month 5 is 0.75. What IPCW weight is used for this event?
  4. State the information restriction for a prediction made at time \(t\), and explain whether a censoring model may use follow-up collected after \(t\).
  5. Why can PPV change between populations even when sensitivity and specificity are similar?

Solutions. (1) Sensitivity is \(18/(18+6)=0.750\); specificity is \(64/(64+12)=0.842\); PPV is \(18/(18+12)=0.600\); and NPV is \(64/(64+6)=0.914\). (2) Censoring before the horizon leaves the horizon outcome unknown: the person might experience the event later, so they are not known to be event-free through the horizon. (3) The event weight is \(1/0.75=1.333\), approximately, using the estimated probability of remaining uncensored just before the event time. (4) The prediction and its predictor information must use only information available by \(t\). A suitable censoring model may use appropriate observed follow-up and censoring data collected after \(t\); those data estimate censoring probabilities and must not leak future information into the risk predictions. (5) PPV depends on event frequency as well as sensitivity and specificity, so a different event frequency can change PPV even when sensitivity and specificity are similar.

Clinical Biostats