Skip to content
AITroveRead. Build. Understand.
Make this comfortable

Restricted mean time: compare curves at a supported horizon

Last updated: 7 Oct 20265 min read
tutorial
AdvancedBy AITrove Editorial

The area under an unresolved-survival curve up to a declared horizon summarizes time unresolved without assuming one constant hazard ratio.

Choose the horizon first

Two ticket queues may resolve cases at different speeds early but reverse later. The restricted mean unresolved time up to 12 hours is the area under each queue’s unresolved-survival curve from zero to 12. It is measured in hours and can be compared directly: a lower value means less time unresolved within that horizon. Choose 12 hours from the service decision and observed follow-up, not because the curves happen to favor one team there. Risk-set construction supplies the curve.

Integrate the step function

A product-limit curve remains constant between event times. Sum each interval width times the survival value that applies during that interval, and stop exactly at the declared horizon. If the last observation ends before the horizon, do not carry a tail forward as if its support were known; report the horizon as unsupported or use an approved estimator with clearly stated assumptions. The code computes area from supplied event steps and assumes follow-up supports the requested endpoint. At-risk counts should accompany the result.

Interpret a difference carefully

A two-hour difference in restricted mean unresolved time is an average over the selected window, not a guarantee that every ticket saves two hours. When groups were not randomized, queue mix, priority and staffing can confound the contrast. Censoring patterns may differ by group. Compute uncertainty with a method that respects independent units such as account or branch, and examine support at the horizon. Cluster resampling must resample the correct unit.

Keep both shapes visible

Report the two curves, at-risk tables, horizon, area estimates, difference and censoring reasons. A single area number can hide a period when one queue performs worse; those crossings matter to a service-level decision. A log-rank test has different emphasis and may have weak sensitivity to crossing alternatives. The project holds a claim when the chosen horizon has too little observed support.

Implementation

python
def restricted_unresolved_hours(event_steps, horizon_hours):
    if horizon_hours <= 0:
        raise ValueError("positive horizon required")
    area = 0.0
    previous_time = 0.0
    survival = 1.0
    for event_time, after_event_survival in event_steps:
        if event_time < previous_time or not 0 <= after_event_survival <= survival:
            raise ValueError("invalid survival steps")
        if event_time >= horizon_hours:
            break
        area += (event_time - previous_time) * survival
        previous_time = event_time
        survival = after_event_survival
    return area + (horizon_hours - previous_time) * survival

hours = restricted_unresolved_hours([(4, 0.75), (8, 0.375)], 10)
assert hours == 7.75

Performance and operating cost

Integrating k sorted event steps is O(k) time and O(1) extra space. Constructing uncertainty and verifying follow-up at the horizon take more work. The function does not check whether censoring support reaches the horizon; that condition must be audited in the calling analysis.

Common Mistakes

  • Choosing a horizon after seeing which queue wins.
  • Extending a curve past available follow-up without declaring an assumption.
  • Treating a restricted-mean difference as an individual guaranteed saving.
  • Reporting one area estimate without curves, at-risk counts and censoring reasons.

Read next

Continue the workflow: Cause-specific hazard versus cumulative incidence: know which question changed.

ai-data
applied-statistics
Storage details