Cox proportional hazards model

TheoremA subject belongs to its own risk set#✓fully proved

Subject i is in its own risk set.

theorem mem_riskSet (T : Fin n → ℝ) (i : Fin n) : i ∈ riskSet T i
Uses 1 · Used by 1

TheoremRisk sets are nonempty#✓fully proved

The risk set of subject i is nonempty.

theorem riskSet_nonempty (T : Fin n → ℝ) (i : Fin n) : (riskSet T i).Nonempty
Uses 2 · Used by 5

DefinitionCox partial likelihood#✓fully proved

Cox's partial likelihood ∏_{i : δᵢ} exp ⟪β, xᵢ⟫ / ∑_{l ∈ R(Tᵢ)} exp ⟪β, x_l⟫.

noncomputable def partialLikelihood (T : Fin n → ℝ) (δ : Fin n → Bool) (x : Fin n → Fin p → ℝ)
    (β : Fin p → ℝ) : ℝ :=
  ∏ i with δ i = true, exp (β ⬝ᵥ x i) / ∑ l ∈ riskSet T i, exp (β ⬝ᵥ x l)
Uses 1 · Used by 1

DefinitionCox log partial likelihood#✓fully proved

The log partial likelihood ∑_{i : δᵢ} (⟪β, xᵢ⟫ - log ∑_{l ∈ R(Tᵢ)} exp ⟪β, x_l⟫).

noncomputable def logPartialLikelihood (T : Fin n → ℝ) (δ : Fin n → Bool)
    (x : Fin n → Fin p → ℝ) (β : Fin p → ℝ) : ℝ :=
  ∑ i with δ i = true, (β ⬝ᵥ x i - log (∑ l ∈ riskSet T i, exp (β ⬝ᵥ x l)))
Uses 1 · Used by 3

TheoremLog of the Cox partial likelihood is the log partial likelihood#✓fully proved

The logarithm of the partial likelihood is the log partial likelihood.

theorem log_partialLikelihood (T : Fin n → ℝ) (δ : Fin n → Bool) (x : Fin n → Fin p → ℝ)
    (β : Fin p → ℝ) : log (partialLikelihood T δ x β) = logPartialLikelihood T δ x β
Uses 4

TheoremConcavity of the Cox log partial likelihood#✓fully proved

Concavity of the Cox log partial likelihood on ℝᵖ.

theorem concaveOn_logPartialLikelihood (T : Fin n → ℝ) (δ : Fin n → Bool)
    (x : Fin n → Fin p → ℝ) : ConcaveOn ℝ Set.univ (logPartialLikelihood T δ x)
Uses 3

DefinitionWeighted mean of a covariate over a risk set#✓fully proved

The exp (b z)-weighted mean of a scalar covariate z over the risk set of subject i.

noncomputable def riskMean (T : Fin n → ℝ) (z : Fin n → ℝ) (b : ℝ) (i : Fin n) : ℝ :=
  (∑ l ∈ riskSet T i, z l * exp (b * z l)) / ∑ l ∈ riskSet T i, exp (b * z l)
Uses 1 · Used by 6

DefinitionWeighted variance of a covariate over a risk set#✓fully proved

The exp (b z)-weighted variance of a scalar covariate over the risk set of subject i.

noncomputable def riskVar (T : Fin n → ℝ) (z : Fin n → ℝ) (b : ℝ) (i : Fin n) : ℝ :=
  (∑ l ∈ riskSet T i, z l ^ 2 * exp (b * z l)) / (∑ l ∈ riskSet T i, exp (b * z l)) -
    riskMean T z b i ^ 2
Uses 2 · Used by 3

DefinitionCox score for a scalar covariate#✓fully proved

The Cox score for a scalar covariate: ∑_{i : δᵢ} (zᵢ - z̄ᵢ(b)).

noncomputable def coxScore (T : Fin n → ℝ) (δ : Fin n → Bool) (z : Fin n → ℝ) (b : ℝ) : ℝ :=
  ∑ i with δ i = true, (z i - riskMean T z b i)
Uses 1 · Used by 3

DefinitionCox observed information for a scalar covariate#✓fully proved

The Cox observed information for a scalar covariate: ∑_{i : δᵢ} Varᵢ(b).

noncomputable def coxInformation (T : Fin n → ℝ) (δ : Fin n → Bool) (z : Fin n → ℝ) (b : ℝ) :
    ℝ :=
  ∑ i with δ i = true, riskVar T z b i
Uses 1 · Used by 2

DefinitionLog partial likelihood of a scalar covariate#✓fully proved

The log partial likelihood of a scalar covariate z as a function of b ∈ ℝ.

noncomputable def logPartialLikelihood₁ (T : Fin n → ℝ) (δ : Fin n → Bool) (z : Fin n → ℝ)
    (b : ℝ) : ℝ :=
  logPartialLikelihood T δ (fun i _ => z i) (fun _ : Fin 1 => b)
Uses 1 · Used by 1

TheoremDerivative of the log partial likelihood is the Cox score#✓fully proved

The derivative of the scalar log partial likelihood is the Cox score.

theorem hasDerivAt_logPartialLikelihood (T : Fin n → ℝ) (δ : Fin n → Bool) (z : Fin n → ℝ)
    (b : ℝ) : HasDerivAt (logPartialLikelihood₁ T δ z) (coxScore T δ z b) b
Uses 5

TheoremDerivative of the Cox score is minus the information#✓fully proved

The derivative of the Cox score is minus the observed information.

theorem hasDerivAt_coxScore (T : Fin n → ℝ) (δ : Fin n → Bool) (z : Fin n → ℝ) (b : ℝ) :
    HasDerivAt (coxScore T δ z) (-coxInformation T δ z b) b
Uses 6

DefinitionNumber at risk at a subject's time#✓fully proved

The number at risk at the time of subject i.

noncomputable def numAtRisk (T : Fin n → ℝ) (i : Fin n) : ℕ := #(riskSet T i)
Uses 1 · Used by 4

DefinitionNumber of group-1 subjects at risk#✓fully proved

The number of group-1 subjects at risk at the time of subject i.

noncomputable def numAtRiskIn (T : Fin n → ℝ) (g : Fin n → Bool) (i : Fin n) : ℕ :=
  #{l ∈ riskSet T i | g l = true}
Uses 1 · Used by 4

DefinitionGroup indicator covariate#✓fully proved

The group indicator zᵢ = 1 for group 1 (g i = true) and 0 otherwise.

def groupIndicator (g : Fin n → Bool) (i : Fin n) : ℝ := if g i = true then 1 else 0
Used by 3

DefinitionLog-rank numerator: observed minus expected events#✓fully proved

The log-rank numerator O - E: observed minus expected group-1 events, ∑_{i : δᵢ} (zᵢ - n₁(Tᵢ) / n(Tᵢ)).

noncomputable def observedMinusExpected (T : Fin n → ℝ) (δ : Fin n → Bool) (g : Fin n → Bool) :
    ℝ :=
  ∑ i with δ i = true, (groupIndicator g i - (numAtRiskIn T g i : ℝ) / numAtRisk T i)
Uses 3 · Used by 1

DefinitionBreslow information#✓fully proved

The Breslow (Cox) information ∑_{i : δᵢ} n₁ n₀ / n² at the risk sets of the events. This is -ℓ''(0) for a group indicator, not the tied log-rank variance: for one tied risk set with n = 4, n₁ = 2 and d = 2 events it gives 1 / 2, while the hypergeometric log-rank variance is 1 / 3. It equals the log-rank variance only when the event times are distinct (so each risk set contributes at most one event).

noncomputable def breslowInformation (T : Fin n → ℝ) (δ : Fin n → Bool) (g : Fin n → Bool) :
    ℝ :=
  ∑ i with δ i = true,
    (numAtRiskIn T g i : ℝ) * ((numAtRisk T i : ℝ) - numAtRiskIn T g i) / (numAtRisk T i) ^ 2
Uses 2 · Used by 1

TheoremThe log-rank statistic is the Cox score at β = 0#✓fully proved

ℓ'(0) = O - E.

theorem coxScore_zero (T : Fin n → ℝ) (δ : Fin n → Bool) (g : Fin n → Bool) :
    coxScore T δ (groupIndicator g) 0 = observedMinusExpected T δ g
Uses 7

TheoremThe Cox information at β = 0 is the Breslow information#✓fully proved

The Cox information at β = 0 is the Breslow information ∑ n₁ n₀ / n² (not the tied log-rank variance; see breslowInformation).

theorem coxInformation_zero (T : Fin n → ℝ) (δ : Fin n → Bool) (g : Fin n → Bool) :
    coxInformation T δ (groupIndicator g) 0 = breslowInformation T δ g
Uses 9
21 fully proved

The dependency explorer needs JavaScript and its graph data.

Download the complete graph data.