--- title: "Estimates of unknown model parameters" output: rmarkdown::html_vignette bibliography: ../inst/bibliography.bib vignette: > %\VignetteIndexEntry{Estimates of unknown model parameters} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) ``` ```{r setup} library(retrogroup) ``` `vignette("model", package = "retrogroup")` defines a survival model and derives the posterior probability that each patient belongs to each subgroup level. The estimation of the posterior probabilities depends on estimates of the prognostic effects $\gamma_k$ and the baseline cumulative hazard $\Lambda_0(t)$. This vignette derives estimates of both quantities, adding assumptions beyond those of the model only where the estimation needs them. ## Notation Along with the notation in `vignette("model", package = "retrogroup")`, define: * $d$: a generic event indicator for an arbitrary patient (1 if an event occurred, 0 if the patient was censored). * $T$: random variable representing the survival time of an arbitrary patient. * $x$: generic subgroup level with possible values $1, \ldots, K$. ## Prognostic effects Begin with $P(d = 0 \mid x = k)$, the probability that a patient in subgroup level $k$ is censored. Expand it using the law of total probability: $$ \begin{aligned} P(d = 0 \mid x = k) &= P(d = 0 \mid x = k, z = 0) P(z = 0 \mid x = k) \\ &\qquad + P(d = 0 \mid x = k, z = 1) P(z = 1 \mid x = k) \end{aligned} $$ Randomization makes treatment assignment independent of subgroup level, so $P(z = 0 \mid x = k) = P(z = 0) = 1 - P(z = 1)$ and $P(z = 1 \mid x = k) = P(z = 1) \approx \bar{z}$, where: $$ \bar{z} := \frac{1}{n}\sum_{i = 1}^n z_i $$ We now have: $$ \begin{aligned} P(d = 0 \mid x = k) &\approx P(d = 0 \mid x = k, z = 0) (1 - \bar{z}) + P(d = 0 \mid x = k, z = 1) \bar{z} \end{aligned} $$ The probability of censoring can be approximated in terms of the existing survival function at $\tau_k$, the unknown median of the distribution of potential censoring time in subgroup level $k$. We assume censoring is independent of treatment, so $\tau_k$ is the same for both treatment arms. $$ \begin{aligned} P(d = 0 \mid x, z) &\approx S(\tau_x \mid x, z) \\ &= \exp(-\Lambda_0(\tau_x) \exp(\hat{\gamma}_x + \beta_x z)) \end{aligned} $$ In addition, we can approximate the marginal probability using the assumed event count $e_k$ and the number of patients $n_k$ in subgroup level $k$. To keep the result strictly between 0 and 1 even if $e_k = 0$ or $e_k = n_k$, we first clamp the event count: $$ \tilde{e}_k := \max(1/2, \min(e_k, n_k - 1/2)) $$ which leaves $e_k$ unchanged whenever $1/2 \le e_k \le n_k - 1/2$. Then: $$ \hat{P}(d = 0 \mid x = k) = 1 - \frac{\tilde{e}_k}{n_k} $$ Putting it all together, we find: $$ \begin{aligned} 1 - \frac{\tilde{e}_k}{n_k} &\approx \exp(-\Lambda_0(\tau_k) \exp(\hat{\gamma}_k))(1 - \bar{z}) + \exp(-\Lambda_0(\tau_k) \exp(\hat{\gamma}_k + \beta_k)) \bar{z} \end{aligned} $$ We don't know the baseline cumulative hazard or median censoring time, so we need to eliminate the dependence on $\Lambda_0(\tau_k)$ in our approximation. We do this with the following two conditions: 1. $\hat{\gamma}_1 = 0$ by definition. 2. We assume all subgroup levels have the same censoring distribution, so all subgroup levels share the same median censoring time so that $\tau_1 = \tau_2 = \dots = \tau_K$. With these conditions, the approximation for subgroup level $k = 1$ has $\Lambda_0(\tau_1)$ as its only unknown: $$ 1 - \frac{\tilde{e}_1}{n_1} \approx \exp(-\Lambda_0(\tau_1))(1 - \bar{z}) + \exp(-\Lambda_0(\tau_1) \exp(\beta_1)) \bar{z} $$ A root finding algorithm can solve this for $\Lambda_0(\tau_1)$. Then, with $\Lambda_0(\tau_k) = \Lambda_0(\tau_1)$ plugged into the approximation for subgroup level $k > 1$, a root finding algorithm can solve for $\hat{\gamma}_k$. In both cases, a unique finite root exists because the left side is strictly between 0 and 1 and the right side decreases strictly from 1 to 0 in the unknown. ## Conditional expected relative hazard Before we derive the baseline cumulative hazard, we first need to estimate the conditional expectation of the relative hazard $\exp(\hat{\gamma}_x + \beta_x z)$, the ratio of a patient's hazard rate to the baseline hazard rate, given survival up to time $t$ and treatment arm $z$, marginalized over subgroup level $x$: $$ E \left (\exp(\hat{\gamma}_x + \beta_x z) \mid T \ge t, z \right) = \sum_{k = 1}^K \exp(\hat{\gamma}_k + \beta_k z) P(x = k \mid T \ge t, z) $$ From Bayes' Theorem: $$ P(x = k \mid T \ge t, z) = \frac{P(T \ge t \mid x = k, z) P(x = k \mid z)}{\sum_{l = 1}^K P(T \ge t \mid x = l, z) P(x = l \mid z)} $$ We assume randomization makes subgroup membership independent of treatment assignment, so $P(x = k \mid z) = P(x = k) = \pi_k$. And when we evaluate the survival function using the cumulative hazard, we have $P(T \ge t \mid x = k, z) = \exp(-\Lambda_0(t) \exp(\hat{\gamma}_k + \beta_k z))$. That makes our expectation equal to: $$ E \left (\exp(\hat{\gamma}_x + \beta_x z) \mid T \ge t, z \right) = \sum_{k = 1}^K \exp(\hat{\gamma}_k + \beta_k z) \frac{\pi_k \exp(-\Lambda_0(t) \exp(\hat{\gamma}_k + \beta_k z))}{\sum_{l = 1}^K \pi_l \exp(-\Lambda_0(t) \exp(\hat{\gamma}_l + \beta_l z))} $$ Define $m_z(H)$ to be an estimate of the conditional expectation for a particular value $H$ of the cumulative baseline hazard: $$ m_z(H) := \sum_{k = 1}^K \exp(\hat{\gamma}_k + \beta_k z) \frac{\pi_k \exp(-H \exp(\hat{\gamma}_k + \beta_k z))}{\sum_{l = 1}^K \pi_l \exp(-H \exp(\hat{\gamma}_l + \beta_l z))} $$ ## Baseline cumulative hazard The Breslow estimator [@breslow1972; @lin2007] of the baseline cumulative hazard is: $$ \sum_{i = 1}^n \frac{I(t_i \le t) d_i}{\sum_{j = 1}^n I(t_j \ge t_i) \exp(\gamma_{x_j} + \beta_{x_j} z_j)} $$ Because the denominator is summing over patients still at risk at time $t_i$, we can estimate $\exp(\gamma_{x_j} + \beta_{x_j} z_j)$ with its estimated conditional expectation $m_{z_j}(H)$, where $H$ is a value of the baseline cumulative hazard at time $t_i$. The true value is unknown, so the natural choice of $H$ is the estimate itself. In other words, we seek an estimate $\hat{\Lambda}_0(t)$ that satisfies: $$ \hat{\Lambda}_0(t) = \sum_{i = 1}^n \frac{I(t_i \le t) d_i}{\sum_{j = 1}^n I(t_j \ge t_i) m_{z_j}(\hat{\Lambda}_0(t_i))} $$ or equivalently: $$ \hat{\Lambda}_0(t) = \sum_{i = 1}^n \frac{I(t_i \le t) d_i}{r_{0i} m_0(\hat{\Lambda}_0(t_i)) + r_{1i} m_1(\hat{\Lambda}_0(t_i))} $$ where $r_{zi} := \sum_{j = 1}^n I(t_j \ge t_i) I(z_j = z)$ is the number of patients in arm $z$ still at risk at time $t_i$. To approximately satisfy this requirement on $\hat{\Lambda}_0(t)$, we accumulate the sum one patient at a time, recalling that $t_1 \le t_2 \le \dots \le t_n$, and in the term for patient $i$ we replace $\hat{\Lambda}_0(t_i)$ with the running sum over the patients before patient $i$. For $i = 1, \ldots, n$, define: $$ H_i := H_{i - 1} + \frac{d_i}{r_{0i} m_0(H_{i - 1}) + r_{1i} m_1(H_{i - 1})} $$ Also define $H_0 := 0$ so that $m_z(H_0)$ is a prior expectation of $\exp(\hat{\gamma}_x + \beta_x z)$ (a weighted average over the prior probabilities $\pi_k$). We define the estimated baseline cumulative hazard as: $$ \hat{\Lambda}_0(t) := H_{N(t)} $$ where $N(t)$ is the number of patients observed up to time $t$: $$ N(t) := \sum_{i = 1}^n I(t_i \le t) $$ ## References