Solution (source code)

= Solution

Use a time-homogeneous <continuous-time multi-state model> with states $H$ (healthy), $I$ (ill), and $D$ (dead), where $D$ is absorbing. For risk-factor indicator $z\in\{0,1\}$, let the transition intensities be
$$
H\xrightarrow{\lambda_z}I,
\qquad
I\xrightarrow{\gamma}H,
\qquad
I\xrightarrow{\delta}D,
\qquad
\lambda_z=\lambda_0e^{\beta z}.
$$
Here $\lambda_0$ is the infection rate without the risk factor, $e^\beta$ is the infection <hazard ratio>, $\gamma$ is the recovery rate, and $\delta$ is the disease-death rate. The assumption that the risk factor affects only acquisition makes $\gamma$ and $\delta$ common to both groups. The <infinitesimal generator> is
$$
Q_z=
\begin{pmatrix}
-\lambda_z&\lambda_z&0\\
\gamma&-(\gamma+\delta)&\delta\\
0&0&0
\end{pmatrix}.
$$