Skip to content

Commit

Permalink
clearer notation and small wordings
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthiasSchmidtblaicherQC committed Nov 4, 2024
1 parent e9260c5 commit 47540c2
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions docs/tutorials/cox_model/cox_model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@
"\n",
"In the Cox model, the rate of event occurrence, $\\lambda(t,x_i)$, factorizes nicely into a linear predictor $\\eta_i=\\sum_k \\beta_k x_{ik}$ that depends on individual $i$'s characteristics but not on time $t$ and a baseline hazard $\\lambda_0$ that depends only on time, $\\lambda(t,x_i)=\\lambda_0(t)\\exp(\\eta_i)$ (the proportional hazards assumption). The partial log-likelihood of $\\eta_i$ is\n",
"$$\n",
"\\sum_{\\text{event times}}\\log\\left(\\frac{\\exp(\\eta_{\\text{d}_t})}{\\sum_{i \\in \\mathcal{R}_t} \\exp(\\eta_i)} \\right),\n",
"\\sum_{\\text{event times}}\\log\\left(\\frac{y_{i,t}\\exp(\\eta_{i})}{\\sum_{i \\in \\mathcal{R}_t} \\exp(\\eta_i)} \\right),\n",
"$$\n",
"where $\\mathcal{R}_t$ is the set of individuals observed at event time $t$ and $\\text{d}_t$ is an indicator for the individual with an event at $t$.[<sup>1</sup>](#fn1) This partial log-likelihood cannot be represented as the log-likelihood of an EDM.[<sup>2</sup>](#fn2) Now consider an alternative Poisson regression with an event indicator for each individual and time period as outcome. Apart from a constant, the log likelihood is\n",
"where $\\mathcal{R}_t$ is the set of individuals observed at event time $t$ and $y_{i,t}$ is one if the individual has an event at $t$ and zero otherwise.[<sup>1</sup>](#fn1) This partial log-likelihood cannot be represented as the log-likelihood of an EDM.[<sup>2</sup>](#fn2) Now consider an alternative Poisson regression with $y_{i,t}$ as an outcome. Apart from a constant, the log likelihood is\n",
"$$\n",
"\\sum_{\\text{event times}}\\sum_{i \\in \\mathcal{R}_t} \\text{d}_t \\log(\\lambda(t,x_i)) - \\lambda(t,x_i).\n",
"\\sum_{\\text{event times}}\\sum_{i \\in \\mathcal{R}_t} y_{i,t} \\log(\\lambda(t,x_i)) - \\lambda(t,x_i).\n",
"$$\n",
"Using the proportional hazards assumption and letting $\\alpha_t = \\log(\\lambda_0(t))$, this becomes\n",
"$$\n",
"\\sum_{\\text{event times}}\\sum_{i \\in \\mathcal{R}_t} \\text{d}_t \\left(\\alpha_t + \\eta_i\\right) - \\exp(\\alpha_t + \\eta_i).\n",
"\\sum_{\\text{event times}}\\sum_{i \\in \\mathcal{R}_t} y_{i,t} \\left(\\alpha_t + \\eta_i\\right) - \\exp(\\alpha_t + \\eta_i).\n",
"$$\n",
"Solving the first order condition with respect to $\\alpha_t$ yields $\\exp(\\hat{\\alpha}_t) = \\left(\\sum_{i \\in \\mathcal{R}_t} \\exp(\\eta_i)\\right)^{-1}$. This can be plugged back into the log likelihood to yield, after some simplifications,\n",
"$$\n",
"\\sum_{\\text{event times}}\\log\\left(\\frac{\\exp(\\eta_{\\text{d}_t})}{\\sum_{i \\in \\mathcal{R}_t} \\exp(\\eta_i)} \\right) - 1,\n",
"\\sum_{\\text{event times}}\\log\\left(\\frac{y_{i,t}\\exp(\\eta_{i})}{\\sum_{i \\in \\mathcal{R}_t} \\exp(\\eta_i)} \\right) - 1,\n",
"$$\n",
"which is the same as the partial likelihood in the Cox model, apart from the -1 which drops out in estimation. In short, the Cox partial log likelihood is equivalent to a Poisson log likelihood with the estimate for time period effects fed back in (\"profiled out\"). This means that, to estimate the parameters of the Cox model, one can simply run a Poisson regression with time fixed effects $\\alpha_t$.\n",
"which is the same as the partial likelihood in the Cox model, apart from the -1 which drops out when taking derivatives. In short, the Cox partial log likelihood is equivalent to a Poisson log likelihood with the estimate for time period effects fed back in (\"profiled out\"). This means that, to estimate the parameters of the Cox model, one can simply run a Poisson regression with time fixed effects $\\alpha_t$.\n",
"\n",
"## 2. Estimating a Cox Model in Glum<a class=\"anchor\"></a>\n",
"\n",
Expand Down Expand Up @@ -601,7 +601,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We can check that the Poisson regression yields very similar estimates and standard errors to the Cox regression:"
"We can check that the Poisson regression yields estimates and standard errors that, for all practical purposes, are the same as those of the Cox regression:"
]
},
{
Expand Down

0 comments on commit 47540c2

Please sign in to comment.