Constrained Kaplan–Meier estimator (source code)

= Constrained Kaplan–Meier estimator
{title2=$\prod_{s_j\leq t}(1-q_j)=p$}

The <Kaplan–Meier estimator> constrained to have <survivor function> value $p\in(0,1)$ at $t$ maximizes the right-<censoring> <log-likelihood> $\sum_j[d_j\log q_j+(n_j-d_j)\log(1-q_j)]$ subject to the displayed constraint. Here $q_j$ is the <discrete hazard>, $d_j$ the event count and $n_j$ the <risk set> size. In an interior event-time solution, a <Lagrange multiplier> gives $q_j=d_j/(n_j+\lambda)$ before the constrained time, with $q_j=d_j/n_j$ afterwards. The multiplier is chosen to satisfy the product constraint. It is essential to allow a zero-event jump at the constrained time or another relevant cell boundary: a constraint can require mass outside observed event times. A general implementation instead maximizes the concave probability-mass <log-likelihood> with total mass one and mass above $t$ equal to $p$, allowing all relevant cells and a terminal tail. This also handles unobserved tails and boundary solutions without imposing unjustified event-only support.