The likelihood function for Cox PH regression when there are $k$ failures is

\begin{equation} \mathcal{L} = \prod_{j=1}^k \frac{\exp ( \mathbf{x}_j^{\mathsf{T}} \boldsymbol{\beta}) } {\sum_{i\in R(t_{(j)})} \exp ( \mathbf{x}_i^{\mathsf{T}} \boldsymbol{\beta}) }.\\ \end{equation}

However, the likelihood can be written to represent all $n$ subjects as

\begin{equation} \mathcal{L} = \prod_{j=1}^n \left\{ \frac{w_j}{W_j} \right\}^{d_j}, \end{equation}

where $d_j$ equals 1 for a failure and zero otherwise, and

\begin{equation} W_j = \sum_{i\in R(t_{(j)})} \exp ( \mathbf{x}_i^{\mathsf{T}} \boldsymbol{\beta}) \end{equation}

Taking the log of the likelihood above gives

\begin{equation} \ell = \sum_j d_j \log(w_j) -\sum_j d_j \log(W_j). \end{equation}

Next, let $Y_i(t_j)$ be an at-risk indicator, equal to 1 if subject $i$ is at risk at time $t_j$, and 0 otherwise. If we let the relative probability of failure for subject $i$ be $w_i$, then the absolute probability of failure for subject $i$ at time $t_j$ is

\begin{equation} \pi_{ij} =Y_i(t_j) \frac{w_i}{W_j}. \end{equation}

Looking at the log-likelihood, $\ell$, since we know that $w_j=\exp ( \mathbf{x}_i^{\mathsf{T}} \boldsymbol{\beta})$, taking the log of $w_j$ simply gives us $\mathbf{x}_i^{\mathsf{T}} \boldsymbol{\beta}=\eta_j$.

So we can now write the log-likelihood as

\begin{equation} \ell = \sum_j d_j \eta_j - \sum_j d_j \log(W_j) \end{equation}

The question is: If we know there are many $\eta$ in $W_j$, how can the first partial derivative of the log-likelihood w.r.t. $\eta_i$ be

\begin{equation} \frac{\partial \ell}{\partial \eta_i} = d_j - \sum_j \pi_{ij}d_j \end{equation}


1 Answer 1


It can't.

Your $\ell$ isn't the log of your ${\cal L}$; there's a sum missing. If we call it $\ell_j$ instead, because it's got an unbound $j$ index, we can look at its derivatives

We have $$\frac{\partial \log(W_j)}{\partial\eta_i}=\frac{1}{W_j}\frac{\partial W_j}{\partial\eta_i}$$ Now $W_j$ is a sum of terms $\exp\eta_k$ for $k$ in the relevant risk set. The derivative of one of these terms with respect to $\eta_i$ is zero unless $i=k$, when it's $\exp\eta_i=w_i$. That is $$\frac{\partial \log(W_j)}{\partial\eta_i}=\frac{1}{W_j}\frac{\partial W_j}{\partial\eta_i}=\frac{w_i}{W_j}\mathbb{1}_{\textrm{something}}$$ where $\mathbb{1}_{\textrm{something}}$ is the indicator that $\exp\eta_i$ actually does appear in $W_j$. That turns out to be precisely $Y_i(t_j)$; the event that $i$ is alive when $j$ dies or is censored, so we get $$\frac{\partial \ell_j}{\partial\eta_i}=d_j-\pi_{ij}d_j$$ with $i$ and $j$ unbound on the right because they are on the left

For the full loglikelihood $\ell=\sum_j \ell_j$ we have $$\frac{\partial \ell}{\partial\eta_i}=\sum_j\frac{\partial \ell_j}{\partial\eta_i}=\sum_j(d_j-\pi_{ij}d_j)$$

That's written as a sum over observations.

The score contribution with respect to $\eta_i$ at time $t_j$, though, is not $d_j-\pi_{ij}d_j$ but $$d_j-\sum_{t_k>t_j} \pi_{ik}d_k$$ The sum is still there, because in this decomposition we keep together the score contributions of all observations at time $t_j$, rather than the score contributions of observation $j$ at all times. There are like $n^/2$ terms $d_{k}\pi_{ik}$ in the score vector, and we're just choosing how to split them into sums.

  • $\begingroup$ Thanks, I forgot to list the sums in $\ell$, which is now fixed. $\endgroup$
    – user318288
    Feb 4, 2022 at 6:08
  • $\begingroup$ I like this approach to the likelihood for Cox PH regression because it is amenable to IRLS (non-GLM). IRLS models for non-linear, logistic, Poisson regression, etc., all have a score vector element values of $u_j=\sum_i x_{ij}e_i$, where $e_i$ is a residual, or at least a delta of some sort. So, in IRLS here, $e_i=d_j - \sum \pi_{ik}d_k$, and a single additional step using the chain rule will yield the $x$. $\endgroup$
    – user318288
    Feb 4, 2022 at 16:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.