Solution (source code)

= Solution

For individual $i$, let $\pi_i=\pi_i(\psi)$, $q_i(t)$ be the known baseline <hazard function>, and $r_i(t;\phi)$ the extra hazard. Put
$$
Q_i(t)=\int_0^tq_i(s)ds,\qquad R_i(t;\phi)=\int_0^tr_i(s;\phi)ds.
$$
The class-specific <survival functions> are $e^{-Q_i(t)}$ and $e^{-Q_i(t)-R_i(t)}$. Consequently the unconditional survivor and failure density are
$$
F_i(t)=e^{-Q_i(t)}[\pi_i+(1-\pi_i)e^{-R_i(t)}],
$$
$$
f_i(t)=e^{-Q_i(t)}[\pi_iq_i(t)+(1-\pi_i)(q_i(t)+r_i(t))e^{-R_i(t)}].
$$
Mixture <probabilities> must be summed before taking a logarithm; a weighted average of class log-likelihoods would be a different, complete-data calculation. Substitution into the right-censored <survival likelihood> gives
$$
\boxed{\begin{aligned}
\ell(\phi,\psi)=\sum_i\bigl[&-Q_i(x_i)
+v_i\log\{\pi_iq_i(x_i)+(1-\pi_i)[q_i(x_i)+r_i(x_i;\phi)]e^{-R_i(x_i;\phi)}\}\\
&+(1-v_i)\log\{\pi_i+(1-\pi_i)e^{-R_i(x_i;\phi)}\}\bigr]+\text{constant}.
\end{aligned}}
$$
Equivalently, this <additive excess-hazard mixture likelihood> has contribution
$$
L_i=e^{-Q_i(x_i)}\{\pi_iq_i(x_i)^{v_i}+(1-\pi_i)[q_i(x_i)+r_i(x_i)]^{v_i}e^{-R_i(x_i)}\}.
$$
Here $q_i$ and $q_i+r_i$ must be nonnegative hazards. The factor $-Q_i(x_i)$ can be dropped when maximizing over $\phi,\psi$ because $q_i$ is known. Factoring out <censoring> presumes a common parameter-free <censoring> mechanism independent of failure and latent class, conditional on the observed <covariates>; unmodelled class-specific <censoring> would change these mixture contributions.