Solution (source code)

= Solution

Assume the usual cohort setup: all individuals enter at time zero, each contributes one event or <censoring> time, and every such observation is included. Order these distinct observation times as $t_1<\cdots<t_m$. The <risk set> size just before $t_k$ is then $r_k=m-k+1$. Write $\delta_k=1$ for an event and zero for <censoring>. Including the jump at an event time, the <Nelson–Aalen estimator> is
$$
\widehat H_j=\sum_{k=1}^{j}\frac{\delta_k}{m-k+1}.
$$
Exchange the two finite sums:
$$
\sum_{j=1}^{m}\widehat H_j
=\sum_{k=1}^{m}\frac{\delta_k}{m-k+1}\sum_{j=k}^{m}1
=\sum_{k=1}^{m}\delta_k.
$$
Thus \b[the sum equals the number of observed events]. Each event increment appears once for each individual still at risk at that event, exactly cancelling its denominator. This is the <event-count identity for Nelson–Aalen cumulative hazards>. The cohort and entry convention matter: delayed entry would invalidate the simple equation $r_k=m-k+1$ and require a modified identity.