Section 11.28

Censoring

Definition

Censoring is the situation in which a measurement shows only that a value lies beyond a limit, not what the value is. In timing, the usual case is right censoring: an operation is still unfinished when observation stops at a time limit cc, so its duration is known only to be greater than cc. A censored observation is recorded as a pair: the time observed, and a flag that says whether the event, such as completion, was seen. Recording the limit as if it were the duration understates the duration.

The idea

A test sends four requests to a server and waits at most 10 seconds for each answer. Three requests are answered after 1, 2 and 3 seconds. The fourth is still unanswered when its 10 seconds run out, and the test stops waiting. Writing 10 for the fourth request gives a mean of (1+2+3+10)/4=4(1 + 2 + 3 + 10)/4 = 4 seconds, but the fourth request did not take 10 seconds; it took more than 10, perhaps much more. Leaving it out gives (1+2+3)/3=2(1 + 2 + 3)/3 = 2 seconds, the mean of the answered requests, which hides the slowest request entirely.

A race whose finish line closes after 10 hours is a fair picture. A runner still on the course at closing time did not finish in 10 hours; the runner’s time is “more than 10 hours”. That is real information: the runner was slower than everyone who finished. Methods for censored data keep that information without inventing a finishing time. The picture also marks where censoring stops applying. If officials take a runner off the course at closing time, that runner will never finish, so there is no finishing time to estimate. The same holds for an operation that is canceled at the limit: its outcome is a failure, not a late completion.

How it works

  1. Choose the target before the analysis, because censoring affects each target differently.

    • The distribution of the eventual completion time TT, including its mean.

    • The completion probability by a deadline: the fraction of operations that finish within the limit cc.

    • The capped time min(T,c)\min(T, c): the time an operation occupies before it either finishes or is given up.

    • The time of completed operations only. This is a different quantity, conditional on finishing.

  2. Record two values for every operation: the observed time YY, which is the completion time if the operation finished within its limit and the limit otherwise, and the event flag δ\delta, which is 1 if completion was seen and 0 if the observation was censored. Also record what happened at the limit: the operation was canceled, retried, or left running.

  3. Report the number of censored operations next to every summary of durations.

  4. Compute what the data determine exactly when every operation was watched for the same limit cc. The observed completion fraction by any time t≤ct \le c is the fraction of operations with δ=1\delta = 1 and Y≤tY \le t. For a nearest-rank sample percentile §11.16 at level pp, at least ⌈np⌉\lceil np\rceil completions suffice. An interpolated percentile needs every order statistic it uses. With 19 of 20 completions, nearest-rank p95 uses rank 19. Type 7 interpolation uses ranks 19 and 20, so it still needs the censored duration. The mean capped time is the plain mean of the YY values.

  5. Use survival analysis when the limits differ between operations, for example when a run ends while operations that started at different times are still in progress. Survival analysis is the branch of statistics for times until an event when some times are censored. Its basic tool, the Kaplan–Meier estimator §11.2 (formula below), estimates the probability that an operation is still unfinished at each time. An operation censored at time cic_i counts as in progress up to cic_i and is then dropped from the count, so the knowledge that it lasted at least cic_i is used and nothing beyond cic_i is assumed.

Two other forms of censoring occur in timing. In left censoring the value is known only to be below a limit, as when a timer reading of 0 ticks shows only that the operation took less than one tick. In interval censoring the value is known only to lie between two times, as when a program checks every 100 milliseconds whether an operation has finished, and finds it unfinished at the second check and finished at the third; the operation then finished between 200 and 300 milliseconds.

Worked example

One common limit. The four requests described above were each watched for c=10c = 10 seconds. The records (Y,δ)(Y, \delta) are (1,1)(1, 1), (2,1)(2, 1), (3,1)(3, 1) and (10,0)(10, 0).

Different limits, Kaplan–Meier. Five operations give these records, in seconds: A completed at 2; B was censored at 3, because the run ended; C completed at 4; D completed at 5; E was censored at 6. Let Ŝ(t)\hat{S}(t) be the estimated probability that an operation is unfinished at time tt.

The estimated median is the first time at which Ŝ\hat{S} falls to 0.5 or below: 5 seconds. Two shortcuts give wrong answers. Dropping B and E leaves completions at 2, 4 and 5, which says that every operation is done by 5 seconds: Ŝ(5)=0\hat{S}(5) = 0. Treating B and E as completions at 3 and 6 gives Ŝ(5)=1/5=0.2\hat{S}(5) = 1/5 = 0.2, too low, because it counts B as finished at 3 seconds although B was only known to be unfinished then.

Stated precisely

Let T≥0T \ge 0 be the time at which an operation would complete and CC the time at which observation of it stops. The record is Y=min(T,C)Y = \min(T, C) together with δ=1\delta = 1 if T≤CT \le C and δ=0\delta = 0 otherwise. The survival function is S(t)=P(T>t)S(t) = P(T > t), the probability that the operation is still unfinished at time tt.

Let t1<t2<…t_1 < t_2 < \dots be the distinct observed completion times, did_i the number of completions at tit_i, and nin_i the number of operations at risk at tit_i, meaning those with Y≥tiY \ge t_i. The Kaplan–Meier estimator [528] is Ŝ(t)=∏i:ti≤t(1−dini),\hat{S}(t) = \prod_{i \,:\, t_i \le t} \left(1 - \frac{d_i}{n_i}\right), the product over all completion times up to tt, with Ŝ(t)=1\hat{S}(t) = 1 before the first completion. It is consistent, meaning that its error tends to zero as the number of operations grows, at every time tt at which operations can still be under observation, provided two assumptions hold.

  1. Independent censoring: the time CC at which observation stops is independent of the completion time TT. Whether observation stops must not depend on how the operation is going.

  2. Independent observations: operations are independent draws from the same distribution of TT, whatever their limits.

With a common limit cc, the mean of the YY values estimates the restricted mean E[min(T,c)]=∫0cS(t)dt,\mathrm{E}[\min(T, c)] = \int_0^c S(t)\,dt, where E\mathrm{E} denotes the expected value (the probability-weighted average). The restricted mean never exceeds the mean E[T]=∫0∞S(t)dt\mathrm{E}[T] = \int_0^\infty S(t)\,dt. The mean E[T]\mathrm{E}[T] depends on S(t)S(t) for t>ct > c, where the data contain no completions, so the data alone do not determine it. If some operations never complete, that is, P(T=∞)>0P(T = \infty) > 0, then E[T]\mathrm{E}[T] is infinite.

Limits and common mistakes

Questions answered

Should a timed-out operation be recorded as exactly the timeout length?

No: a timed-out operation must not be recorded as a completion that took exactly the timeout length, because it did not complete within that time, and its true duration, if it ever completes, is longer. Record the time observed together with a flag that marks the operation as unfinished, and distinguish work still running from work canceled at the deadline, and count timeouts separately in every report.

The timeout length is the right value only for a capped target, the time each operation occupies before it finishes or is given up; the recorded values give the exact sample capped mean and estimate the population capped mean. For the completion time itself, report the completion probability within the limit, sample percentiles whose required ranks are observed, and survival-analysis estimates such as the Kaplan–Meier curve, which use the knowledge that the operation lasted at least the limit. If the timeout cancels the operation, the operation has no completion time: report it as a failure. For example, requests that complete in 1, 2 and 3 seconds plus one that times out at 10 give a capped mean of (1+2+3+10)/4=4(1 + 2 + 3 + 10)/4 = 4 seconds; if the fourth request finishes at 30 seconds, the true mean is (1+2+3+30)/4=9(1 + 2 + 3 + 30)/4 = 9 seconds.

Related entries: Estimand and estimator (§11.2), Missing data and attrition (§11.29), Survivorship bias (§11.30), Finite-window rate (§11.41), Deadline versus timeout (§9.34), Empirical cumulative distribution function (ECDF) (§11.17). Further reading: [528].