Solution (source code)

= Solution

Let $N(t)$ count observed events and $Y(t)$ count individuals still in the <risk set> just before $t$. Under a common <hazard function> $h(t)$ and <independent censoring>, the expected event count over a short interval, conditional on the observed past, is
$$
\operatorname E[dN(t)\mid\mathcal F_{t-}]=Y(t)h(t)\,dt=Y(t)\,dH(t).
$$
Here $H(t)=\int_0^t h(u)\,du$ is the <integrated hazard>. Thus an estimating increment for $dH$ is $dN/Y$, on the range where the <risk set> is nonempty. Accumulating these increments gives the <Nelson–Aalen estimator>
$$
\boxed{\widehat H(t)=\int_0^t\frac{\mathbf1_{\{Y(u)>0\}}}{Y(u)}\,dN(u)
=\sum_{t_j\leq t}\frac{\delta_j}{r_j}.}
$$
The observation times $t_j$ include both events and censorings, $r_j=Y(t_j)$, and $\delta_j$ is one for an event and zero for <censoring>. Without ties each event adds $1/r_j$; <censoring> changes later <risk sets> but adds nothing immediately. Equivalently, the local event fraction estimates the local hazard increment, and summing those estimates produces the <integrated hazard>. The <counting-process intensity in survival analysis> justifies this estimating equation; it does not imply exact finite-sample unbiasedness after the <risk set> can become empty.