EM algorithm for a censored lognormal competing-risks mixture (source code)

= EM algorithm for a censored lognormal competing-risks mixture
{c}
{title2=$\Pr(I=j\mid T>c)=\pi_j S_j(c)/\sum_\ell\pi_\ell S_\ell(c)$}

Let eventual outcome $I=j$ have probability $\pi_j$, with $\log T\mid I=j\sim N(\mu_j,\sigma_j^2)$. An observed outcome at time $t$ contributes $\pi_j f_j(t)$ to the <likelihood>, while <right censoring> at $c$ contributes $\sum_j\pi_j S_j(c)$. The <expectation-maximization algorithm> imputes both the censored outcome and its latent log event time. Its E-step uses the displayed conditional weights and the first two moments of a <truncated normal distribution> above $\log c$. With $z=(\log c-\mu_j)/\sigma_j$ and <Inverse Mills ratio> $\psi(z)$, these moments are $m=\mu_j+\sigma_j\psi(z)$ and $s=m^2+\sigma_j^2[1-\psi(z)(\psi(z)-z)]$. Observed outcomes use deterministic class weights and moments $\log t,(\log t)^2$. The M-step updates each class probability to its average weight, its mean to the weighted first moment, and its variance to the weighted second moment minus the squared new mean. Outcome-specific cumulative probabilities are <cumulative incidence functions>, not the conditional distributions $F(t\mid I=j)$ themselves.