Stat.Recurrent­Event.Counting­Process

This directory develops finite iid right-censoring records, compensated censor counts, predictable-integral isometries, and zero-safe Nelson–Aalen squared-risk identities.

Finite­Jump 50 core · 60 supporting · 23 submodules This directory provides a finite-horizon, finite-sample compensated-integral isometry for simple recurrent-event counting processes.
Basic 14 core · 0 supporting Finite samples of latent failure and censor times, their observable counting processes, and pathwise integrals against the censor compensator.

Finite samples of latent failure and censor times, their observable counting processes, and pathwise integrals against the censor compensator. Times live in ℝ. The convention at a simultaneous event assigns the event to failure; an absolutely continuous censor law has zero probability of such ties under independent failure and censor times.

abbrev Sample reviewed
Causalean.Stat.RecurrentEvent.CountingProcess

A finite sample of n subjects records one real failure time and one real censor time for each subject.

Definition (Lean source)
n :
ℕ
Sample n :
Type
Fin n → ℝ × ℝ
Causalean.Stat.RecurrentEvent.CountingProcess.Sample · Causalean/Stat/RecurrentEvent/CountingProcess/Basic.lean:21
def sampleLaw reviewed
Causalean.Stat.RecurrentEvent.CountingProcess

The sample law of n subjects makes the subjects independent, each with a failure time drawn from the failure-time law and an independent censor time drawn from the censor-time law.

Definition (Lean source)
n :
ℕ
failureLaw censorLaw :
sampleLaw n failureLaw censorLaw :
Measure.pi (fun _ : Fin n => failureLaw.prod censorLaw)
Causalean.Stat.RecurrentEvent.CountingProcess.sampleLaw · Causalean/Stat/RecurrentEvent/CountingProcess/Basic.lean:25 · uses Sample
def NonnegativeTimeLaw reviewed
Causalean.Stat.RecurrentEvent.CountingProcess

A law on event times is a nonnegative time law when it is a probability measure that puts all its mass on nonnegative times.

Definition (Lean source)
law :
NonnegativeTimeLaw law :
Prop
clause 1
law univ = 1
clause 2
law (Ici 0) = 1
Causalean.Stat.RecurrentEvent.CountingProcess.NonnegativeTimeLaw · Causalean/Stat/RecurrentEvent/CountingProcess/Basic.lean:31
def censorCount reviewed
Causalean.Stat.RecurrentEvent.CountingProcess

The observed censor-event count of subject i by time u in a sample is one exactly when that subject's censoring occurs by u and strictly before its failure, and zero otherwise.

Definition (Lean source)
n :
ℕ
i :
Fin n
u :
ℝ
x :
censorCount i u x :
ℝ
if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then 1 else 0
Causalean.Stat.RecurrentEvent.CountingProcess.censorCount · Causalean/Stat/RecurrentEvent/CountingProcess/Basic.lean:36 · uses Sample
def failureCount reviewed
Causalean.Stat.RecurrentEvent.CountingProcess

The observed failure-event count of subject i by time u in a sample is one exactly when that subject's failure occurs by u and no later than its censoring, and zero otherwise.

Definition (Lean source)
n :
ℕ
i :
Fin n
u :
ℝ
x :
failureCount i u x :
ℝ
if (x i).1 ≤ u ∧ (x i).1 ≤ (x i).2 then 1 else 0
Causalean.Stat.RecurrentEvent.CountingProcess.failureCount · Causalean/Stat/RecurrentEvent/CountingProcess/Basic.lean:42 · uses Sample
def riskIndicator reviewed
Causalean.Stat.RecurrentEvent.CountingProcess

The left-continuous at-risk indicator of subject i at time s in a sample is one when s is nonnegative and the subject has had neither failure nor censoring strictly before s, and zero otherwise.

Definition (Lean source)
n :
ℕ
i :
Fin n
s :
ℝ
x :
riskIndicator i s x :
ℝ
if 0 ≤ s ∧ s ≤ (x i).1 ∧ s ≤ (x i).2 then 1 else 0
Causalean.Stat.RecurrentEvent.CountingProcess.riskIndicator · Causalean/Stat/RecurrentEvent/CountingProcess/Basic.lean:48 · uses Sample
def riskSet reviewed
Causalean.Stat.RecurrentEvent.CountingProcess

The risk-set size at time s in a sample is the number of subjects at risk at s: zero when s is negative, and otherwise the number of subjects with neither failure nor censoring strictly before s.

Definition (Lean source)
n :
ℕ
s :
ℝ
x :
riskSet s x :
ℕ
∑ i : Fin n, if 0 ≤ s ∧ s ≤ (x i).1 ∧ s ≤ (x i).2 then 1 else 0
Causalean.Stat.RecurrentEvent.CountingProcess.riskSet · Causalean/Stat/RecurrentEvent/CountingProcess/Basic.lean:54 · uses Sample
def LeftPredictable reviewed
Causalean.Stat.RecurrentEvent.CountingProcess

A time-indexed process on samples is left predictable when its value at each time is the same for any two samples whose observed censor and failure counts agree for every subject at all strictly earlier times.

Definition (Lean source)
n :
ℕ
H :
ℝ → Sample n → ℝ
s x y :
(∀ (i : Fin n) t, t < s → censorCount i t x = censorCount i t y ∧ failureCount i t x = failureCount i t y)
LeftPredictable H :
Prop
H s x = H s y
Causalean.Stat.RecurrentEvent.CountingProcess.LeftPredictable · Causalean/Stat/RecurrentEvent/CountingProcess/Basic.lean:60 · uses Sample
def HasCensorHazard reviewed
Causalean.Stat.RecurrentEvent.CountingProcess

A censor-time law has the given censor hazard when it is a probability law on nonnegative times and the hazard function is measurable, nonnegative, integrable on every interval from 0 to u, and the law has Lebesgue density equal at each time s to the hazard at s times the probability of censoring at or after s.

Definition (Lean source)
censorLaw :
hazard :
ℝ → ℝ
HasCensorHazard censorLaw hazard :
Prop
clause 1
clause 2
Measurable hazard
clause 3
s :
0 ≤ hazard s
clause 4
u :
Integrable hazard (volume.restrict (Icc 0 u))
clause 5
censorLaw
= (volume : Measure ℝ).withDensity (fun s => ofReal (hazard s * (censorLaw (Ici s)).toReal))
Causalean.Stat.RecurrentEvent.CountingProcess.HasCensorHazard · Causalean/Stat/RecurrentEvent/CountingProcess/Basic.lean:70
def compensatedCensor reviewed
Causalean.Stat.RecurrentEvent.CountingProcess

The compensated censor count of subject i by time u in a sample is the observed censor-event count by u minus the integral over times from 0 to u of the censor hazard times the subject's at-risk indicator.

Definition (Lean source)
n :
ℕ
hazard :
ℝ → ℝ
i :
Fin n
u :
ℝ
x :
compensatedCensor hazard i u x :
ℝ
censorCount i u x - ∫ s in Icc 0 u, hazard s * riskIndicator i s x ∂volume
Causalean.Stat.RecurrentEvent.CountingProcess.compensatedCensor · Causalean/Stat/RecurrentEvent/CountingProcess/Basic.lean:84 · uses Sample
def subjectIntegral reviewed
Causalean.Stat.RecurrentEvent.CountingProcess

The pathwise integral of a process against the compensated censor count of subject i up to time u in a sample is the process's value at the subject's censor time when an observed censor event occurs by u (zero otherwise), minus the integral over times from 0 to u of the process times the censor hazard times the subject's at-risk indicator.

Definition (Lean source)
n :
ℕ
hazard :
ℝ → ℝ
H :
ℝ → Sample n → ℝ
i :
Fin n
u :
ℝ
x :
subjectIntegral hazard H i u x :
ℝ
(if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0)
- ∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume
Causalean.Stat.RecurrentEvent.CountingProcess.subjectIntegral · Causalean/Stat/RecurrentEvent/CountingProcess/Basic.lean:91 · uses Sample
def aggregateIntegral reviewed
Causalean.Stat.RecurrentEvent.CountingProcess

The pathwise integral of a process against the sum of all subjects' compensated censor counts, with censor hazard, up to time u in a sample, is the sum over subjects of the subjectwise integrals.

Definition (Lean source)
n :
ℕ
hazard :
ℝ → ℝ
H :
ℝ → Sample n → ℝ
u :
ℝ
x :
aggregateIntegral hazard H u x :
ℝ
∑ i : Fin n, subjectIntegral hazard H i u x
Causalean.Stat.RecurrentEvent.CountingProcess.aggregateIntegral · Causalean/Stat/RecurrentEvent/CountingProcess/Basic.lean:102 · uses Sample
def inverseRisk reviewed
Causalean.Stat.RecurrentEvent.CountingProcess

The zero-safe inverse risk-set size, the Nelson–Aalen integrand, at time s in a sample is zero when the risk set is empty and the reciprocal of the risk-set size otherwise.

Definition (Lean source)
n :
ℕ
s :
ℝ
x :
inverseRisk s x :
ℝ
if riskSet s x = 0 then 0 else 1 / (riskSet s x : ℝ)
Causalean.Stat.RecurrentEvent.CountingProcess.inverseRisk · Causalean/Stat/RecurrentEvent/CountingProcess/Basic.lean:109 · uses Sample
def nelsonAalenError reviewed
Causalean.Stat.RecurrentEvent.CountingProcess

The compensated Nelson–Aalen estimation error up to time u in a sample is the integral of the zero-safe inverse risk-set size against the sum of all compensated censor counts with censor hazard.

Definition (Lean source)
n :
ℕ
hazard :
ℝ → ℝ
u :
ℝ
x :
nelsonAalenError hazard u x :
ℝ
aggregateIntegral hazard inverseRisk u x
Causalean.Stat.RecurrentEvent.CountingProcess.nelsonAalenError · Causalean/Stat/RecurrentEvent/CountingProcess/Basic.lean:115 · uses Sample
Subject­Moments­Basic 3 core · 4 supporting Second-moment building blocks for predictable pathwise integrals against compensated censor-event counts: the quadratic-energy definitions, the expected squared event payoff as the expected at-risk hazard integral of the ★ subject_event_square_expectation

Second-moment building blocks for predictable pathwise integrals against compensated censor-event counts: the quadratic-energy definitions, the expected squared event payoff as the expected at-risk hazard integral of the squared payoff, and energy bounds for the mixed terms. The subjectwise isometry and the zero cross moment of different subjects are proved in the SubjectIsometry and Isometry modules.

The counting-process and stochastic-integration framework follows Andersen, Borgan, Gill, and Keiding (1993), Chapter II. The proofs below establish the finite-sample expectation identities directly from the iid product law.

def predictableEnergy reviewed
Causalean.Stat.RecurrentEvent.CountingProcess

The predictable quadratic energy of an integrand up to time u in a sample is the integral over times from 0 to u of the squared integrand times the censor hazard times the number of subjects at risk.

Definition (Lean source)
n :
ℕ
hazard :
ℝ → ℝ
H :
ℝ → Sample n → ℝ
u :
ℝ
x :
predictableEnergy hazard H u x :
ℝ
∫ s in Icc 0 u, (H s x) ^ 2 * hazard s * (∑ i : Fin n, riskIndicator i s x) ∂volume
Causalean.Stat.RecurrentEvent.CountingProcess.predictableEnergy · Causalean/Stat/RecurrentEvent/CountingProcess/SubjectMomentsBasic.lean:29 · uses Sample
def QuadraticEnergyFinite reviewed
Causalean.Stat.RecurrentEvent.CountingProcess

The expected quadratic energy is finite for an integrand up to time u, with censor hazard, when the sample is drawn from the independent product law with failure-time law and censor-time law: the expected extended integral over times from 0 to u of the squared integrand times the hazard times the number of subjects at risk is not infinite.

Definition (Lean source)
n :
ℕ
failureLaw censorLaw :
hazard :
ℝ → ℝ
H :
ℝ → Sample n → ℝ
u :
ℝ
QuadraticEnergyFinite failureLaw censorLaw hazard H u :
Prop
(∫⁻ x : Sample n, ∫⁻ s in Icc 0 u, ofReal ((H s x) ^ 2 * hazard s * (∑ i : Fin n, riskIndicator i s x)) ∂volume ∂sampleLaw n failureLaw censorLaw)
≠ ⊤
Causalean.Stat.RecurrentEvent.CountingProcess.QuadraticEnergyFinite · Causalean/Stat/RecurrentEvent/CountingProcess/SubjectMomentsBasic.lean:37 · uses Sample
theorem subject_event_square_expectation reviewed
Causalean.Stat.RecurrentEvent.CountingProcess

Suppose subjects are drawn independently with failure times following a nonnegative time law and independent censor times whose law has the given censor hazard, and let the payoff process be left predictable and jointly measurable in time and sample. For a horizon u and finite expected quadratic energy, the expected squared payoff at subject i's observed censor event by u equals the expected integral from 0 to u of the squared payoff times the hazard times the subject's at-risk indicator.

Formal statement
n :
ℕ
failureLaw censorLaw :
hazard :
ℝ → ℝ
hFailure :
hHazard :
HasCensorHazard censorLaw hazard
H :
ℝ → Sample n → ℝ
hPredictable :
LeftPredictable H
hMeasurable :
Measurable (fun p : ℝ × Sample n => H p.1 p.2)
i :
Fin n
u :
ℝ
hQuadratic :
QuadraticEnergyFinite failureLaw censorLaw hazard H u
(∫ x : Sample n, (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) ^ 2 ∂sampleLaw n failureLaw censorLaw)
= ∫ x : Sample n, (∫ s in Icc 0 u, (H s x) ^ 2 * hazard s * riskIndicator i s x ∂volume) ∂sampleLaw n failureLaw censorLaw
Proof (Lean source)
theorem subject_event_square_expectation {n : ℕ} (failureLaw censorLaw : Measure ℝ) (hazard : ℝ → ℝ) (hFailure : NonnegativeTimeLaw failureLaw) (hHazard : HasCensorHazard censorLaw hazard) (H : ℝ → Sample n → ℝ) (hPredictable : LeftPredictable H) (hMeasurable : Measurable (fun p : ℝ × Sample n => H p.1 p.2)) (i : Fin n) (u : ℝ) (hQuadratic : QuadraticEnergyFinite failureLaw censorLaw hazard H u) : (∫ x : Sample n, (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) ^ 2 ∂sampleLaw n failureLaw censorLaw) = ∫ x : Sample n, (∫ s in Icc 0 u, (H s x) ^ 2 * hazard s * riskIndicator i s x ∂volume) ∂sampleLaw n failureLaw censorLaw := by classical let μ := sampleLaw n failureLaw censorLaw let Q : ℝ → Sample n → ℝ := fun s x => (H s x) ^ 2 have hQpred : LeftPredictable Q := by intro s x y hxy simpa [Q] using congrArg (fun z : ℝ => z ^ 2) (hPredictable s x y hxy) have hQmeas : Measurable (fun p : ℝ × Sample n => Q p.1 p.2) := by exact hMeasurable.pow_const 2 have hQnonneg : ∀ s x, 0 ≤ Q s x := fun s x => sq_nonneg _ have hlin := predictable_censor_compensator_lintegral failureLaw censorLaw hazard hFailure hHazard Q hQpred hQmeas hQnonneg i u have hfinite : (∫⁻ x : Sample n, ∫⁻ s in Icc 0 u, ofReal (Q s x * hazard s * riskIndicator i s x) ∂volume ∂μ) ≠ ⊤ := by have hle : (∫⁻ x : Sample n, ∫⁻ s in Icc 0 u, ofReal (Q s x * hazard s * riskIndicator i s x) ∂volume ∂μ) ≤ ∫⁻ x : Sample n, ∫⁻ s in Icc 0 u, ofReal ((H s x) ^ 2 * hazard s * (∑ j : Fin n, riskIndicator j s x)) ∂volume ∂μ := by apply lintegral_mono intro x apply lintegral_mono intro s apply ENNReal.ofReal_le_ofReal dsimp [Q] apply mul_le_mul_of_nonneg_left · exact Finset.single_le_sum (f := fun j : Fin n => riskIndicator j s x) (fun j hj => by unfold riskIndicator split_ifs <;> norm_num) (Finset.mem_univ i) · exact mul_nonneg (sq_nonneg _) (hHazard.2.2.1 s) exact ne_top_of_le_ne_top hQuadratic hle have hEventInt : Integrable (fun x : Sample n => if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then Q (x i).2 x else 0) μ := by have hm : Measurable (fun x : Sample n => if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then Q (x i).2 x else 0) := by have hc : Measurable (fun x : Sample n => (x i).2) := by fun_prop have hf : Measurable (fun x : Sample n => (x i).1) := by fun_prop exact (hQmeas.comp (hc.prodMk measurable_id)).ite ((measurableSet_le hc measurable_const).inter (measurableSet_lt hc hf)) measurable_const apply (lintegral_ofReal_ne_top_iff_integrable hm.aestronglyMeasurable (by filter_upwards [] with x split_ifs <;> positivity)).1 rw [hlin] exact hfinite have hcomp := predictable_censor_compensator_nonnegative failureLaw censorLaw hazard hFailure hHazard Q hQpred hQmeas hQnonneg i u hEventInt convert hcomp using 1 <;> simp only [Q, ite_pow, zero_pow (by decide : (2 : ℕ) ≠ 0)]
4 supporting declarations (lemmas, instances)
  • cumulative_hazard_square theorem — For a nonnegative horizon u and a sample path on which subject i's at-risk payoff, weighted by the censor hazard, is integrable from 0 to u, the square of the cumulative payoff up to u equals the integral of twice the accumulated payoff times its current rate.
    n :
    ℕ
    hazard :
    ℝ → ℝ
    H :
    ℝ → Sample n → ℝ
    i :
    Fin n
    u :
    ℝ
    hu :
    0 ≤ u
    x :
    hPath :
    Integrable (fun s => H s x * hazard s * riskIndicator i s x) (volume.restrict (Icc 0 u))
    (∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume) ^ 2
    = ∫ s in Icc 0 u, 2 * (∫ t in Icc 0 s, H t x * hazard t * riskIndicator i t x ∂volume) * (H s x * hazard s * riskIndicator i s x) ∂volume
    Proof (Lean source)
    theorem cumulative_hazard_square {n : ℕ} (hazard : ℝ → ℝ) (H : ℝ → Sample n → ℝ) (i : Fin n) (u : ℝ) (hu : 0 ≤ u) (x : Sample n) (hPath : Integrable (fun s => H s x * hazard s * riskIndicator i s x) (volume.restrict (Icc 0 u))) : (∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume) ^ 2 = ∫ s in Icc 0 u, 2 * (∫ t in Icc 0 s, H t x * hazard t * riskIndicator i t x ∂volume) * (H s x * hazard s * riskIndicator i s x) ∂volume := by exact integral_prefix_square (fun s => H s x * hazard s * riskIndicator i s x) u hu hPath
    Causalean.Stat.RecurrentEvent.CountingProcess.cumulative_hazard_square · Causalean/Stat/RecurrentEvent/CountingProcess/SubjectMomentsBasic.lean:53
  • subject_hazard_path_integrable_ae theorem — Suppose subjects are drawn independently with failure times following a given law and independent censor times whose law has the given censor hazard, and let the payoff process be jointly measurable in time and sample. For a horizon u and finite expected quadratic energy, almost every sample path has a hazard-weighted at-risk payoff for subject i that is integrable from 0 to u.
    n :
    ℕ
    failureLaw censorLaw :
    hazard :
    ℝ → ℝ
    hHazard :
    HasCensorHazard censorLaw hazard
    H :
    ℝ → Sample n → ℝ
    hMeasurable :
    Measurable (fun p : ℝ × Sample n => H p.1 p.2)
    i :
    Fin n
    u :
    ℝ
    hQuadratic :
    QuadraticEnergyFinite failureLaw censorLaw hazard H u
    ∀ᵐ x ∂sampleLaw n failureLaw censorLaw, Integrable (fun s => H s x * hazard s * riskIndicator i s x) (volume.restrict (Icc 0 u))
    Proof (Lean source)
    theorem subject_hazard_path_integrable_ae {n : ℕ} (failureLaw censorLaw : Measure ℝ) (hazard : ℝ → ℝ) (hHazard : HasCensorHazard censorLaw hazard) (H : ℝ → Sample n → ℝ) (hMeasurable : Measurable (fun p : ℝ × Sample n => H p.1 p.2)) (i : Fin n) (u : ℝ) (hQuadratic : QuadraticEnergyFinite failureLaw censorLaw hazard H u) : ∀ᵐ x ∂sampleLaw n failureLaw censorLaw, Integrable (fun s => H s x * hazard s * riskIndicator i s x) (volume.restrict (Icc 0 u)) := by /- Tonelli gives finite quadratic energy on almost every path. The pointwise Young bound |H| ≤ H² + 1 then controls the L1 payoff by that energy and the finite deterministic hazard mass. -/ classical let μ := sampleLaw n failureLaw censorLaw let ν := (volume : Measure ℝ).restrict (Icc 0 u) let e : Sample n → ℝ → ℝ := fun x s => (H s x) ^ 2 * hazard s * (∑ j : Fin n, riskIndicator j s x) have he_meas : Measurable (fun p : Sample n × ℝ => e p.1 p.2) := by have hrisk (j : Fin n) : Measurable (fun p : Sample n × ℝ => riskIndicator j p.2 p.1) := by unfold riskIndicator have hf : Measurable (fun p : Sample n × ℝ => (p.1 j).1) := by fun_prop have hc : Measurable (fun p : Sample n × ℝ => (p.1 j).2) := by fun_prop have hs : MeasurableSet {p : Sample n × ℝ | 0 ≤ p.2 ∧ p.2 ≤ (p.1 j).1 ∧ p.2 ≤ (p.1 j).2} := by simpa only [Set.ofPred_and, Set.inter_assoc, id_eq] using (((show MeasurableSet {p : Sample n × ℝ | (0 : ℝ) ≤ p.2} from measurableSet_le measurable_const measurable_snd).inter (measurableSet_le measurable_snd hf)).inter (measurableSet_le measurable_snd hc)) exact measurable_const.ite hs measurable_const exact (((hMeasurable.comp (measurable_snd.prodMk measurable_fst)).pow_const 2).mul (hHazard.2.1.comp measurable_snd)).mul (Finset.measurable_fun_sum _ (fun j _ => hrisk j)) have he_nonneg (x : Sample n) (s : ℝ) : 0 ≤ e x s := by dsimp [e] apply mul_nonneg (mul_nonneg (sq_nonneg _) (hHazard.2.2.1 s)) exact Finset.sum_nonneg (fun j _ => by unfold riskIndicator; split_ifs <;> norm_num) have he_inner_meas : Measurable (fun x => ∫⁻ s, ofReal (e x s) ∂ν) := he_meas.ennreal_ofReal.lintegral_prod_right' have he_ae : ∀ᵐ x ∂μ, Integrable (e x) ν := by have hfinite : (∫⁻ x, ∫⁻ s, ofReal (e x s) ∂ν ∂μ) ≠ ⊤ := hQuadratic filter_upwards [ae_lt_top he_inner_meas hfinite] with x hx exact (lintegral_ofReal_ne_top_iff_integrable (he_meas.comp (measurable_const.prodMk measurable_id)).aestronglyMeasurable (Filter.Eventually.of_forall (he_nonneg x))).1 hx.ne filter_upwards [he_ae] with x hx have hf_meas : Measurable (fun s => H s x * hazard s * riskIndicator i s x) := by have hrisk : Measurable (fun s : ℝ => riskIndicator i s x) := by unfold riskIndicator have hs : MeasurableSet {s : ℝ | 0 ≤ s ∧ s ≤ (x i).1 ∧ s ≤ (x i).2} := by simpa only [Set.ofPred_and, Set.inter_assoc, id_eq] using (((show MeasurableSet {s : ℝ | (0 : ℝ) ≤ s} from measurableSet_le measurable_const measurable_id).inter (measurableSet_le measurable_id measurable_const)).inter (measurableSet_le measurable_id measurable_const)) exact measurable_const.ite hs measurable_const exact ((hMeasurable.comp (measurable_id.prodMk measurable_const)).mul hHazard.2.1).mul hrisk have hbound (s : ℝ) : ‖H s x * hazard s * riskIndicator i s x‖ ≤ e x s + hazard s := by have hr : 0 ≤ riskIndicator i s x ∧ riskIndicator i s x ≤ 1 := by unfold riskIndicator split_ifs <;> norm_num have hsum : riskIndicator i s x ≤ ∑ j : Fin n, riskIndicator j s x := Finset.single_le_sum (f := fun j : Fin n => riskIndicator j s x) (fun j hj => by unfold riskIndicator; split_ifs <;> norm_num) (Finset.mem_univ i) have hH : |H s x| ≤ (H s x) ^ 2 + 1 := by nlinarith [sq_nonneg (|H s x| - 1), sq_abs (H s x)] rw [Real.norm_eq_abs, abs_mul, abs_mul, abs_of_nonneg (hHazard.2.2.1 s), abs_of_nonneg hr.1] calc |H s x| * hazard s * riskIndicator i s x ≤ ((H s x) ^ 2 + 1) * hazard s * riskIndicator i s x := by exact mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right hH (hHazard.2.2.1 s)) hr.1 _ = (H s x) ^ 2 * hazard s * riskIndicator i s x + hazard s * riskIndicator i s x := by ring _ ≤ e x s + hazard s := by dsimp [e] exact add_le_add (mul_le_mul_of_nonneg_left hsum (mul_nonneg (sq_nonneg _) (hHazard.2.2.1 s))) (mul_le_of_le_one_right (hHazard.2.2.1 s) hr.2) exact (hx.add (hHazard.2.2.2.1 u)).mono' hf_meas.aestronglyMeasurable (Filter.Eventually.of_forall hbound)
    Causalean.Stat.RecurrentEvent.CountingProcess.subject_hazard_path_integrable_ae · Causalean/Stat/RecurrentEvent/CountingProcess/SubjectMomentsBasic.lean:143
  • subject_absolute_payoff_square_le_energy theorem — If the censor hazard is nonnegative and integrable from 0 to u, and on a sample path subject i's hazard-weighted squared at-risk payoff is integrable from 0 to u, then the square of the integral of the absolute hazard-weighted payoff is at most the total hazard mass from 0 to u times the subject's quadratic hazard energy.
    n :
    ℕ
    hazard :
    ℝ → ℝ
    hHazardNonneg :
    ∀ s, 0 ≤ hazard s
    H :
    ℝ → Sample n → ℝ
    i :
    Fin n
    u :
    ℝ
    x :
    hHazardInt :
    Integrable hazard (volume.restrict (Icc 0 u))
    hEnergyPath :
    Integrable (fun s => (H s x) ^ 2 * hazard s * riskIndicator i s x) (volume.restrict (Icc 0 u))
    (∫ s in Icc 0 u, |H s x * hazard s * riskIndicator i s x| ∂volume) ^ 2
    ≤ (∫ s in Icc 0 u, hazard s ∂volume) * (∫ s in Icc 0 u, (H s x) ^ 2 * hazard s * riskIndicator i s x ∂volume)
    Proof (Lean source)
    theorem subject_absolute_payoff_square_le_energy {n : ℕ} (hazard : ℝ → ℝ) (hHazardNonneg : ∀ s, 0 ≤ hazard s) (H : ℝ → Sample n → ℝ) (i : Fin n) (u : ℝ) (x : Sample n) (hHazardInt : Integrable hazard (volume.restrict (Icc 0 u))) (hEnergyPath : Integrable (fun s => (H s x) ^ 2 * hazard s * riskIndicator i s x) (volume.restrict (Icc 0 u))) : (∫ s in Icc 0 u, |H s x * hazard s * riskIndicator i s x| ∂volume) ^ 2 ≤ (∫ s in Icc 0 u, hazard s ∂volume) * (∫ s in Icc 0 u, (H s x) ^ 2 * hazard s * riskIndicator i s x ∂volume) := by /- Apply Hölder to the square roots of the hazard and quadratic energy densities. The at-risk indicator is idempotent, giving the payoff. -/ let μ := volume.restrict (Icc 0 u) let e : ℝ → ℝ := fun s => (H s x) ^ 2 * hazard s * riskIndicator i s x have he_nonneg (s : ℝ) : 0 ≤ e s := by exact mul_nonneg (mul_nonneg (sq_nonneg _) (hHazardNonneg s)) (by simp [riskIndicator]; split_ifs <;> norm_num) have hf_meas : AEStronglyMeasurable (fun s => sqrt (hazard s)) μ := hHazardInt.aestronglyMeasurable.aemeasurable.sqrt.aestronglyMeasurable have hg_meas : AEStronglyMeasurable (fun s => sqrt (e s)) μ := by have h := (show Integrable e μ from hEnergyPath).aestronglyMeasurable exact h.aemeasurable.sqrt.aestronglyMeasurable have hf_lp : MemLp (fun s => sqrt (hazard s)) 2 μ := by have h : MemLp (fun s => ‖Real.sqrt (hazard s)‖ ^ (2 : ENNReal).toReal) 1 μ := by apply memLp_one_iff_integrable.mpr convert hHazardInt using 1 funext s simp [Real.norm_eq_abs, abs_of_nonneg (Real.sqrt_nonneg _), Real.sq_sqrt (hHazardNonneg s)] have hdiv : (2 / 2 : ENNReal) = 1 := ENNReal.div_self (by norm_num) (by norm_num) exact (memLp_norm_rpow_iff (p := 2) (q := 2) hf_meas (by norm_num) (by norm_num)).mp (by simpa only [hdiv] using h) have hg_lp : MemLp (fun s => sqrt (e s)) 2 μ := by have h : MemLp (fun s => ‖Real.sqrt (e s)‖ ^ (2 : ENNReal).toReal) 1 μ := by apply memLp_one_iff_integrable.mpr convert hEnergyPath using 1 funext s simp [e, Real.norm_eq_abs, abs_of_nonneg (Real.sqrt_nonneg _), Real.sq_sqrt (he_nonneg s)] have hdiv : (2 / 2 : ENNReal) = 1 := ENNReal.div_self (by norm_num) (by norm_num) exact (memLp_norm_rpow_iff (p := 2) (q := 2) hg_meas (by norm_num) (by norm_num)).mp (by simpa only [hdiv] using h) have hpoint (s : ℝ) : sqrt (hazard s) * sqrt (e s) = |H s x * hazard s * riskIndicator i s x| := by calc sqrt (hazard s) * sqrt (e s) = sqrt (hazard s * e s) := (Real.sqrt_mul (hHazardNonneg s) _).symm _ = sqrt ((H s x * hazard s * riskIndicator i s x) ^ 2) := by congr 1 dsimp [e, riskIndicator] split_ifs <;> ring _ = _ := Real.sqrt_sq_eq_abs _ have hfsq : (∫ s, (sqrt (hazard s)) ^ (2 : ℝ) ∂μ) = ∫ s, hazard s ∂μ := by apply integral_congr_ae exact Filter.Eventually.of_forall (fun s => by simpa using Real.sq_sqrt (hHazardNonneg s)) have hgsq : (∫ s, (sqrt (e s)) ^ (2 : ℝ) ∂μ) = ∫ s, e s ∂μ := by apply integral_congr_ae exact Filter.Eventually.of_forall (fun s => by simpa using Real.sq_sqrt (he_nonneg s)) have hholder : (∫ s in Icc 0 u, |H s x * hazard s * riskIndicator i s x| ∂volume) ≤ sqrt (∫ s in Icc 0 u, hazard s ∂volume) * sqrt (∫ s in Icc 0 u, e s ∂volume) := by have hholder0 := integral_mul_le_Lp_mul_Lq_of_nonneg (p := 2) (q := 2) (f := fun s => sqrt (hazard s)) (g := fun s => sqrt (e s)) (Real.holderConjugate_iff.mpr ⟨by norm_num, by norm_num⟩) (Filter.Eventually.of_forall (fun s => Real.sqrt_nonneg _)) (Filter.Eventually.of_forall (fun s => Real.sqrt_nonneg _)) (by simpa only [ENNReal.ofReal_ofNat] using hf_lp) (by simpa only [ENNReal.ofReal_ofNat] using hg_lp) calc _ = ∫ s, sqrt (hazard s) * sqrt (e s) ∂μ := by exact integral_congr_ae (Filter.Eventually.of_forall (fun s => (hpoint s).symm)) _ ≤ _ := by rw [hfsq, hgsq] at hholder0 simpa only [Real.sqrt_eq_rpow] using hholder0 have hB : 0 ≤ ∫ s in Icc 0 u, hazard s ∂volume := integral_nonneg (fun s => hHazardNonneg s) have hC : 0 ≤ ∫ s in Icc 0 u, e s ∂volume := integral_nonneg he_nonneg have hA : 0 ≤ ∫ s in Icc 0 u, |H s x * hazard s * riskIndicator i s x| ∂volume := integral_nonneg (fun s => abs_nonneg _) have hsq : (sqrt (∫ s in Icc 0 u, hazard s ∂volume) * sqrt (∫ s in Icc 0 u, e s ∂volume)) ^ 2 = (∫ s in Icc 0 u, hazard s ∂volume) * (∫ s in Icc 0 u, e s ∂volume) := by rw [mul_pow, Real.sq_sqrt hB, Real.sq_sqrt hC] dsimp [e] at hsq ⊢ nlinarith [Real.sqrt_nonneg (∫ s in Icc 0 u, hazard s ∂volume), Real.sqrt_nonneg (∫ s in Icc 0 u, e s ∂volume)]
    Causalean.Stat.RecurrentEvent.CountingProcess.subject_absolute_payoff_square_le_energy · Causalean/Stat/RecurrentEvent/CountingProcess/SubjectMomentsBasic.lean:240
  • subject_prefix_mixed_abs_integral_le_energy theorem — If the censor hazard is nonnegative, the horizon u is nonnegative, the hazard is integrable from 0 to u, and on a sample path both subject i's hazard-weighted at-risk payoff and its squared-payoff analogue are integrable from 0 to u, then the integral of the absolute value of the accumulated payoff times the current payoff is at most the total hazard mass from 0 to u times the subject's quadratic hazard energy.
    n :
    ℕ
    hazard :
    ℝ → ℝ
    hHazardNonneg :
    ∀ s, 0 ≤ hazard s
    H :
    ℝ → Sample n → ℝ
    i :
    Fin n
    u :
    ℝ
    hu :
    0 ≤ u
    x :
    hHazardInt :
    Integrable hazard (volume.restrict (Icc 0 u))
    hPath :
    Integrable (fun s => H s x * hazard s * riskIndicator i s x) (volume.restrict (Icc 0 u))
    hEnergyPath :
    Integrable (fun s => (H s x) ^ 2 * hazard s * riskIndicator i s x) (volume.restrict (Icc 0 u))
    (∫ s in Icc 0 u, |(∫ t in Icc 0 s, H t x * hazard t * riskIndicator i t x ∂volume) * (H s x * hazard s * riskIndicator i s x)| ∂volume)
    ≤ (∫ s in Icc 0 u, hazard s ∂volume) * (∫ s in Icc 0 u, (H s x) ^ 2 * hazard s * riskIndicator i s x ∂volume)
    Proof (Lean source)
    theorem subject_prefix_mixed_abs_integral_le_energy {n : ℕ} (hazard : ℝ → ℝ) (hHazardNonneg : ∀ s, 0 ≤ hazard s) (H : ℝ → Sample n → ℝ) (i : Fin n) (u : ℝ) (hu : 0 ≤ u) (x : Sample n) (hHazardInt : Integrable hazard (volume.restrict (Icc 0 u))) (hPath : Integrable (fun s => H s x * hazard s * riskIndicator i s x) (volume.restrict (Icc 0 u))) (hEnergyPath : Integrable (fun s => (H s x) ^ 2 * hazard s * riskIndicator i s x) (volume.restrict (Icc 0 u))) : (∫ s in Icc 0 u, |(∫ t in Icc 0 s, H t x * hazard t * riskIndicator i t x ∂volume) * (H s x * hazard s * riskIndicator i s x)| ∂volume) ≤ (∫ s in Icc 0 u, hazard s ∂volume) * (∫ s in Icc 0 u, (H s x) ^ 2 * hazard s * riskIndicator i s x ∂volume) := by calc _ ≤ (∫ s in Icc 0 u, |H s x * hazard s * riskIndicator i s x| ∂volume) ^ 2 := integral_prefix_mul_abs_le_square (fun s => H s x * hazard s * riskIndicator i s x) u hu hPath _ ≤ _ := subject_absolute_payoff_square_le_energy hazard hHazardNonneg H i u x hHazardInt hEnergyPath
    Causalean.Stat.RecurrentEvent.CountingProcess.subject_prefix_mixed_abs_integral_le_energy · Causalean/Stat/RecurrentEvent/CountingProcess/SubjectMomentsBasic.lean:338
Cross­Prefix 2 core · 1 supporting The strict-past version of a subjectwise compensated censor integral. ★ subjectIntegralBefore_leftPredictable

The strict-past version of a subjectwise compensated censor integral. Its event term excludes a jump at the evaluation time, so it can be used as a predictable factor in cross-subject integration by parts.

def subjectIntegralBefore reviewed
Causalean.Stat.RecurrentEvent.CountingProcess

The strict-past compensated integral of a process for subject i before time s in a sample is the process's value at the subject's censor time when an observed censor event occurs strictly before s (zero otherwise), minus the integral over times from 0 to s of the process times the censor hazard times the subject's at-risk indicator.

Definition (Lean source)
n :
ℕ
hazard :
ℝ → ℝ
H :
ℝ → Sample n → ℝ
i :
Fin n
s :
ℝ
x :
subjectIntegralBefore hazard H i s x :
ℝ
(if (x i).2 < s ∧ (x i).2 < (x i).1 then H (x i).2 x else 0)
- ∫ t in Icc 0 s, H t x * hazard t * riskIndicator i t x ∂volume
Causalean.Stat.RecurrentEvent.CountingProcess.subjectIntegralBefore · Causalean/Stat/RecurrentEvent/CountingProcess/CrossPrefix.lean:17 · uses Sample
theorem subjectIntegralBefore_leftPredictable reviewed
Causalean.Stat.RecurrentEvent.CountingProcess

If the integrand is left predictable, then each subject's strict-past compensated integral, as a process in time, is left predictable, whatever the censor hazard used in its compensator.

Formal statement
n :
ℕ
hazard :
ℝ → ℝ
H :
ℝ → Sample n → ℝ
hPredictable :
LeftPredictable H
i :
Fin n
LeftPredictable (subjectIntegralBefore hazard H i)
Proof (Lean source)
theorem subjectIntegralBefore_leftPredictable {n : ℕ} (hazard : ℝ → ℝ) (H : ℝ → Sample n → ℝ) (hPredictable : LeftPredictable H) (i : Fin n) : LeftPredictable (subjectIntegralBefore hazard H i) := by have hRisk (t : ℝ) (z : Sample n) (hf : t ≠ (z i).1) (hc : t ≠ (z i).2) : riskIndicator i t z = if 0 ≤ t ∧ censorCount i t z = 0 ∧ failureCount i t z = 0 then 1 else 0 := by by_cases h0 : 0 ≤ t · rcases lt_or_gt_of_ne hf with htf | htf · rcases lt_or_gt_of_ne hc with htc | htc · simp [riskIndicator, censorCount, failureCount, h0, htf, htc, le_of_lt] · have hcf : (z i).2 < (z i).1 := lt_trans htc htf simp [riskIndicator, censorCount, failureCount, h0, htf, htc, hcf, le_of_lt] · rcases lt_or_gt_of_ne hc with htc | htc · have hfc : (z i).1 < (z i).2 := lt_trans htf htc simp [riskIndicator, censorCount, failureCount, h0, htf, htc, hfc, le_of_lt] · by_cases hfc : (z i).1 ≤ (z i).2 · simp [riskIndicator, censorCount, failureCount, h0, htf, htc, hfc, le_of_lt] · have hcf : (z i).2 < (z i).1 := lt_of_not_ge hfc simp [riskIndicator, censorCount, failureCount, h0, htf, htc, hcf, le_of_lt] · simp [riskIndicator, censorCount, failureCount, h0] have hNe (a : ℝ) : ∀ᵐ t ∂(volume : Measure ℝ), t ≠ a := by rw [ae_iff] simpa only [not_ne_iff, Set.ofPred_eq_eq_singleton] using (measure_singleton a : (volume : Measure ℝ) {a} = 0) intro s x y hHist have hInt : (∫ t in Icc 0 s, H t x * hazard t * riskIndicator i t x ∂volume) = ∫ t in Icc 0 s, H t y * hazard t * riskIndicator i t y ∂volume := by rw [integral_Icc_eq_integral_Ico, integral_Icc_eq_integral_Ico] apply integral_congr_ae have hxF := ae_restrict_of_ae (s := Ico 0 s) (hNe (x i).1) have hxC := ae_restrict_of_ae (s := Ico 0 s) (hNe (x i).2) have hyF := ae_restrict_of_ae (s := Ico 0 s) (hNe (y i).1) have hyC := ae_restrict_of_ae (s := Ico 0 s) (hNe (y i).2) have htMem : ∀ᵐ t ∂(volume : Measure ℝ).restrict (Ico 0 s), t ∈ Ico 0 s := ae_restrict_mem measurableSet_Ico filter_upwards [hxF, hxC, hyF, hyC, htMem] with t hxF hxC hyF hyC ht have hHistory := hHist i t ht.2 have hHt : H t x = H t y := hPredictable t x y (fun j u hu => hHist j u (lt_trans hu ht.2)) rw [hHt, hRisk t x hxF hxC, hRisk t y hyF hyC, hHistory.1, hHistory.2] have hEvent : (if (x i).2 < s ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) = (if (y i).2 < s ∧ (y i).2 < (y i).1 then H (y i).2 y else 0) := by by_cases hx : (x i).2 < s ∧ (x i).2 < (x i).1 · have hxc : censorCount i (x i).2 x = 1 := by simp [censorCount, hx.2] have hyc : censorCount i (x i).2 y = 1 := by rw [← (hHist i (x i).2 hx.1).1, hxc] have hyEvent : (y i).2 ≤ (x i).2 ∧ (y i).2 < (y i).1 := by by_contra hn simp [censorCount, hn] at hyc have hy : (y i).2 < s ∧ (y i).2 < (y i).1 := ⟨lt_of_le_of_lt hyEvent.1 hx.1, hyEvent.2⟩ have hyc' : censorCount i (y i).2 y = 1 := by simp [censorCount, hy.2] have hxc' : censorCount i (y i).2 x = 1 := by rw [(hHist i (y i).2 hy.1).1, hyc'] have hxy : (x i).2 ≤ (y i).2 := by by_contra hn have hn' : ¬ ((x i).2 ≤ (y i).2 ∧ (x i).2 < (x i).1) := by simp [hn] simp [censorCount, hn'] at hxc' have heq : (x i).2 = (y i).2 := le_antisymm hxy hyEvent.1 have hH : H (x i).2 x = H (y i).2 y := by rw [← heq] exact hPredictable (x i).2 x y (fun j u hu => hHist j u (lt_trans hu hx.1)) simp [hx, hy, hH] · have hyFalse : ¬ ((y i).2 < s ∧ (y i).2 < (y i).1) := by intro hy have hyc : censorCount i (y i).2 y = 1 := by simp [censorCount, hy.2] have hxc : censorCount i (y i).2 x = 1 := by rw [(hHist i (y i).2 hy.1).1, hyc] have hxEvent : (x i).2 ≤ (y i).2 ∧ (x i).2 < (x i).1 := by by_contra hn simp [censorCount, hn] at hxc exact hx ⟨lt_of_le_of_lt hxEvent.1 hy.1, hxEvent.2⟩ simp [hx, hyFalse] simp only [subjectIntegralBefore, hEvent, hInt]
Causalean.Stat.RecurrentEvent.CountingProcess.subjectIntegralBefore_leftPredictable · Causalean/Stat/RecurrentEvent/CountingProcess/CrossPrefix.lean:27 · uses LeftPredictable , Sample , subjectIntegralBefore
1 supporting declaration (lemmas, instances)
  • subjectIntegralBefore_jointMeasurable theorem — If the censor hazard is measurable and the integrand is jointly measurable in time and sample, then a subject's strict-past compensated integral is jointly measurable in time and sample.
    n :
    ℕ
    hazard :
    ℝ → ℝ
    hHazard :
    Measurable hazard
    H :
    ℝ → Sample n → ℝ
    hMeasurable :
    Measurable (fun p : ℝ × Sample n => H p.1 p.2)
    i :
    Fin n
    Measurable (fun p : ℝ × Sample n => subjectIntegralBefore hazard H i p.1 p.2)
    Proof (Lean source)
    @[fun_prop] theorem subjectIntegralBefore_jointMeasurable {n : ℕ} (hazard : ℝ → ℝ) (hHazard : Measurable hazard) (H : ℝ → Sample n → ℝ) (hMeasurable : Measurable (fun p : ℝ × Sample n => H p.1 p.2)) (i : Fin n) : Measurable (fun p : ℝ × Sample n => subjectIntegralBefore hazard H i p.1 p.2) := by let F : (ℝ × Sample n) × ℝ → ℝ := fun q => if 0 ≤ q.2 ∧ q.2 ≤ q.1.1 then H q.2 q.1.2 * hazard q.2 * riskIndicator i q.2 q.1.2 else 0 have hq2 : Measurable (fun q : (ℝ × Sample n) × ℝ => q.2) := by fun_prop have hq1 : Measurable (fun q : (ℝ × Sample n) × ℝ => q.1.1) := by fun_prop have hf : Measurable (fun q : (ℝ × Sample n) × ℝ => (q.1.2 i).1) := by fun_prop have hc : Measurable (fun q : (ℝ × Sample n) × ℝ => (q.1.2 i).2) := by fun_prop have hp : Measurable (fun q : (ℝ × Sample n) × ℝ => (q.2, q.1.2)) := by fun_prop have hRisk : Measurable (fun q : (ℝ × Sample n) × ℝ => riskIndicator i q.2 q.1.2) := by unfold riskIndicator apply Measurable.ite · simpa only [Set.ofPred_and, Set.inter_assoc] using ((measurableSet_le (measurable_const : Measurable (fun _ : (ℝ × Sample n) × ℝ => (0 : ℝ))) hq2).inter (measurableSet_le hq2 hf)).inter (measurableSet_le hq2 hc) · exact measurable_const · exact measurable_const have hF : Measurable F := by dsimp [F] apply Measurable.ite · simpa only [Set.ofPred_and] using (measurableSet_le (measurable_const : Measurable (fun _ : (ℝ × Sample n) × ℝ => (0 : ℝ))) hq2).inter (measurableSet_le hq2 hq1) · exact ((hMeasurable.comp hp).mul (hHazard.comp hq2)).mul hRisk · exact measurable_const have hI : Measurable (fun p : ℝ × Sample n => ∫ t, F (p, t) ∂volume) := hF.stronglyMeasurable.integral_prod_right'.measurable have hEq : ∀ p : ℝ × Sample n, (∫ t, F (p, t) ∂volume) = ∫ t in Icc 0 p.1, H t p.2 * hazard t * riskIndicator i t p.2 ∂volume := by intro p rw [← integral_indicator measurableSet_Icc] congr 1 funext t simp only [F, indicator, Set.mem_Icc] rw [show (fun p : ℝ × Sample n => ∫ t, F (p, t) ∂volume) = (fun p => ∫ t in Icc 0 p.1, H t p.2 * hazard t * riskIndicator i t p.2 ∂volume) from funext hEq] at hI have hC : Measurable (fun p : ℝ × Sample n => (p.2 i).2) := by fun_prop have hD : Measurable (fun p : ℝ × Sample n => (p.2 i).1) := by fun_prop have hS : Measurable (fun p : ℝ × Sample n => p.1) := by fun_prop have hP : Measurable (fun p : ℝ × Sample n => ((p.2 i).2, p.2)) := by fun_prop have hEvent : Measurable (fun p : ℝ × Sample n => if (p.2 i).2 < p.1 ∧ (p.2 i).2 < (p.2 i).1 then H (p.2 i).2 p.2 else 0) := by apply Measurable.ite · simpa only [Set.ofPred_and] using (measurableSet_lt hC hS).inter (measurableSet_lt hC hD) · exact hMeasurable.comp hP · exact measurable_const exact hEvent.sub hI
    Causalean.Stat.RecurrentEvent.CountingProcess.subjectIntegralBefore_jointMeasurable · Causalean/Stat/RecurrentEvent/CountingProcess/CrossPrefix.lean:117
Cross­Product 1 core · 0 supporting A pathwise product formula for two compensated one-jump censor integrals. ★ distinct_subject_integral_product_pathwise

A pathwise product formula for two compensated one-jump censor integrals. Distinct censor times remove the common-jump term; the remaining terms use strict-past compensated integrals, which are predictable.

theorem distinct_subject_integral_product_pathwise reviewed
Causalean.Stat.RecurrentEvent.CountingProcess

For two subjects in a sample, a nonnegative horizon u, nonnegative censor times that differ between the two subjects, and integrable at-risk integrands for each subject, weighted by the censor hazard, the product of the two subjects' compensated integrals up to u equals each subject's observed censor-jump payoff times the other subject's strict-past integral at that jump, summed, minus the two cross-compensator integrals of one subject's strict-past integral against the other's hazard payoff.

Formal statement
n :
ℕ
hazard :
ℝ → ℝ
H :
ℝ → Sample n → ℝ
i j :
Fin n
u :
ℝ
hu :
0 ≤ u
x :
hci0 :
0 ≤ (x i).2
hcj0 :
0 ≤ (x j).2
hCensorDistinct :
(x i).2 ≠ (x j).2
hPathi :
Integrable (fun s => H s x * hazard s * riskIndicator i s x) (volume.restrict (Icc 0 u))
hPathj :
Integrable (fun s => H s x * hazard s * riskIndicator j s x) (volume.restrict (Icc 0 u))
subjectIntegral hazard H i u x * subjectIntegral hazard H j u x
= (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x * subjectIntegralBefore hazard H j (x i).2 x else 0)
+ (if (x j).2 ≤ u ∧ (x j).2 < (x j).1 then H (x j).2 x * subjectIntegralBefore hazard H i (x j).2 x else 0)
- (∫ s in Icc 0 u, subjectIntegralBefore hazard H j s x * H s x * hazard s * riskIndicator i s x ∂volume)
- (∫ s in Icc 0 u, subjectIntegralBefore hazard H i s x * H s x * hazard s * riskIndicator j s x ∂volume)
Proof (Lean source)
theorem distinct_subject_integral_product_pathwise {n : ℕ} (hazard : ℝ → ℝ) (H : ℝ → Sample n → ℝ) (i j : Fin n) (u : ℝ) (hu : 0 ≤ u) (x : Sample n) (hci0 : 0 ≤ (x i).2) (hcj0 : 0 ≤ (x j).2) (hCensorDistinct : (x i).2 ≠ (x j).2) (hPathi : Integrable (fun s => H s x * hazard s * riskIndicator i s x) (volume.restrict (Icc 0 u))) (hPathj : Integrable (fun s => H s x * hazard s * riskIndicator j s x) (volume.restrict (Icc 0 u))) : subjectIntegral hazard H i u x * subjectIntegral hazard H j u x = (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x * subjectIntegralBefore hazard H j (x i).2 x else 0) + (if (x j).2 ≤ u ∧ (x j).2 < (x j).1 then H (x j).2 x * subjectIntegralBefore hazard H i (x j).2 x else 0) - (∫ s in Icc 0 u, subjectIntegralBefore hazard H j s x * H s x * hazard s * riskIndicator i s x ∂volume) - (∫ s in Icc 0 u, subjectIntegralBefore hazard H i s x * H s x * hazard s * riskIndicator j s x ∂volume) := by let ci := (x i).2 let cj := (x j).2 let di := (x i).1 let dj := (x j).1 let fi : ℝ → ℝ := fun s => H s x * hazard s * riskIndicator i s x let fj : ℝ → ℝ := fun s => H s x * hazard s * riskIndicator j s x let Ai := H ci x let Aj := H cj x let Ii := ∫ s in Icc 0 u, fi s ∂volume let Ij := ∫ s in Icc 0 u, fj s ∂volume let Pi := fun s => ∫ t in Icc 0 s, fi t ∂volume let Pj := fun s => ∫ t in Icc 0 s, fj t ∂volume have hbilin := integral_prefix_mul_bilinear fi fj u hu hPathi hPathj have hcrossj := integral_before_cross fi fj Aj cj dj u hcj0 hu hPathi hPathj have hcrossi := integral_before_cross fj fi Ai ci di u hci0 hu hPathj hPathi have hR : (if ci ≤ u ∧ ci < di then Ai else 0) * (if cj ≤ u ∧ cj < dj then Aj else 0) = (if ci ≤ u ∧ ci < di then Ai else 0) * (if cj < ci ∧ cj < dj then Aj else 0) + (if cj ≤ u ∧ cj < dj then Aj else 0) * (if ci < cj ∧ ci < di then Ai else 0) := by change ci ≠ cj at hCensorDistinct by_cases hci : ci ≤ u ∧ ci < di · by_cases hcj : cj ≤ u ∧ cj < dj · rcases lt_or_gt_of_ne hCensorDistinct with hlt | hlt · have hnot : ¬ cj < ci := not_lt_of_ge (le_of_lt hlt) simp [hci, hcj, hlt, hnot, mul_comm] · have hnot : ¬ ci < cj := not_lt_of_ge (le_of_lt hlt) simp [hci, hcj, hlt, hnot] · have hnot : ¬ (cj < ci ∧ cj < dj) := by intro h exact hcj ⟨le_trans (le_of_lt h.1) hci.1, h.2⟩ simp [hci, hcj, hnot] · by_cases hcj : cj ≤ u ∧ cj < dj · have hnot : ¬ (ci < cj ∧ ci < di) := by intro h exact hci ⟨le_trans (le_of_lt h.1) hcj.1, h.2⟩ simp [hci, hcj, hnot] · simp [hci, hcj] have hmain : ((if ci ≤ u ∧ ci < di then Ai else 0) - Ii) * ((if cj ≤ u ∧ cj < dj then Aj else 0) - Ij) = (if ci ≤ u ∧ ci < di then Ai * ((if cj < ci ∧ cj < dj then Aj else 0) - Pj ci) else 0) + (if cj ≤ u ∧ cj < dj then Aj * ((if ci < cj ∧ ci < di then Ai else 0) - Pi cj) else 0) - (∫ s in Icc 0 u, ((if cj < s ∧ cj < dj then Aj else 0) - Pj s) * fi s ∂volume) - (∫ s in Icc 0 u, ((if ci < s ∧ ci < di then Ai else 0) - Pi s) * fj s ∂volume) := by rw [hcrossj, hcrossi] unfold Ii Ij Pi Pj at * by_cases hi : ci ≤ u ∧ ci < di · by_cases hj : cj ≤ u ∧ cj < dj · simp only [if_pos hi, if_pos hj] at hR ⊢ nlinarith [hR, hbilin] · simp only [if_pos hi, if_neg hj] at hR ⊢ nlinarith [hR, hbilin] · by_cases hj : cj ≤ u ∧ cj < dj · simp only [if_neg hi, if_pos hj] at hR ⊢ nlinarith [hR, hbilin] · simp only [if_neg hi, if_neg hj] at hR ⊢ nlinarith [hR, hbilin] simpa only [subjectIntegral, subjectIntegralBefore, ci, cj, di, dj, fi, fj, Ai, Aj, Ii, Ij, Pi, Pj, mul_assoc] using hmain
Causalean.Stat.RecurrentEvent.CountingProcess.distinct_subject_integral_product_pathwise · Causalean/Stat/RecurrentEvent/CountingProcess/CrossProduct.lean:227 · uses Sample , riskIndicator , subjectIntegral , subjectIntegralBefore
Hazard­Bridge 1 core · 3 supporting The hazard-density law of a censor time gives the predictable compensator identity under an iid sample law. ★ predictable_censor_compensator

The hazard-density law of a censor time gives the predictable compensator identity under an iid sample law. This is the bridge from an ordinary product probability measure to the compensated counting process.

theorem predictable_censor_compensator reviewed
Causalean.Stat.RecurrentEvent.CountingProcess

Suppose subjects are drawn independently with failure times following a nonnegative time law and independent censor times whose law has the given censor hazard. If the payoff process is left predictable and jointly measurable in time and sample, and the payoff at subject i's observed censor event by u is integrable, then the expected censor-event payoff equals the expected at-risk hazard integral.

Formal statement
n :
ℕ
failureLaw censorLaw :
hazard :
ℝ → ℝ
hFailure :
hHazard :
HasCensorHazard censorLaw hazard
H :
ℝ → Sample n → ℝ
hPredictable :
LeftPredictable H
hMeasurable :
Measurable (fun p : ℝ × Sample n => H p.1 p.2)
i :
Fin n
u :
ℝ
hEvent :
Integrable (fun x : Sample n => if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) (sampleLaw n failureLaw censorLaw)
(∫ x : Sample n, (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) ∂sampleLaw n failureLaw censorLaw)
= ∫ x : Sample n, (∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume) ∂sampleLaw n failureLaw censorLaw
Proof (Lean source)
theorem predictable_censor_compensator {n : ℕ} (failureLaw censorLaw : Measure ℝ) (hazard : ℝ → ℝ) (hFailure : NonnegativeTimeLaw failureLaw) (hHazard : HasCensorHazard censorLaw hazard) (H : ℝ → Sample n → ℝ) (hPredictable : LeftPredictable H) (hMeasurable : Measurable (fun p : ℝ × Sample n => H p.1 p.2)) (i : Fin n) (u : ℝ) (hEvent : Integrable (fun x : Sample n => if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) (sampleLaw n failureLaw censorLaw)) : (∫ x : Sample n, (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) ∂sampleLaw n failureLaw censorLaw) = ∫ x : Sample n, (∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume) ∂sampleLaw n failureLaw censorLaw := by /- Apply the nonnegative identity to the positive and negative parts. Its extended-integral proof also supplies integrability of their compensators and the almost-everywhere inner-integrability needed to subtract the time integrals. -/ classical let μ := sampleLaw n failureLaw censorLaw let Hpos : ℝ → Sample n → ℝ := fun s x => max (H s x) 0 let Hneg : ℝ → Sample n → ℝ := fun s x => max (-H s x) 0 have hp_pred : LeftPredictable Hpos := by intro s x y hxy simp only [Hpos, hPredictable s x y hxy] have hn_pred : LeftPredictable Hneg := by intro s x y hxy simp only [Hneg, hPredictable s x y hxy] have hp_meas : Measurable (fun p : ℝ × Sample n => Hpos p.1 p.2) := hMeasurable.max measurable_const have hn_meas : Measurable (fun p : ℝ × Sample n => Hneg p.1 p.2) := hMeasurable.neg.max measurable_const have hp_nonneg : ∀ s x, 0 ≤ Hpos s x := fun s x => le_max_right _ _ have hn_nonneg : ∀ s x, 0 ≤ Hneg s x := fun s x => le_max_right _ _ have hp_event : Integrable (fun x : Sample n => if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then Hpos (x i).2 x else 0) μ := by convert hEvent.sup (integrable_zero (Sample n) ℝ μ) using 1 funext x by_cases hx : (x i).2 ≤ u ∧ (x i).2 < (x i).1 <;> simp [Hpos, hx] have hn_event : Integrable (fun x : Sample n => if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then Hneg (x i).2 x else 0) μ := by convert hEvent.neg.sup (integrable_zero (Sample n) ℝ μ) using 1 funext x by_cases hx : (x i).2 ≤ u ∧ (x i).2 < (x i).1 <;> simp [Hneg, hx] have hp_comp := nonnegative_compensator_integrable failureLaw censorLaw hazard hFailure hHazard Hpos hp_pred hp_meas hp_nonneg i u hp_event have hn_comp := nonnegative_compensator_integrable failureLaw censorLaw hazard hFailure hHazard Hneg hn_pred hn_meas hn_nonneg i u hn_event have hp_eq := predictable_censor_compensator_nonnegative failureLaw censorLaw hazard hFailure hHazard Hpos hp_pred hp_meas hp_nonneg i u hp_event have hn_eq := predictable_censor_compensator_nonnegative failureLaw censorLaw hazard hFailure hHazard Hneg hn_pred hn_meas hn_nonneg i u hn_event have hevent_sub : (fun x : Sample n => (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then Hpos (x i).2 x else 0) - (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then Hneg (x i).2 x else 0)) = (fun x => if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) := by funext x by_cases hx : (x i).2 ≤ u ∧ (x i).2 < (x i).1 · simp [hx, Hpos, Hneg, max_zero_sub_max_neg_zero_eq_self] · simp [hx] have hcomp_sub : ∀ᵐ x ∂μ, (∫ s in Icc 0 u, Hpos s x * hazard s * riskIndicator i s x ∂volume) - (∫ s in Icc 0 u, Hneg s x * hazard s * riskIndicator i s x ∂volume) = ∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume := by filter_upwards [hp_comp.2, hn_comp.2] with x hpi hni rw [← integral_sub hpi hni] congr 1 funext s dsimp [Hpos, Hneg] rw [← sub_mul, ← sub_mul, max_zero_sub_max_neg_zero_eq_self] calc (∫ x : Sample n, (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) ∂μ) = ∫ x : Sample n, ((if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then Hpos (x i).2 x else 0) - (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then Hneg (x i).2 x else 0)) ∂μ := by rw [hevent_sub] _ = (∫ x : Sample n, (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then Hpos (x i).2 x else 0) ∂μ) - (∫ x : Sample n, (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then Hneg (x i).2 x else 0) ∂μ) := integral_sub hp_event hn_event _ = (∫ x : Sample n, (∫ s in Icc 0 u, Hpos s x * hazard s * riskIndicator i s x ∂volume) ∂μ) - (∫ x : Sample n, (∫ s in Icc 0 u, Hneg s x * hazard s * riskIndicator i s x ∂volume) ∂μ) := by rw [hp_eq, hn_eq] _ = ∫ x : Sample n, ((∫ s in Icc 0 u, Hpos s x * hazard s * riskIndicator i s x ∂volume) - (∫ s in Icc 0 u, Hneg s x * hazard s * riskIndicator i s x ∂volume)) ∂μ := (integral_sub hp_comp.1 hn_comp.1).symm _ = ∫ x : Sample n, (∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume) ∂μ := integral_congr_ae hcomp_sub
3 supporting declarations (lemmas, instances)
  • predictable_censor_compensator_nonnegative theorem — Suppose subjects are drawn independently with failure times following a nonnegative time law and independent censor times whose law has the given censor hazard. Let the payoff process be left predictable, jointly measurable in time and sample, and nonnegative, fix a horizon u, and assume the payoff at subject i's observed censor event by u is integrable. Then the expected payoff at that censor event equals the expected integral, over times from 0 to u, of the payoff times the hazard times the subject's at-risk indicator.
    n :
    ℕ
    failureLaw censorLaw :
    hazard :
    ℝ → ℝ
    hFailure :
    hHazard :
    HasCensorHazard censorLaw hazard
    H :
    ℝ → Sample n → ℝ
    hPredictable :
    LeftPredictable H
    hMeasurable :
    Measurable (fun p : ℝ × Sample n => H p.1 p.2)
    hNonnegative :
    ∀ s x, 0 ≤ H s x
    i :
    Fin n
    u :
    ℝ
    hEvent :
    Integrable (fun x : Sample n => if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) (sampleLaw n failureLaw censorLaw)
    (∫ x : Sample n, (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) ∂sampleLaw n failureLaw censorLaw)
    = ∫ x : Sample n, (∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume) ∂sampleLaw n failureLaw censorLaw
    Proof (Lean source)
    theorem predictable_censor_compensator_nonnegative {n : ℕ} (failureLaw censorLaw : Measure ℝ) (hazard : ℝ → ℝ) (hFailure : NonnegativeTimeLaw failureLaw) (hHazard : HasCensorHazard censorLaw hazard) (H : ℝ → Sample n → ℝ) (hPredictable : LeftPredictable H) (hMeasurable : Measurable (fun p : ℝ × Sample n => H p.1 p.2)) (hNonnegative : ∀ s x, 0 ≤ H s x) (i : Fin n) (u : ℝ) (hEvent : Integrable (fun x : Sample n => if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) (sampleLaw n failureLaw censorLaw)) : (∫ x : Sample n, (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) ∂sampleLaw n failureLaw censorLaw) = ∫ x : Sample n, (∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume) ∂sampleLaw n failureLaw censorLaw := by /- Use `predictable_censor_compensator_lintegral`. Since the event payoff is integrable, the outer and inner extended hazard integrals are finite; convert each to a Bochner integral with `integral_eq_lintegral_of_nonneg_ae`. The inner conversion holds for almost every sample, which suffices for the outer integral. -/ classical let μ := sampleLaw n failureLaw censorLaw let F : Sample n → ℝ := fun x => if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0 let G : Sample n → ℝ := fun x => ∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume let g : Sample n → ℝ → ℝ := fun x s => H s x * hazard s * riskIndicator i s x have hg_nonneg : ∀ x s, 0 ≤ g x s := by intro x s dsimp [g] exact mul_nonneg (mul_nonneg (hNonnegative s x) (hHazard.2.2.1 s)) (by unfold riskIndicator split_ifs <;> norm_num) have hg_meas : Measurable (fun p : Sample n × ℝ => g p.1 p.2) := by dsimp [g] have hrisk : Measurable (fun p : Sample n × ℝ => riskIndicator i p.2 p.1) := by unfold riskIndicator have hfail : Measurable (fun p : Sample n × ℝ => (p.1 i).1) := by fun_prop have hcens : Measurable (fun p : Sample n × ℝ => (p.1 i).2) := by fun_prop have hevent : MeasurableSet {p : Sample n × ℝ | 0 ≤ p.2 ∧ p.2 ≤ (p.1 i).1 ∧ p.2 ≤ (p.1 i).2} := by simpa only [Set.ofPred_and, Set.inter_assoc] using (((show MeasurableSet {p : Sample n × ℝ | (0 : ℝ) ≤ p.2} from measurableSet_le measurable_const measurable_snd).inter (measurableSet_le measurable_snd hfail)).inter (measurableSet_le measurable_snd hcens)) exact measurable_const.ite hevent measurable_const exact ((hMeasurable.comp (measurable_snd.prodMk measurable_fst)).mul (hHazard.2.1.comp measurable_snd)).mul hrisk have hlin : (∫⁻ x, ofReal (F x) ∂μ) = ∫⁻ x, ∫⁻ s in Icc 0 u, ofReal (g x s) ∂volume ∂μ := by exact predictable_censor_compensator_lintegral failureLaw censorLaw hazard hFailure hHazard H hPredictable hMeasurable hNonnegative i u have hF_nonneg : 0 ≤ᵐ[μ] F := Filter.Eventually.of_forall (by intro x dsimp [F] split_ifs <;> simp_all) have hfinite : (∫⁻ x, ∫⁻ s in Icc 0 u, ofReal (g x s) ∂volume ∂μ) ≠ ⊤ := by rw [← hlin] rw [← ofReal_integral_eq_lintegral_ofReal hEvent hF_nonneg] exact ENNReal.ofReal_ne_top have hinner_meas : Measurable (fun x => ∫⁻ s in Icc 0 u, ofReal (g x s) ∂volume) := by exact (hg_meas.ennreal_ofReal.lintegral_prod_right') have hinner_finite : ∀ᵐ x ∂μ, (∫⁻ s in Icc 0 u, ofReal (g x s) ∂volume) < ⊤ := ae_lt_top hinner_meas hfinite have hinner : ∀ᵐ x ∂μ, G x = (∫⁻ s in Icc 0 u, ofReal (g x s) ∂volume).toReal := by filter_upwards [hinner_finite] with x hx exact integral_eq_lintegral_of_nonneg_ae (Filter.Eventually.of_forall (fun s => hg_nonneg x s)) (hg_meas.comp (measurable_const.prodMk measurable_id)).aestronglyMeasurable have houter : ∫ x, G x ∂μ = (∫⁻ x, ∫⁻ s in Icc 0 u, ofReal (g x s) ∂volume ∂μ).toReal := by rw [integral_congr_ae hinner] exact integral_toReal hinner_meas.aemeasurable hinner_finite have hF : ∫ x, F x ∂μ = (∫⁻ x, ofReal (F x) ∂μ).toReal := integral_eq_lintegral_of_nonneg_ae hF_nonneg hEvent.aestronglyMeasurable exact hF.trans (congrArg toReal hlin |>.trans houter.symm)
    Causalean.Stat.RecurrentEvent.CountingProcess.predictable_censor_compensator_nonnegative · Causalean/Stat/RecurrentEvent/CountingProcess/HazardBridge.lean:16
  • predictable_censor_compensator_integrable theorem — Suppose subjects are drawn independently with failure times following a nonnegative time law and independent censor times whose law has the given censor hazard. If the payoff process is left predictable and jointly measurable in time and sample, and the payoff at subject i's observed censor event by u is integrable, then the integral over times from 0 to u of the payoff times the hazard times the subject's at-risk indicator is integrable over samples.
    n :
    ℕ
    failureLaw censorLaw :
    hazard :
    ℝ → ℝ
    hFailure :
    hHazard :
    HasCensorHazard censorLaw hazard
    H :
    ℝ → Sample n → ℝ
    hPredictable :
    LeftPredictable H
    hMeasurable :
    Measurable (fun p : ℝ × Sample n => H p.1 p.2)
    i :
    Fin n
    u :
    ℝ
    hEvent :
    Integrable (fun x : Sample n => if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) (sampleLaw n failureLaw censorLaw)
    Integrable (fun x : Sample n => ∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume) (sampleLaw n failureLaw censorLaw)
    Proof (Lean source)
    theorem predictable_censor_compensator_integrable {n : ℕ} (failureLaw censorLaw : Measure ℝ) (hazard : ℝ → ℝ) (hFailure : NonnegativeTimeLaw failureLaw) (hHazard : HasCensorHazard censorLaw hazard) (H : ℝ → Sample n → ℝ) (hPredictable : LeftPredictable H) (hMeasurable : Measurable (fun p : ℝ × Sample n => H p.1 p.2)) (i : Fin n) (u : ℝ) (hEvent : Integrable (fun x : Sample n => if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) (sampleLaw n failureLaw censorLaw)) : Integrable (fun x : Sample n => ∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume) (sampleLaw n failureLaw censorLaw) := by /- Split H into its positive and negative parts. The nonnegative extended compensator identity gives integrability of both time integrals and almost-everywhere integrability of their time integrands. Subtract the two time integrals on that full-measure set. -/ classical let μ := sampleLaw n failureLaw censorLaw let Hpos : ℝ → Sample n → ℝ := fun s x => max (H s x) 0 let Hneg : ℝ → Sample n → ℝ := fun s x => max (-H s x) 0 have hp_pred : LeftPredictable Hpos := by intro s x y hxy simp only [Hpos, hPredictable s x y hxy] have hn_pred : LeftPredictable Hneg := by intro s x y hxy simp only [Hneg, hPredictable s x y hxy] have hp_meas : Measurable (fun p : ℝ × Sample n => Hpos p.1 p.2) := hMeasurable.max measurable_const have hn_meas : Measurable (fun p : ℝ × Sample n => Hneg p.1 p.2) := hMeasurable.neg.max measurable_const have hp_event : Integrable (fun x : Sample n => if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then Hpos (x i).2 x else 0) μ := by convert hEvent.sup (integrable_zero (Sample n) ℝ μ) using 1 funext x by_cases hx : (x i).2 ≤ u ∧ (x i).2 < (x i).1 <;> simp [Hpos, hx] have hn_event : Integrable (fun x : Sample n => if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then Hneg (x i).2 x else 0) μ := by convert hEvent.neg.sup (integrable_zero (Sample n) ℝ μ) using 1 funext x by_cases hx : (x i).2 ≤ u ∧ (x i).2 < (x i).1 <;> simp [Hneg, hx] have hp_comp := nonnegative_compensator_integrable failureLaw censorLaw hazard hFailure hHazard Hpos hp_pred hp_meas (fun _ _ => le_max_right _ _) i u hp_event have hn_comp := nonnegative_compensator_integrable failureLaw censorLaw hazard hFailure hHazard Hneg hn_pred hn_meas (fun _ _ => le_max_right _ _) i u hn_event have hcomp_sub : ∀ᵐ x ∂μ, (∫ s in Icc 0 u, Hpos s x * hazard s * riskIndicator i s x ∂volume) - (∫ s in Icc 0 u, Hneg s x * hazard s * riskIndicator i s x ∂volume) = ∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume := by filter_upwards [hp_comp.2, hn_comp.2] with x hpi hni rw [← integral_sub hpi hni] congr 1 funext s dsimp [Hpos, Hneg] rw [← sub_mul, ← sub_mul, max_zero_sub_max_neg_zero_eq_self] exact (hp_comp.1.sub hn_comp.1).congr hcomp_sub
    Causalean.Stat.RecurrentEvent.CountingProcess.predictable_censor_compensator_integrable · Causalean/Stat/RecurrentEvent/CountingProcess/HazardBridge.lean:186
  • compensatedCensor_mean_zero theorem — Under independent sampling with failure times following a nonnegative time law and independent censor times whose law has the given censor hazard, each subject's compensated censor count at a horizon u has mean zero.
    n :
    ℕ
    failureLaw censorLaw :
    hazard :
    ℝ → ℝ
    hFailure :
    hHazard :
    HasCensorHazard censorLaw hazard
    i :
    Fin n
    u :
    ℝ
    (∫ x : Sample n, compensatedCensor hazard i u x ∂sampleLaw n failureLaw censorLaw) = 0
    Proof (Lean source)
    theorem compensatedCensor_mean_zero {n : ℕ} (failureLaw censorLaw : Measure ℝ) (hazard : ℝ → ℝ) (hFailure : NonnegativeTimeLaw failureLaw) (hHazard : HasCensorHazard censorLaw hazard) (i : Fin n) (u : ℝ) : (∫ x : Sample n, compensatedCensor hazard i u x ∂sampleLaw n failureLaw censorLaw) = 0 := by /- Specialize the nonnegative compensator identity to the constant predictable process 1. The event payoff is bounded by 1. -/ classical haveI : IsProbabilityMeasure failureLaw := ⟨hFailure.1⟩ haveI : IsProbabilityMeasure censorLaw := ⟨hHazard.1.1⟩ let μ := sampleLaw n failureLaw censorLaw haveI : IsProbabilityMeasure μ := by dsimp [μ, sampleLaw] infer_instance have hevent_meas : Measurable (fun x : Sample n => if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then (1 : ℝ) else 0) := by have hpair : Measurable (fun x : Sample n => x i) := measurable_pi_apply i have hset : MeasurableSet {x : Sample n | (x i).2 ≤ u ∧ (x i).2 < (x i).1} := by exact (measurableSet_le hpair.snd measurable_const).inter (measurableSet_lt hpair.snd hpair.fst) exact measurable_const.ite hset measurable_const have hevent : Integrable (fun x : Sample n => if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then (1 : ℝ) else 0) μ := by apply Integrable.of_mem_Icc 0 1 hevent_meas.aemeasurable filter_upwards [] with x split_ifs <;> simp have hpred : LeftPredictable (fun (_ : ℝ) (_ : Sample n) => (1 : ℝ)) := by intro s x y hxy rfl have hcomp := (nonnegative_compensator_integrable failureLaw censorLaw hazard hFailure hHazard (fun (_ : ℝ) (_ : Sample n) => (1 : ℝ)) hpred measurable_const (fun _ _ => by norm_num) i u hevent).1 have heq := predictable_censor_compensator_nonnegative failureLaw censorLaw hazard hFailure hHazard (fun (_ : ℝ) (_ : Sample n) => (1 : ℝ)) hpred measurable_const (fun _ _ => by norm_num) i u hevent simp only [one_mul] at hcomp heq change (∫ x : Sample n, ((if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then (1 : ℝ) else 0) - ∫ s in Icc 0 u, hazard s * riskIndicator i s x ∂volume) ∂μ) = 0 rw [integral_sub hevent hcomp, heq, sub_self]
    Causalean.Stat.RecurrentEvent.CountingProcess.compensatedCensor_mean_zero · Causalean/Stat/RecurrentEvent/CountingProcess/HazardBridge.lean:353
Hazard­Density 1 core · 0 supporting One-dimensional hazard-density change of measure for a censored event. ★ censor_event_hazard_lintegral

One-dimensional hazard-density change of measure for a censored event. This is the scalar measure step needed before predictable sample histories and product-law resampling enter the compensator argument.

theorem censor_event_hazard_lintegral reviewed
Causalean.Stat.RecurrentEvent.CountingProcess

If the censor-time law has the given censor hazard and the payoff g is measurable, then for a fixed failure time f and horizon u, the expected positive part of the payoff over censor times that fall by u and strictly before f equals the Lebesgue integral, over times s from 0 to u with s before f, of the positive part of the payoff times the hazard times the probability of censoring at or after s.

Formal statement
censorLaw :
hazard g :
ℝ → ℝ
hHazard :
HasCensorHazard censorLaw hazard
hG :
f u :
ℝ
(∫⁻ c : ℝ, ofReal (if c ≤ u ∧ c < f then g c else 0) ∂censorLaw)
= ∫⁻ s in Icc 0 u, ofReal (if s < f then g s * hazard s * (censorLaw (Ici s)).toReal else 0) ∂volume
Proof (Lean source)
theorem censor_event_hazard_lintegral (censorLaw : Measure ℝ) (hazard g : ℝ → ℝ) (hHazard : HasCensorHazard censorLaw hazard) (hG : Measurable g) (f u : ℝ) : (∫⁻ c : ℝ, ofReal (if c ≤ u ∧ c < f then g c else 0) ∂censorLaw) = ∫⁻ s in Icc 0 u, ofReal (if s < f then g s * hazard s * (censorLaw (Ici s)).toReal else 0) ∂volume := by haveI : IsProbabilityMeasure censorLaw := ⟨hHazard.1.1⟩ have hsupport : Ici (0 : ℝ) ∈ ae censorLaw := (mem_ae_iff_prob_eq_one measurableSet_Ici).2 hHazard.1.2 have hsurv : Measurable (fun s : ℝ => censorLaw (Ici s)) := by apply Antitone.measurable intro a b hab exact measure_mono (Set.Ici_subset_Ici.mpr hab) have hdens : Measurable (fun s : ℝ => ofReal (hazard s * (censorLaw (Ici s)).toReal)) := (hHazard.2.1.mul hsurv.ennreal_toReal).ennreal_ofReal have hcut : Measurable (fun s : ℝ => ofReal (if s < f then g s else 0)) := by exact (Measurable.ite measurableSet_Iio hG measurable_const).ennreal_ofReal calc (∫⁻ c : ℝ, ofReal (if c ≤ u ∧ c < f then g c else 0) ∂censorLaw) = ∫⁻ c in Icc 0 u, ofReal (if c < f then g c else 0) ∂censorLaw := by rw [← lintegral_indicator measurableSet_Icc] apply lintegral_congr_ae filter_upwards [hsupport] with c hc simp only [Set.indicator_apply, Set.mem_Icc, Set.mem_Ici] at hc ⊢ by_cases hcu : c ≤ u <;> simp [hc, hcu] _ = ∫⁻ s in Icc 0 u, ofReal (hazard s * (censorLaw (Ici s)).toReal) * ofReal (if s < f then g s else 0) ∂volume := by simpa only [← hHazard.2.2.2.2, Pi.mul_apply] using (setLIntegral_withDensity_eq_lintegral_mul₀ (μ := volume) (s := Icc 0 u) hdens.aemeasurable hcut.aemeasurable measurableSet_Icc) _ = ∫⁻ s in Icc 0 u, ofReal (if s < f then g s * hazard s * (censorLaw (Ici s)).toReal else 0) ∂volume := by apply setLIntegral_congr_fun measurableSet_Icc intro s hs by_cases hsf : s < f · simp only [if_pos hsf] rw [← ENNReal.ofReal_mul (mul_nonneg (hHazard.2.2.1 s) ENNReal.toReal_nonneg)] congr 1 ring · simp [hsf]
Causalean.Stat.RecurrentEvent.CountingProcess.censor_event_hazard_lintegral · Causalean/Stat/RecurrentEvent/CountingProcess/HazardDensity.lean:16 · uses HasCensorHazard
Hazard­Tonelli 1 core · 4 supporting The nonnegative predictable censor-compensator identity. ★ predictable_censor_compensator_lintegral

The nonnegative predictable censor-compensator identity. Its extended integrals separate the product-law disintegration and Tonelli argument from the signed integrability bookkeeping in HazardBridge.

theorem predictable_censor_compensator_lintegral reviewed
Causalean.Stat.RecurrentEvent.CountingProcess

Suppose subjects are drawn independently with failure times following a nonnegative time law and independent censor times whose law has the given censor hazard, and let the payoff process be left predictable, jointly measurable in time and sample, and nonnegative. For any horizon u, the expected payoff at subject i's observed censor event by u equals the expected integral from 0 to u of the payoff times the hazard times the subject's at-risk indicator, as extended nonnegative integrals that may be infinite.

Formal statement
n :
ℕ
failureLaw censorLaw :
hazard :
ℝ → ℝ
hFailure :
hHazard :
HasCensorHazard censorLaw hazard
H :
ℝ → Sample n → ℝ
hPredictable :
LeftPredictable H
hMeasurable :
Measurable (fun p : ℝ × Sample n => H p.1 p.2)
hNonnegative :
∀ s x, 0 ≤ H s x
i :
Fin n
u :
ℝ
(∫⁻ x : Sample n, ofReal (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) ∂sampleLaw n failureLaw censorLaw)
= ∫⁻ x : Sample n, ∫⁻ s in Icc 0 u, ofReal (H s x * hazard s * riskIndicator i s x) ∂volume ∂sampleLaw n failureLaw censorLaw
Proof (Lean source)
theorem predictable_censor_compensator_lintegral {n : ℕ} (failureLaw censorLaw : Measure ℝ) (hazard : ℝ → ℝ) (hFailure : NonnegativeTimeLaw failureLaw) (hHazard : HasCensorHazard censorLaw hazard) (H : ℝ → Sample n → ℝ) (hPredictable : LeftPredictable H) (hMeasurable : Measurable (fun p : ℝ × Sample n => H p.1 p.2)) (hNonnegative : ∀ s x, 0 ≤ H s x) (i : Fin n) (u : ℝ) : (∫⁻ x : Sample n, ofReal (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) ∂sampleLaw n failureLaw censorLaw) = ∫⁻ x : Sample n, ∫⁻ s in Icc 0 u, ofReal (H s x * hazard s * riskIndicator i s x) ∂volume ∂sampleLaw n failureLaw censorLaw := by /- Disintegrate the finite product law at subject `i`. For a fixed `s`, `leftPredictable_censor_tail_invariant` identifies the value of H across all censor times at or after `s`; the two preceding lemmas identify both sides with the same resampled time integral. -/ exact (predictable_censor_event_hazard_lintegral failureLaw censorLaw hazard hFailure hHazard H hMeasurable hNonnegative i u).trans (predictable_censor_atRisk_hazard_lintegral failureLaw censorLaw hazard hFailure hHazard H hPredictable hMeasurable hNonnegative i u).symm
4 supporting declarations (lemmas, instances)
  • predictable_censor_event_hazard_lintegral theorem — Suppose subjects are drawn independently with failure times following a nonnegative time law and independent censor times whose law has the given censor hazard, and let the payoff process be jointly measurable in time and sample and nonnegative. For a horizon u, the expected payoff at subject i's observed censor event by u equals the expected Lebesgue integral, over times s from 0 to u strictly before the subject's failure time, of the payoff at s evaluated with that subject's censor time reset to s, times the hazard at s, times the probability of censoring at or after s.
    n :
    ℕ
    failureLaw censorLaw :
    hazard :
    ℝ → ℝ
    hFailure :
    hHazard :
    HasCensorHazard censorLaw hazard
    H :
    ℝ → Sample n → ℝ
    hMeasurable :
    Measurable (fun p : ℝ × Sample n => H p.1 p.2)
    hNonnegative :
    ∀ s x, 0 ≤ H s x
    i :
    Fin n
    u :
    ℝ
    (∫⁻ x : Sample n, ofReal (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) ∂sampleLaw n failureLaw censorLaw)
    = ∫⁻ x : Sample n, ∫⁻ s in Icc 0 u, ofReal (if s < (x i).1 then H s (update x i ((x i).1, s)) * hazard s * (censorLaw (Ici s)).toReal else 0) ∂volume ∂sampleLaw n failureLaw censorLaw
    Proof (Lean source)
    theorem predictable_censor_event_hazard_lintegral {n : ℕ} (failureLaw censorLaw : Measure ℝ) (hazard : ℝ → ℝ) (hFailure : NonnegativeTimeLaw failureLaw) (hHazard : HasCensorHazard censorLaw hazard) (H : ℝ → Sample n → ℝ) (hMeasurable : Measurable (fun p : ℝ × Sample n => H p.1 p.2)) (hNonnegative : ∀ s x, 0 ≤ H s x) (i : Fin n) (u : ℝ) : (∫⁻ x : Sample n, ofReal (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) ∂sampleLaw n failureLaw censorLaw) = ∫⁻ x : Sample n, ∫⁻ s in Icc 0 u, ofReal (if s < (x i).1 then H s (update x i ((x i).1, s)) * hazard s * (censorLaw (Ici s)).toReal else 0) ∂volume ∂sampleLaw n failureLaw censorLaw := by /- Use `lintegral_censor_event_resample`. For each fixed sample, apply `censor_event_hazard_lintegral` to `g s = H s (update x i ((x i).1, s))`. Joint measurability gives measurability of `g`; nonnegativity is inherited from `H`. -/ classical rw [lintegral_censor_event_resample failureLaw censorLaw hFailure hHazard.1 H hMeasurable i u] apply lintegral_congr intro x let g : ℝ → ℝ := fun s => H s (update x i ((x i).1, s)) have hg : Measurable g := by have hp : Measurable (fun s : ℝ => (s, update x i ((x i).1, s))) := by fun_prop simpa only [g, Function.comp_def] using hMeasurable.comp hp have hgn : ∀ s, 0 ≤ g s := fun s => hNonnegative s _ exact censor_event_hazard_lintegral censorLaw hazard g hHazard hg (x i).1 u
    Causalean.Stat.RecurrentEvent.CountingProcess.predictable_censor_event_hazard_lintegral · Causalean/Stat/RecurrentEvent/CountingProcess/HazardTonelli.lean:18
  • predictable_censor_atRisk_fixed_time_resample theorem — Suppose subjects are drawn independently with failure times following a nonnegative time law and independent censor times whose law has the given censor hazard, and let the payoff process be left predictable, jointly measurable in time and sample, and nonnegative. At a fixed nonnegative time s, the expected value of the payoff times the hazard times subject i's at-risk indicator equals the expected value, over samples whose subject-i failure time is at least s, of the payoff evaluated with that subject's censor time reset to s, times the hazard at s, times the probability of censoring at or after s.
    n :
    ℕ
    failureLaw censorLaw :
    hazard :
    ℝ → ℝ
    hFailure :
    hHazard :
    HasCensorHazard censorLaw hazard
    H :
    ℝ → Sample n → ℝ
    hPredictable :
    LeftPredictable H
    hMeasurable :
    Measurable (fun p : ℝ × Sample n => H p.1 p.2)
    hNonnegative :
    ∀ s x, 0 ≤ H s x
    i :
    Fin n
    s :
    ℝ
    hs :
    0 ≤ s
    (∫⁻ x : Sample n, ofReal (H s x * hazard s * riskIndicator i s x) ∂sampleLaw n failureLaw censorLaw)
    = ∫⁻ x : Sample n, ofReal (if s ≤ (x i).1 then H s (update x i ((x i).1, s)) * hazard s * (censorLaw (Ici s)).toReal else 0) ∂sampleLaw n failureLaw censorLaw
    Proof (Lean source)
    theorem predictable_censor_atRisk_fixed_time_resample {n : ℕ} (failureLaw censorLaw : Measure ℝ) (hazard : ℝ → ℝ) (hFailure : NonnegativeTimeLaw failureLaw) (hHazard : HasCensorHazard censorLaw hazard) (H : ℝ → Sample n → ℝ) (hPredictable : LeftPredictable H) (hMeasurable : Measurable (fun p : ℝ × Sample n => H p.1 p.2)) (hNonnegative : ∀ s x, 0 ≤ H s x) (i : Fin n) (s : ℝ) (hs : 0 ≤ s) : (∫⁻ x : Sample n, ofReal (H s x * hazard s * riskIndicator i s x) ∂sampleLaw n failureLaw censorLaw) = ∫⁻ x : Sample n, ofReal (if s ≤ (x i).1 then H s (update x i ((x i).1, s)) * hazard s * (censorLaw (Ici s)).toReal else 0) ∂sampleLaw n failureLaw censorLaw := by /- Apply `lintegral_resample_censor` to the at-risk payoff. For each fixed x, `leftPredictable_censor_tail_invariant` makes H constant over c ≥ s. The remaining censor integral is the measure of Ici s; use hHazard.2.2.1 and hNonnegative for ofReal multiplication. -/ classical have hF : Measurable (fun x : Sample n => ofReal (H s x * hazard s * riskIndicator i s x)) := by have hHs : Measurable (H s) := hMeasurable.comp (measurable_const.prodMk measurable_id) have hrisk : Measurable (riskIndicator i s : Sample n → ℝ) := by unfold riskIndicator have hfail : Measurable (fun x : Sample n => (x i).1) := by fun_prop have hcens : Measurable (fun x : Sample n => (x i).2) := by fun_prop have hevent : MeasurableSet {x : Sample n | 0 ≤ s ∧ s ≤ (x i).1 ∧ s ≤ (x i).2} := by simpa only [hs, true_and, Set.ofPred_and] using (measurableSet_le measurable_const hfail).inter (measurableSet_le measurable_const hcens) exact measurable_const.ite hevent measurable_const exact (hHs.mul_const _ |>.mul hrisk).ennreal_ofReal rw [lintegral_resample_censor failureLaw censorLaw hFailure hHazard.1 _ hF i] apply lintegral_congr intro x by_cases hf : s ≤ (x i).1 · let a : ℝ := H s (update x i ((x i).1, s)) * hazard s have ha : 0 ≤ a := mul_nonneg (hNonnegative s _) (hHazard.2.2.1 s) have hp : ∀ c : ℝ, ofReal (H s (update x i ((x i).1, c)) * hazard s * riskIndicator i s (update x i ((x i).1, c))) = (Ici s).indicator (fun _ => ofReal a) c := by intro c by_cases hc : s ≤ c · have hInv := leftPredictable_censor_tail_invariant H hPredictable s (update x i ((x i).1, s)) i c (by simp) hc have hInv' : H s (update x i ((x i).1, s)) = H s (update x i ((x i).1, c)) := by simpa [Function.update_idem] using hInv simpa [indicator, Set.mem_Ici, hc, riskIndicator, hs, hf, Function.update_self, a] using congrArg (fun y : ℝ => ofReal (y * hazard s)) hInv'.symm · simp [indicator, Set.mem_Ici, hc, riskIndicator, hs, hf, Function.update_self] simp_rw [hp] rw [lintegral_indicator_const measurableSet_Ici] have hfinite : censorLaw (Ici s) ≠ ⊤ := by have hle : censorLaw (Ici s) ≤ censorLaw univ := measure_mono (Set.subset_univ _) rw [hHazard.1.1] at hle exact ne_top_of_le_ne_top ENNReal.one_ne_top hle rw [← ENNReal.ofReal_toReal hfinite, ← ENNReal.ofReal_mul ha] simp [hf, a] · simp [riskIndicator, hs, hf, Function.update_self]
    Causalean.Stat.RecurrentEvent.CountingProcess.predictable_censor_atRisk_fixed_time_resample · Causalean/Stat/RecurrentEvent/CountingProcess/HazardTonelli.lean:63
  • lintegral_failure_time_boundary theorem — For any nonnegative extended-valued process, the expected Lebesgue integral from 0 to u of the process restricted to times at or before subject i's failure time equals the same quantity with times strictly before the failure time, whatever the failure and censor laws.
    n :
    ℕ
    failureLaw censorLaw :
    i :
    Fin n
    u :
    ℝ
    G :
    ℝ → Sample n → ENNReal
    (∫⁻ x : Sample n, ∫⁻ s in Icc 0 u, (if s ≤ (x i).1 then G s x else 0) ∂volume ∂sampleLaw n failureLaw censorLaw)
    = ∫⁻ x : Sample n, ∫⁻ s in Icc 0 u, (if s < (x i).1 then G s x else 0) ∂volume ∂sampleLaw n failureLaw censorLaw
    Proof (Lean source)
    theorem lintegral_failure_time_boundary {n : ℕ} (failureLaw censorLaw : Measure ℝ) (i : Fin n) (u : ℝ) (G : ℝ → Sample n → ENNReal) : (∫⁻ x : Sample n, ∫⁻ s in Icc 0 u, (if s ≤ (x i).1 then G s x else 0) ∂volume ∂sampleLaw n failureLaw censorLaw) = ∫⁻ x : Sample n, ∫⁻ s in Icc 0 u, (if s < (x i).1 then G s x else 0) ∂volume ∂sampleLaw n failureLaw censorLaw := by /- For each fixed `x`, use `lintegral_congr_ae`. Outside the null singleton `{(x i).1}`, the two order tests agree. The identity requires no measurability of `G`, since the two functions agree almost everywhere on the time measure. -/ apply lintegral_congr intro x apply lintegral_congr_ae filter_upwards [Measure.ae_ne (volume.restrict (Icc 0 u)) (x i).1] with s hs have hiff : s ≤ (x i).1 ↔ s < (x i).1 := ⟨fun h => lt_of_le_of_ne h hs, le_of_lt⟩ simp only [hiff]
    Causalean.Stat.RecurrentEvent.CountingProcess.lintegral_failure_time_boundary · Causalean/Stat/RecurrentEvent/CountingProcess/HazardTonelli.lean:142
  • predictable_censor_atRisk_hazard_lintegral theorem — Suppose subjects are drawn independently with failure times following a nonnegative time law and independent censor times whose law has the given censor hazard, and let the payoff process be left predictable, jointly measurable in time and sample, and nonnegative. For a horizon u, the expected integral from 0 to u of the payoff times the hazard times subject i's at-risk indicator equals the expected integral, over times s before the subject's failure time, of the payoff with that subject's censor time reset to s, times the hazard at s, times the probability of censoring at or after s.
    n :
    ℕ
    failureLaw censorLaw :
    hazard :
    ℝ → ℝ
    hFailure :
    hHazard :
    HasCensorHazard censorLaw hazard
    H :
    ℝ → Sample n → ℝ
    hPredictable :
    LeftPredictable H
    hMeasurable :
    Measurable (fun p : ℝ × Sample n => H p.1 p.2)
    hNonnegative :
    ∀ s x, 0 ≤ H s x
    i :
    Fin n
    u :
    ℝ
    (∫⁻ x : Sample n, ∫⁻ s in Icc 0 u, ofReal (H s x * hazard s * riskIndicator i s x) ∂volume ∂sampleLaw n failureLaw censorLaw)
    = ∫⁻ x : Sample n, ∫⁻ s in Icc 0 u, ofReal (if s < (x i).1 then H s (update x i ((x i).1, s)) * hazard s * (censorLaw (Ici s)).toReal else 0) ∂volume ∂sampleLaw n failureLaw censorLaw
    Proof (Lean source)
    theorem predictable_censor_atRisk_hazard_lintegral {n : ℕ} (failureLaw censorLaw : Measure ℝ) (hazard : ℝ → ℝ) (hFailure : NonnegativeTimeLaw failureLaw) (hHazard : HasCensorHazard censorLaw hazard) (H : ℝ → Sample n → ℝ) (hPredictable : LeftPredictable H) (hMeasurable : Measurable (fun p : ℝ × Sample n => H p.1 p.2)) (hNonnegative : ∀ s x, 0 ≤ H s x) (i : Fin n) (u : ℝ) : (∫⁻ x : Sample n, ∫⁻ s in Icc 0 u, ofReal (H s x * hazard s * riskIndicator i s x) ∂volume ∂sampleLaw n failureLaw censorLaw) = ∫⁻ x : Sample n, ∫⁻ s in Icc 0 u, ofReal (if s < (x i).1 then H s (update x i ((x i).1, s)) * hazard s * (censorLaw (Ici s)).toReal else 0) ∂volume ∂sampleLaw n failureLaw censorLaw := by classical haveI : IsProbabilityMeasure failureLaw := ⟨hFailure.1⟩ haveI : IsProbabilityMeasure censorLaw := ⟨hHazard.1.1⟩ let μ := sampleLaw n failureLaw censorLaw let ν := volume.restrict (Icc 0 u) haveI : IsProbabilityMeasure μ := by dsimp [μ, sampleLaw] infer_instance have hleft : Measurable (fun p : Sample n × ℝ => ofReal (H p.2 p.1 * hazard p.2 * riskIndicator i p.2 p.1)) := by have hrisk : Measurable (fun p : Sample n × ℝ => riskIndicator i p.2 p.1) := by unfold riskIndicator have hfail : Measurable (fun p : Sample n × ℝ => (p.1 i).1) := by fun_prop have hcens : Measurable (fun p : Sample n × ℝ => (p.1 i).2) := by fun_prop have hevent : MeasurableSet {p : Sample n × ℝ | 0 ≤ p.2 ∧ p.2 ≤ (p.1 i).1 ∧ p.2 ≤ (p.1 i).2} := by simpa only [Set.ofPred_and, Set.inter_assoc] using (((show MeasurableSet {p : Sample n × ℝ | (0 : ℝ) ≤ p.2} from measurableSet_le measurable_const measurable_snd).inter (measurableSet_le measurable_snd hfail)).inter (measurableSet_le measurable_snd hcens)) exact measurable_const.ite hevent measurable_const exact ENNReal.measurable_ofReal.comp (((hMeasurable.comp (measurable_snd.prodMk measurable_fst)).mul (hHazard.2.1.comp measurable_snd)).mul hrisk) have hright : Measurable (fun p : Sample n × ℝ => ofReal (if p.2 ≤ (p.1 i).1 then H p.2 (update p.1 i ((p.1 i).1, p.2)) * hazard p.2 * (censorLaw (Ici p.2)).toReal else 0)) := by have htail : Measurable (fun s : ℝ => (censorLaw (Ici s)).toReal) := by apply ENNReal.measurable_toReal.comp apply Antitone.measurable intro a b hab exact measure_mono (Set.Ici_subset_Ici.mpr hab) have hevent : MeasurableSet {p : Sample n × ℝ | p.2 ≤ (p.1 i).1} := measurableSet_le measurable_snd (by fun_prop) have hupdate : Measurable (fun p : Sample n × ℝ => update p.1 i ((p.1 i).1, p.2)) := by apply measurable_pi_lambda intro k by_cases hk : k = i · subst k simpa using ((show Measurable (fun p : Sample n × ℝ => (p.1 i).1) by fun_prop).prodMk measurable_snd : Measurable (fun p : Sample n × ℝ => ((p.1 i).1, p.2))) · simpa [Function.update_of_ne hk] using (show Measurable (fun p : Sample n × ℝ => p.1 k) by fun_prop) apply ENNReal.measurable_ofReal.comp apply Measurable.ite hevent · exact ((hMeasurable.comp (measurable_snd.prodMk hupdate)).mul (hHazard.2.1.comp measurable_snd)).mul (htail.comp measurable_snd) · exact measurable_const calc (∫⁻ x : Sample n, ∫⁻ s in Icc 0 u, ofReal (H s x * hazard s * riskIndicator i s x) ∂volume ∂μ) = ∫⁻ s : ℝ, ∫⁻ x : Sample n, ofReal (H s x * hazard s * riskIndicator i s x) ∂μ ∂ν := by exact lintegral_lintegral_swap hleft.aemeasurable _ = ∫⁻ s : ℝ, ∫⁻ x : Sample n, ofReal (if s ≤ (x i).1 then H s (update x i ((x i).1, s)) * hazard s * (censorLaw (Ici s)).toReal else 0) ∂μ ∂ν := by apply lintegral_congr_ae filter_upwards [ae_restrict_mem measurableSet_Icc] with s hs exact predictable_censor_atRisk_fixed_time_resample failureLaw censorLaw hazard hFailure hHazard H hPredictable hMeasurable hNonnegative i s hs.1 _ = ∫⁻ x : Sample n, ∫⁻ s in Icc 0 u, ofReal (if s ≤ (x i).1 then H s (update x i ((x i).1, s)) * hazard s * (censorLaw (Ici s)).toReal else 0) ∂volume ∂μ := by exact (lintegral_lintegral_swap hright.aemeasurable).symm _ = _ := by dsimp [μ] convert lintegral_failure_time_boundary failureLaw censorLaw i u (fun s x => ofReal (H s (update x i ((x i).1, s)) * hazard s * (censorLaw (Ici s)).toReal)) using 1 <;> simp only [ENNReal.ofReal_zero, apply_ite]
    Causalean.Stat.RecurrentEvent.CountingProcess.predictable_censor_atRisk_hazard_lintegral · Causalean/Stat/RecurrentEvent/CountingProcess/HazardTonelli.lean:168
History 1 core · 1 supporting Elementary history invariance for the observed event processes. ★ leftPredictable_censor_tail_invariant

Elementary history invariance for the observed event processes. These lemmas isolate the pathwise nonanticipation step used when a latent event time is integrated out of the iid sample law.

theorem leftPredictable_censor_tail_invariant reviewed
Causalean.Stat.RecurrentEvent.CountingProcess

If a process is left predictable and, at time s, one subject's current censor time and a replacement censor time are both at or after s, then the process at s is unchanged when that subject's censor time is replaced, with the subject's failure time and every other subject's record held fixed.

Formal statement
n :
ℕ
H :
ℝ → Sample n → ℝ
hH :
LeftPredictable H
s :
ℝ
x :
i :
Fin n
c :
ℝ
hOld :
s ≤ (x i).2
hNew :
s ≤ c
H s x = H s (update x i ((x i).1, c))
Proof (Lean source)
theorem leftPredictable_censor_tail_invariant {n : ℕ} (H : ℝ → Sample n → ℝ) (hH : LeftPredictable H) (s : ℝ) (x : Sample n) (i : Fin n) (c : ℝ) (hOld : s ≤ (x i).2) (hNew : s ≤ c) : H s x = H s (update x i ((x i).1, c)) := by /- For each t < s, neither censor time can have generated a censor event. A failure before t is observed under both censor times. Apply `hH` to the resulting equality of earlier event histories. -/ apply hH s x (update x i ((x i).1, c)) intro j t ht by_cases hji : j = i · subst j have htOld : t < (x i).2 := lt_of_lt_of_le ht hOld have htNew : t < c := lt_of_lt_of_le ht hNew have hcOld : ¬ (x i).2 ≤ t := not_le.mpr htOld have hcNew : ¬ c ≤ t := not_le.mpr htNew constructor · simp [censorCount, Function.update_self, hcOld, hcNew] · by_cases hf : (x i).1 ≤ t · have hfOld : (x i).1 ≤ (x i).2 := le_trans hf (le_of_lt htOld) have hfNew : (x i).1 ≤ c := le_trans hf (le_of_lt htNew) simp [failureCount, Function.update_self, hf, hfOld, hfNew] · simp [failureCount, Function.update_self, hf] · have hu := Function.update_of_ne hji ((x i).1, c) x simp [censorCount, failureCount, hu]
Causalean.Stat.RecurrentEvent.CountingProcess.leftPredictable_censor_tail_invariant · Causalean/Stat/RecurrentEvent/CountingProcess/History.lean:14 · uses LeftPredictable , Sample
1 supporting declaration (lemmas, instances)
  • leftPredictable_failure_tail_invariant theorem — If a process is left predictable and, at time s, one subject's current failure time and a replacement failure time are both at or after s, then the process at s is unchanged when that subject's failure time is replaced, with the subject's censor time and every other subject's record held fixed.
    n :
    ℕ
    H :
    ℝ → Sample n → ℝ
    hH :
    LeftPredictable H
    s :
    ℝ
    x :
    i :
    Fin n
    f :
    ℝ
    hOld :
    s ≤ (x i).1
    hNew :
    s ≤ f
    H s x = H s (update x i (f, (x i).2))
    Proof (Lean source)
    theorem leftPredictable_failure_tail_invariant {n : ℕ} (H : ℝ → Sample n → ℝ) (hH : LeftPredictable H) (s : ℝ) (x : Sample n) (i : Fin n) (f : ℝ) (hOld : s ≤ (x i).1) (hNew : s ≤ f) : H s x = H s (update x i (f, (x i).2)) := by /- Before s, neither failure time can have generated a failure event. A censor event before s is observed under both failure times. -/ apply hH s x (update x i (f, (x i).2)) intro j t ht by_cases hji : j = i · subst j have htOld : t < (x i).1 := lt_of_lt_of_le ht hOld have htNew : t < f := lt_of_lt_of_le ht hNew have hfOld : ¬ (x i).1 ≤ t := not_le.mpr htOld have hfNew : ¬ f ≤ t := not_le.mpr htNew constructor · by_cases hc : (x i).2 ≤ t · have hcOld : (x i).2 < (x i).1 := lt_of_le_of_lt hc htOld have hcNew : (x i).2 < f := lt_of_le_of_lt hc htNew simp [censorCount, Function.update_self, hc, hcOld, hcNew] · simp [censorCount, Function.update_self, hc] · simp [failureCount, Function.update_self, hfOld, hfNew] · have hu := Function.update_of_ne hji (f, (x i).2) x simp [censorCount, failureCount, hu]
    Causalean.Stat.RecurrentEvent.CountingProcess.leftPredictable_failure_tail_invariant · Causalean/Stat/RecurrentEvent/CountingProcess/History.lean:44
Integral­Square 1 core · 1 supporting The deterministic square identity and absolute mixed-product bound for an indefinite Lebesgue integral on a finite interval. ★ integral_prefix_square

The deterministic square identity and absolute mixed-product bound for an indefinite Lebesgue integral on a finite interval. These are the pathwise calculus inputs to counting-process second-moment calculations.

theorem integral_prefix_square reviewed
Causalean.Stat.RecurrentEvent.CountingProcess

For a nonnegative horizon u and a real rate integrable on the interval from 0 to u, the square of the rate's integral over that interval equals the integral of twice its running integral times the rate.

Formal statement
f :
ℝ → ℝ
u :
ℝ
hu :
0 ≤ u
hf :
Integrable f (volume.restrict (Icc 0 u))
(∫ s in Icc 0 u, f s ∂volume) ^ 2
= ∫ s in Icc 0 u, 2 * (∫ t in Icc 0 s, f t ∂volume) * f s ∂volume
Proof (Lean source)
theorem integral_prefix_square (f : ℝ → ℝ) (u : ℝ) (hu : 0 ≤ u) (hf : Integrable f (volume.restrict (Icc 0 u))) : (∫ s in Icc 0 u, f s ∂volume) ^ 2 = ∫ s in Icc 0 u, 2 * (∫ t in Icc 0 s, f t ∂volume) * f s ∂volume := by let F : ℝ → ℝ := fun x => ∫ t in (0 : ℝ)..x, f t have hfi : IntervalIntegrable f volume 0 u := (intervalIntegrable_iff_integrableOn_Icc_of_le hu).2 hf have hF : AbsolutelyContinuousOnInterval F 0 u := hfi.absolutelyContinuousOnInterval_intervalIntegral (by simp) have hderiv := hfi.ae_hasDerivAt_integral have hprod := hF.integral_deriv_mul_eq_sub hF have heq : (∫ s in (0 : ℝ)..u, deriv F s * F s + F s * deriv F s) = ∫ s in (0 : ℝ)..u, 2 * (∫ t in Icc 0 s, f t ∂volume) * f s := by apply intervalIntegral.integral_congr_ae filter_upwards [hderiv] with s hs hsmem have hsIcc : s ∈ Icc (0 : ℝ) u := by simpa [Set.uIcc_of_le hu] using (Set.uIoc_subset_uIcc hsmem) have hds : deriv F s = f s := (hs (by simpa [Set.uIcc_of_le hu] using hsIcc) 0 (by simp)).deriv have hprefix : F s = ∫ t in Icc 0 s, f t ∂volume := by dsimp [F] rw [intervalIntegral.integral_of_le hsIcc.1, ← integral_Icc_eq_integral_Ioc] rw [hds, hprefix] ring rw [heq] at hprod have hzero : F 0 = 0 := by simp [F] have hfinal : F u = ∫ s in Icc 0 u, f s ∂volume := by dsimp [F] rw [intervalIntegral.integral_of_le hu, ← integral_Icc_eq_integral_Ioc] rw [hfinal, hzero] at hprod simpa [pow_two, intervalIntegral.integral_of_le hu, ← integral_Icc_eq_integral_Ioc] using hprod.symm
Causalean.Stat.RecurrentEvent.CountingProcess.integral_prefix_square · Causalean/Stat/RecurrentEvent/CountingProcess/IntegralSquare.lean:17
1 supporting declaration (lemmas, instances)
  • integral_prefix_mul_abs_le_square theorem — For a nonnegative horizon u and a real rate integrable on the interval from 0 to u, the integral of the absolute value of the running integral times the rate is at most the square of the integral of the rate's absolute value.
    f :
    ℝ → ℝ
    u :
    ℝ
    hu :
    0 ≤ u
    hf :
    Integrable f (volume.restrict (Icc 0 u))
    (∫ s in Icc 0 u, |(∫ t in Icc 0 s, f t ∂volume) * f s| ∂volume)
    ≤ (∫ s in Icc 0 u, |f s| ∂volume) ^ 2
    Proof (Lean source)
    theorem integral_prefix_mul_abs_le_square (f : ℝ → ℝ) (u : ℝ) (hu : 0 ≤ u) (hf : Integrable f (volume.restrict (Icc 0 u))) : (∫ s in Icc 0 u, |(∫ t in Icc 0 s, f t ∂volume) * f s| ∂volume) ≤ (∫ s in Icc 0 u, |f s| ∂volume) ^ 2 := by /- On 0 ≤ s ≤ u, the absolute prefix is bounded by the prefix integral of |f|. Apply `integral_prefix_square` to |f|, use positivity, and compare the two integrands. The factor of two leaves slack. -/ let g : ℝ → ℝ := fun s => |f s| let F : ℝ → ℝ := fun s => ∫ t in (0 : ℝ)..s, g t have hg : Integrable g (volume.restrict (Icc 0 u)) := hf.abs have hgi : IntervalIntegrable g volume 0 u := (intervalIntegrable_iff_integrableOn_Icc_of_le hu).2 hg have hF : ContinuousOn F (Icc 0 u) := by simpa [Set.uIcc_of_le hu] using (hgi.absolutelyContinuousOnInterval_intervalIntegral (by simp)).continuousOn have hprod : Integrable (fun s => F s * g s) (volume.restrict (Icc 0 u)) := (intervalIntegrable_iff_integrableOn_Icc_of_le hu).1 (hgi.continuousOn_mul (by simpa [Set.uIcc_of_le hu] using hF)) have hprefix (s : ℝ) (hs : s ∈ Icc (0 : ℝ) u) : F s = ∫ t in Icc 0 s, g t ∂volume := by dsimp [F] rw [intervalIntegral.integral_of_le hs.1, ← integral_Icc_eq_integral_Ioc] have hright : Integrable (fun s => 2 * (∫ t in Icc 0 s, g t ∂volume) * g s) (volume.restrict (Icc 0 u)) := by have hae : (fun s => 2 * (F s * g s)) =ᵐ[volume.restrict (Icc 0 u)] (fun s => 2 * (∫ t in Icc 0 s, g t ∂volume) * g s) := by filter_upwards [ae_restrict_mem measurableSet_Icc] with s hs rw [hprefix s hs] ring have h := (hprod.const_mul (2 : ℝ)).congr hae exact h have hle : (∫ s in Icc 0 u, |(∫ t in Icc 0 s, f t ∂volume) * f s| ∂volume) ≤ ∫ s in Icc 0 u, 2 * (∫ t in Icc 0 s, g t ∂volume) * g s ∂volume := by apply integral_mono_of_nonneg · exact Filter.Eventually.of_forall (fun s => abs_nonneg _) · exact hright · filter_upwards [ae_restrict_mem measurableSet_Icc] with s hs have hpre := abs_integral_le_integral_abs (μ := volume.restrict (Icc 0 s)) (f := f) have hnonneg : 0 ≤ ∫ t in Icc 0 s, g t ∂volume := integral_nonneg (fun t => abs_nonneg (f t)) rw [abs_mul] dsimp [g] change 0 ≤ ∫ t in Icc 0 s, |f t| ∂volume at hnonneg nlinarith [mul_nonneg (sub_nonneg.mpr hpre) (abs_nonneg (f s)), mul_nonneg hnonneg (abs_nonneg (f s))] rw [← integral_prefix_square g u hu hg] at hle exact hle
    Causalean.Stat.RecurrentEvent.CountingProcess.integral_prefix_mul_abs_le_square · Causalean/Stat/RecurrentEvent/CountingProcess/IntegralSquare.lean:54
Isometry 1 core · 1 supporting This module combines finite-sample subjectwise compensated censor integrals. ★ aggregate_integral_isometry

Aggregate compensated-count isometry

This module combines finite-sample subjectwise compensated censor integrals. It supplies pairwise orthogonality and the aggregate predictable-integral isometry whose bracket is the at-risk hazard integral.

theorem aggregate_integral_isometry reviewed
Causalean.Stat.RecurrentEvent.CountingProcess

Suppose subjects are drawn independently with failure times following a nonnegative time law and independent censor times whose law has the given censor hazard, and let the integrand be left predictable and jointly measurable in time and sample. For a nonnegative horizon u, finite expected quadratic energy, and an integrable predictable quadratic energy, the expected square of the integral against the sum of all compensated censor counts up to u equals the expected predictable quadratic energy.

Formal statement
n :
ℕ
failureLaw censorLaw :
hazard :
ℝ → ℝ
hFailure :
hHazard :
HasCensorHazard censorLaw hazard
H :
ℝ → Sample n → ℝ
hPredictable :
LeftPredictable H
hMeasurable :
Measurable (fun p : ℝ × Sample n => H p.1 p.2)
u :
ℝ
hu :
0 ≤ u
hQuadratic :
QuadraticEnergyFinite failureLaw censorLaw hazard H u
hEnergy :
Integrable (predictableEnergy hazard H u) (sampleLaw n failureLaw censorLaw)
(∫ x : Sample n, (aggregateIntegral hazard H u x) ^ 2 ∂sampleLaw n failureLaw censorLaw)
= ∫ x : Sample n, predictableEnergy hazard H u x ∂sampleLaw n failureLaw censorLaw
Proof (Lean source)
theorem aggregate_integral_isometry {n : ℕ} (failureLaw censorLaw : Measure ℝ) (hazard : ℝ → ℝ) (hFailure : NonnegativeTimeLaw failureLaw) (hHazard : HasCensorHazard censorLaw hazard) (H : ℝ → Sample n → ℝ) (hPredictable : LeftPredictable H) (hMeasurable : Measurable (fun p : ℝ × Sample n => H p.1 p.2)) (u : ℝ) (hu : 0 ≤ u) (hQuadratic : QuadraticEnergyFinite failureLaw censorLaw hazard H u) (hEnergy : Integrable (predictableEnergy hazard H u) (sampleLaw n failureLaw censorLaw)) : (∫ x : Sample n, (aggregateIntegral hazard H u x) ^ 2 ∂sampleLaw n failureLaw censorLaw) = ∫ x : Sample n, predictableEnergy hazard H u x ∂sampleLaw n failureLaw censorLaw := by /- For each i, derive integrability of the subject energy by domination by `predictableEnergy`. Derive subject square integrability directly from the event-payoff and hazard-payoff squares; isometry by itself is only an equality of Bochner integrals. Cauchy--Schwarz gives products. Expand `(∑ i, subjectIntegral ... i)^2` as a double sum, interchange each finite sum with the expectation, and use the subject isometry on diagonal terms and `distinct_subject_integrals_orthogonal` elsewhere. The sum of subject energies is `predictableEnergy` by linearity of the time integral (pathwise almost everywhere integrability follows from the finite quadratic-energy hypothesis). -/ classical let μ := sampleLaw n failureLaw censorLaw let J : Fin n → Sample n → ℝ := fun i x => subjectIntegral hazard H i u x let Q : Fin n → Sample n → ℝ := fun i x => ∫ s in Icc 0 u, (H s x) ^ 2 * hazard s * riskIndicator i s x ∂volume have hQ (i : Fin n) : Integrable (Q i) μ := subject_energy_integrable failureLaw censorLaw hazard hFailure hHazard H hMeasurable i u hQuadratic hEnergy have hSquare (i : Fin n) : AEStronglyMeasurable (J i) μ ∧ Integrable (fun x => (J i x) ^ 2) μ := by let E : Sample n → ℝ := fun x => if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0 let A : Sample n → ℝ := fun x => ∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume have hEmeas : Measurable E := by have hc : Measurable (fun x : Sample n => (x i).2) := by fun_prop have hf : Measurable (fun x : Sample n => (x i).1) := by fun_prop exact (hMeasurable.comp (hc.prodMk measurable_id)).ite ((measurableSet_le hc measurable_const).inter (measurableSet_lt hc hf)) measurable_const have hAmeas : Measurable A := by let F : Sample n × ℝ → ℝ := fun p => H p.2 p.1 * hazard p.2 * riskIndicator i p.2 p.1 have hrisk : Measurable (fun p : Sample n × ℝ => riskIndicator i p.2 p.1) := by unfold riskIndicator have hf : Measurable (fun p : Sample n × ℝ => (p.1 i).1) := by fun_prop have hc : Measurable (fun p : Sample n × ℝ => (p.1 i).2) := by fun_prop have hs : MeasurableSet {p : Sample n × ℝ | 0 ≤ p.2 ∧ p.2 ≤ (p.1 i).1 ∧ p.2 ≤ (p.1 i).2} := by simpa only [Set.ofPred_and, Set.inter_assoc, id_eq] using (((show MeasurableSet {p : Sample n × ℝ | (0 : ℝ) ≤ p.2} from measurableSet_le measurable_const measurable_snd).inter (measurableSet_le measurable_snd hf)).inter (measurableSet_le measurable_snd hc)) exact measurable_const.ite hs measurable_const have hF : Measurable F := ((hMeasurable.comp (measurable_snd.prodMk measurable_fst)).mul (hHazard.2.1.comp measurable_snd)).mul hrisk exact hF.stronglyMeasurable.integral_prod_right'.measurable have hELp : MemLp E 2 μ := (memLp_two_iff_integrable_sq hEmeas.aestronglyMeasurable).2 (subject_event_payoff_square_integrable failureLaw censorLaw hazard hFailure hHazard H hPredictable hMeasurable i u hQuadratic) have hALp : MemLp A 2 μ := (memLp_two_iff_integrable_sq hAmeas.aestronglyMeasurable).2 (subject_hazard_square_integrable failureLaw censorLaw hazard hFailure hHazard H hMeasurable i u hQuadratic) constructor · change AEStronglyMeasurable (E - A) μ exact (hEmeas.sub hAmeas).aestronglyMeasurable · simpa [J, subjectIntegral, E, A, Pi.sub_apply] using (hELp.sub hALp).integrable_sq have hProd (i j : Fin n) : Integrable (fun x => J i x * J j x) μ := ((memLp_two_iff_integrable_sq (hSquare i).1).2 (hSquare i).2).integrable_mul ((memLp_two_iff_integrable_sq (hSquare j).1).2 (hSquare j).2) have hIso (i : Fin n) : (∫ x, (J i x) ^ 2 ∂μ) = ∫ x, Q i x ∂μ := subject_integral_isometry failureLaw censorLaw hazard hFailure hHazard H hPredictable hMeasurable i u hu hQuadratic have hCross (i j : Fin n) (hij : i ≠ j) : (∫ x, J i x * J j x ∂μ) = 0 := distinct_subject_integrals_orthogonal failureLaw censorLaw hazard hFailure hHazard H hPredictable hMeasurable i j hij u hu hQuadratic have hEnergyPath : ∀ᵐ x ∂μ, IntegrableOn (fun s => (H s x) ^ 2 * hazard s * (∑ i : Fin n, riskIndicator i s x)) (Icc 0 u) volume := by let e : Sample n → ℝ → ℝ := fun x s => (H s x) ^ 2 * hazard s * (∑ i : Fin n, riskIndicator i s x) let ν := (volume : Measure ℝ).restrict (Icc 0 u) have he_meas : Measurable (fun p : Sample n × ℝ => e p.1 p.2) := by have hrisk (i : Fin n) : Measurable (fun p : Sample n × ℝ => riskIndicator i p.2 p.1) := by unfold riskIndicator have hf : Measurable (fun p : Sample n × ℝ => (p.1 i).1) := by fun_prop have hc : Measurable (fun p : Sample n × ℝ => (p.1 i).2) := by fun_prop have hs : MeasurableSet {p : Sample n × ℝ | 0 ≤ p.2 ∧ p.2 ≤ (p.1 i).1 ∧ p.2 ≤ (p.1 i).2} := by simpa only [Set.ofPred_and, Set.inter_assoc, id_eq] using (((show MeasurableSet {p : Sample n × ℝ | (0 : ℝ) ≤ p.2} from measurableSet_le measurable_const measurable_snd).inter (measurableSet_le measurable_snd hf)).inter (measurableSet_le measurable_snd hc)) exact measurable_const.ite hs measurable_const exact (((hMeasurable.comp (measurable_snd.prodMk measurable_fst)).pow_const 2).mul (hHazard.2.1.comp measurable_snd)).mul (Finset.measurable_fun_sum _ (fun i _ => hrisk i)) have he_nonneg (x : Sample n) (s : ℝ) : 0 ≤ e x s := by dsimp [e] exact mul_nonneg (mul_nonneg (sq_nonneg _) (hHazard.2.2.1 s)) (Finset.sum_nonneg (fun i _ => by unfold riskIndicator; split_ifs <;> norm_num)) have he_inner_meas : Measurable (fun x => ∫⁻ s, ofReal (e x s) ∂ν) := he_meas.ennreal_ofReal.lintegral_prod_right' have hfinite : (∫⁻ x, ∫⁻ s, ofReal (e x s) ∂ν ∂μ) ≠ ⊤ := hQuadratic filter_upwards [ae_lt_top he_inner_meas hfinite] with x hx exact (lintegral_ofReal_ne_top_iff_integrable (he_meas.comp (measurable_const.prodMk measurable_id)).aestronglyMeasurable (Filter.Eventually.of_forall (he_nonneg x))).1 hx.ne have hQPath : ∀ᵐ x ∂μ, ∀ i : Fin n, IntegrableOn (fun s => (H s x) ^ 2 * hazard s * riskIndicator i s x) (Icc 0 u) volume := by apply ae_all_iff.2 intro i filter_upwards [hEnergyPath] with x hx have hmeas : Measurable (fun s => (H s x) ^ 2 * hazard s * riskIndicator i s x) := by have hrisk : Measurable (fun s : ℝ => riskIndicator i s x) := by unfold riskIndicator have hs : MeasurableSet {s : ℝ | 0 ≤ s ∧ s ≤ (x i).1 ∧ s ≤ (x i).2} := by simpa only [Set.ofPred_and, Set.inter_assoc, id_eq] using (((show MeasurableSet {s : ℝ | (0 : ℝ) ≤ s} from measurableSet_le measurable_const measurable_id).inter (measurableSet_le measurable_id measurable_const)).inter (measurableSet_le measurable_id measurable_const)) exact measurable_const.ite hs measurable_const exact ((hMeasurable.comp (measurable_id.prodMk measurable_const)).pow_const 2 |>.mul hHazard.2.1).mul hrisk exact hx.mono' hmeas.aestronglyMeasurable (Filter.Eventually.of_forall (fun s => by rw [Real.norm_eq_abs, abs_of_nonneg (mul_nonneg (mul_nonneg (sq_nonneg _) (hHazard.2.2.1 s)) (by unfold riskIndicator; split_ifs <;> norm_num))] exact mul_le_mul_of_nonneg_left (Finset.single_le_sum (f := fun j : Fin n => riskIndicator j s x) (fun j hj => by unfold riskIndicator; split_ifs <;> norm_num) (Finset.mem_univ i)) (mul_nonneg (sq_nonneg _) (hHazard.2.2.1 s)))) have hEnergyEq : (fun x => ∑ i : Fin n, Q i x) =ᵐ[μ] predictableEnergy hazard H u := by filter_upwards [hQPath] with x hx simp only [Q, predictableEnergy] rw [← integral_finsetSum univ (fun i _ => hx i)] congr 1 funext s rw [Finset.mul_sum] calc (∫ x : Sample n, (aggregateIntegral hazard H u x) ^ 2 ∂μ) = ∫ x : Sample n, ∑ i : Fin n, ∑ j : Fin n, J i x * J j x ∂μ := by apply integral_congr_ae filter_upwards [] with x simp only [aggregateIntegral, J, pow_two, Finset.sum_mul_sum] _ = ∑ i : Fin n, ∑ j : Fin n, ∫ x : Sample n, J i x * J j x ∂μ := by rw [integral_finsetSum univ (fun i _ => integrable_finsetSum univ (fun j _ => hProd i j))] apply Finset.sum_congr rfl intro i _ rw [integral_finsetSum univ (fun j _ => hProd i j)] _ = ∑ i : Fin n, ∫ x : Sample n, Q i x ∂μ := by apply Finset.sum_congr rfl intro i _ rw [Finset.sum_eq_single i] · simpa [pow_two] using hIso i · intro j _ hji exact hCross i j (Ne.symm hji) · simp _ = ∫ x : Sample n, predictableEnergy hazard H u x ∂μ := by rw [← integral_finsetSum univ (fun i _ => hQ i)] exact integral_congr_ae hEnergyEq
1 supporting declaration (lemmas, instances)
  • distinct_subject_integrals_orthogonal theorem — Suppose subjects are drawn independently with failure times following a nonnegative time law and independent censor times whose law has the given censor hazard, and let the integrand be left predictable and jointly measurable in time and sample. For two different subjects, a nonnegative horizon u, and finite expected quadratic energy, the expected product of the two subjects' integrals against their compensated censor counts up to u is zero.
    n :
    ℕ
    failureLaw censorLaw :
    hazard :
    ℝ → ℝ
    hFailure :
    hHazard :
    HasCensorHazard censorLaw hazard
    H :
    ℝ → Sample n → ℝ
    hPredictable :
    LeftPredictable H
    hMeasurable :
    Measurable (fun p : ℝ × Sample n => H p.1 p.2)
    i j :
    Fin n
    hij :
    i ≠ j
    u :
    ℝ
    hu :
    0 ≤ u
    hQuadratic :
    QuadraticEnergyFinite failureLaw censorLaw hazard H u
    (∫ x : Sample n, subjectIntegral hazard H i u x * subjectIntegral hazard H j u x ∂sampleLaw n failureLaw censorLaw)
    = 0
    Proof (Lean source)
    theorem distinct_subject_integrals_orthogonal {n : ℕ} (failureLaw censorLaw : Measure ℝ) (hazard : ℝ → ℝ) (hFailure : NonnegativeTimeLaw failureLaw) (hHazard : HasCensorHazard censorLaw hazard) (H : ℝ → Sample n → ℝ) (hPredictable : LeftPredictable H) (hMeasurable : Measurable (fun p : ℝ × Sample n => H p.1 p.2)) (i j : Fin n) (hij : i ≠ j) (u : ℝ) (hu : 0 ≤ u) (hQuadratic : QuadraticEnergyFinite failureLaw censorLaw hazard H u) : (∫ x : Sample n, subjectIntegral hazard H i u x * subjectIntegral hazard H j u x ∂sampleLaw n failureLaw censorLaw) = 0 := by /- Work in the sample probability law. Derive integrability of each subject's square directly from the event-payoff square and hazard-payoff square integrability lemmas, using `(a-b)^2 ≤ 2a²+2b²`; an equality of Bochner integrals alone does not establish integrability. Then use `memLp_two_iff_integrable_sq` and `MemLp.integrable_mul` for the product. `distinct_subject_integral_product_pathwise` expands that product into two jump/prefix terms minus two time integrals. Censor times differ almost surely by `distinct_censor_times_ae`. For each orientation (i,j), set P(s,x) := H(s,x) * subjectIntegralBefore hazard H j s x. The cross-prefix lemmas show that P is left predictable and jointly measurable. Use `cross_prefix_event_integrable` and `cross_prefix_compensator_integrable` for its two payoffs. Apply `predictable_censor_compensator` to identify the expectations. Finally integrate the pathwise expansion and cancel the two matched pairs. -/ classical let μ := sampleLaw n failureLaw censorLaw haveI : IsProbabilityMeasure failureLaw := ⟨hFailure.1⟩ haveI : IsProbabilityMeasure censorLaw := ⟨hHazard.1.1⟩ haveI : IsProbabilityMeasure μ := by dsimp [μ, sampleLaw] infer_instance have hSquare (k : Fin n) : AEStronglyMeasurable (subjectIntegral hazard H k u) μ ∧ Integrable (fun x : Sample n => (subjectIntegral hazard H k u x) ^ 2) μ := by let E : Sample n → ℝ := fun x => if (x k).2 ≤ u ∧ (x k).2 < (x k).1 then H (x k).2 x else 0 let A : Sample n → ℝ := fun x => ∫ s in Icc 0 u, H s x * hazard s * riskIndicator k s x ∂volume have hEmeas : Measurable E := by have hc : Measurable (fun x : Sample n => (x k).2) := by fun_prop have hf : Measurable (fun x : Sample n => (x k).1) := by fun_prop exact (hMeasurable.comp (hc.prodMk measurable_id)).ite ((measurableSet_le hc measurable_const).inter (measurableSet_lt hc hf)) measurable_const have hAmeas : Measurable A := by let F : Sample n × ℝ → ℝ := fun p => H p.2 p.1 * hazard p.2 * riskIndicator k p.2 p.1 have hrisk : Measurable (fun p : Sample n × ℝ => riskIndicator k p.2 p.1) := by unfold riskIndicator have hf : Measurable (fun p : Sample n × ℝ => (p.1 k).1) := by fun_prop have hc : Measurable (fun p : Sample n × ℝ => (p.1 k).2) := by fun_prop have hs : MeasurableSet {p : Sample n × ℝ | 0 ≤ p.2 ∧ p.2 ≤ (p.1 k).1 ∧ p.2 ≤ (p.1 k).2} := by simpa only [Set.ofPred_and, Set.inter_assoc, id_eq] using (((show MeasurableSet {p : Sample n × ℝ | (0 : ℝ) ≤ p.2} from measurableSet_le measurable_const measurable_snd).inter (measurableSet_le measurable_snd hf)).inter (measurableSet_le measurable_snd hc)) exact measurable_const.ite hs measurable_const have hF : Measurable F := ((hMeasurable.comp (measurable_snd.prodMk measurable_fst)).mul (hHazard.2.1.comp measurable_snd)).mul hrisk exact hF.stronglyMeasurable.integral_prod_right'.measurable have hELp : MemLp E 2 μ := (memLp_two_iff_integrable_sq hEmeas.aestronglyMeasurable).2 (subject_event_payoff_square_integrable failureLaw censorLaw hazard hFailure hHazard H hPredictable hMeasurable k u hQuadratic) have hALp : MemLp A 2 μ := (memLp_two_iff_integrable_sq hAmeas.aestronglyMeasurable).2 (subject_hazard_square_integrable failureLaw censorLaw hazard hFailure hHazard H hMeasurable k u hQuadratic) constructor · change AEStronglyMeasurable (E - A) μ exact (hEmeas.sub hAmeas).aestronglyMeasurable · simpa [subjectIntegral, E, A, Pi.sub_apply] using (hELp.sub hALp).integrable_sq have hProduct : Integrable (fun x : Sample n => subjectIntegral hazard H i u x * subjectIntegral hazard H j u x) μ := by exact ((memLp_two_iff_integrable_sq (hSquare i).1).2 (hSquare i).2).integrable_mul ((memLp_two_iff_integrable_sq (hSquare j).1).2 (hSquare j).2) let P : Fin n → Fin n → ℝ → Sample n → ℝ := fun _ l s x => H s x * subjectIntegralBefore hazard H l s x let E : Fin n → Fin n → Sample n → ℝ := fun k l x => if (x k).2 ≤ u ∧ (x k).2 < (x k).1 then P k l (x k).2 x else 0 let C : Fin n → Fin n → Sample n → ℝ := fun k l x => ∫ s in Icc 0 u, subjectIntegralBefore hazard H l s x * H s x * hazard s * riskIndicator k s x ∂volume have hPair (k l : Fin n) (hkl : k ≠ l) : Integrable (E k l) μ ∧ Integrable (C k l) μ ∧ (∫ x, E k l x ∂μ) = ∫ x, C k l x ∂μ := by have hPpred : LeftPredictable (fun s x => H s x * subjectIntegralBefore hazard H l s x) := by intro s x y hxy exact congrArg₂ (· * ·) (hPredictable s x y hxy) (subjectIntegralBefore_leftPredictable hazard H hPredictable l s x y hxy) have hPmeas : Measurable (fun p : ℝ × Sample n => H p.1 p.2 * subjectIntegralBefore hazard H l p.1 p.2) := hMeasurable.mul (subjectIntegralBefore_jointMeasurable hazard hHazard.2.1 H hMeasurable l) have hE : Integrable (fun x : Sample n => if (x k).2 ≤ u ∧ (x k).2 < (x k).1 then H (x k).2 x * subjectIntegralBefore hazard H l (x k).2 x else 0) μ := cross_prefix_event_integrable failureLaw censorLaw hazard hFailure hHazard H hPredictable hMeasurable k l u hQuadratic have hC : Integrable (fun x : Sample n => ∫ s in Icc 0 u, subjectIntegralBefore hazard H l s x * H s x * hazard s * riskIndicator k s x ∂volume) μ := cross_prefix_compensator_integrable failureLaw censorLaw hazard hFailure hHazard H hPredictable hMeasurable k l u hQuadratic have hEq := predictable_censor_compensator failureLaw censorLaw hazard hFailure hHazard (fun s x => H s x * subjectIntegralBefore hazard H l s x) hPpred hPmeas k u hE refine ⟨?_, ?_, ?_⟩ · simpa [E, P] using hE · simpa [C] using hC · convert hEq using 1 congr 1 funext x apply integral_congr_ae filter_upwards [] with s ring have hi := hPair i j hij have hj := hPair j i (Ne.symm hij) have hPathi := subject_hazard_path_integrable_ae failureLaw censorLaw hazard hHazard H hMeasurable i u hQuadratic have hPathj := subject_hazard_path_integrable_ae failureLaw censorLaw hazard hHazard H hMeasurable j u hQuadratic have hCensori : ∀ᵐ x ∂μ, 0 ≤ (x i).2 := by have hC : ∀ᵐ c ∂censorLaw, 0 ≤ c := (mem_ae_iff_prob_eq_one measurableSet_Ici).2 hHazard.1.2 have hPair : ∀ᵐ z ∂failureLaw.prod censorLaw, 0 ≤ z.2 := by apply (Measure.ae_prod_iff_ae_ae (measurableSet_le measurable_const measurable_snd)).2 filter_upwards [] with a exact hC unfold μ sampleLaw exact (Measure.tendsto_eval_ae_ae (μ := fun _ : Fin n => failureLaw.prod censorLaw) (i := i)) hPair have hCensorj : ∀ᵐ x ∂μ, 0 ≤ (x j).2 := by have hC : ∀ᵐ c ∂censorLaw, 0 ≤ c := (mem_ae_iff_prob_eq_one measurableSet_Ici).2 hHazard.1.2 have hPair : ∀ᵐ z ∂failureLaw.prod censorLaw, 0 ≤ z.2 := by apply (Measure.ae_prod_iff_ae_ae (measurableSet_le measurable_const measurable_snd)).2 filter_upwards [] with a exact hC unfold μ sampleLaw exact (Measure.tendsto_eval_ae_ae (μ := fun _ : Fin n => failureLaw.prod censorLaw) (i := j)) hPair have hPath : ∀ᵐ x ∂μ, subjectIntegral hazard H i u x * subjectIntegral hazard H j u x = E i j x + E j i x - C i j x - C j i x := by filter_upwards [hPathi, hPathj, hCensori, hCensorj, distinct_censor_times_ae failureLaw censorLaw hazard hFailure hHazard i j hij] with x hpi hpj hci hcj hne simpa [E, P, C] using distinct_subject_integral_product_pathwise hazard H i j u hu x hci hcj hne hpi hpj have hRhs : Integrable (fun x => E i j x + E j i x - C i j x - C j i x) μ := hProduct.congr hPath calc (∫ x, subjectIntegral hazard H i u x * subjectIntegral hazard H j u x ∂μ) = ∫ x, E i j x + E j i x - C i j x - C j i x ∂μ := integral_congr_ae hPath _ = 0 := by change (∫ x, (E i j + E j i - C i j - C j i) x ∂μ) = 0 rw [integral_sub' ((hi.1.add hj.1).sub hi.2.1) hj.2.1, integral_sub' (hi.1.add hj.1) hi.2.1, integral_add' hi.1 hj.1, hi.2.2, hj.2.2] ring
    Causalean.Stat.RecurrentEvent.CountingProcess.distinct_subject_integrals_orthogonal · Causalean/Stat/RecurrentEvent/CountingProcess/Isometry.lean:18
Isometry­Integrability 1 core · 4 supporting Integrability lemmas behind the finite-sample aggregate isometry and pairwise orthogonality for predictable integrals against compensated censor-event counts: integrability of each subject's quadratic hazard energy, squa ★ subject_energy_integrable

Integrability lemmas behind the finite-sample aggregate isometry and pairwise orthogonality for predictable integrals against compensated censor-event counts: integrability of each subject's quadratic hazard energy, square integrability of event payoffs, and integrability of the cross-prefix event and compensator terms. The isometry and orthogonality statements themselves are in the Isometry module.

theorem subject_energy_integrable reviewed
Causalean.Stat.RecurrentEvent.CountingProcess

Suppose subjects are drawn independently with failure times following a nonnegative time law and independent censor times whose law has the given censor hazard, and let the integrand be jointly measurable in time and sample. For a horizon u, finite expected quadratic energy, and an integrable predictable quadratic energy summed over all subjects, each single subject's quadratic hazard energy up to u is integrable over samples.

Formal statement
n :
ℕ
failureLaw censorLaw :
hazard :
ℝ → ℝ
hFailure :
hHazard :
HasCensorHazard censorLaw hazard
H :
ℝ → Sample n → ℝ
hMeasurable :
Measurable (fun p : ℝ × Sample n => H p.1 p.2)
i :
Fin n
u :
ℝ
hQuadratic :
QuadraticEnergyFinite failureLaw censorLaw hazard H u
hEnergy :
Integrable (predictableEnergy hazard H u) (sampleLaw n failureLaw censorLaw)
Integrable (fun x : Sample n => ∫ s in Icc 0 u, (H s x) ^ 2 * hazard s * riskIndicator i s x ∂volume) (sampleLaw n failureLaw censorLaw)
Proof (Lean source)
theorem subject_energy_integrable {n : ℕ} (failureLaw censorLaw : Measure ℝ) (hazard : ℝ → ℝ) (hFailure : NonnegativeTimeLaw failureLaw) (hHazard : HasCensorHazard censorLaw hazard) (H : ℝ → Sample n → ℝ) (hMeasurable : Measurable (fun p : ℝ × Sample n => H p.1 p.2)) (i : Fin n) (u : ℝ) (hQuadratic : QuadraticEnergyFinite failureLaw censorLaw hazard H u) (hEnergy : Integrable (predictableEnergy hazard H u) (sampleLaw n failureLaw censorLaw)) : Integrable (fun x : Sample n => ∫ s in Icc 0 u, (H s x) ^ 2 * hazard s * riskIndicator i s x ∂volume) (sampleLaw n failureLaw censorLaw) := by /- The nonnegative subject energy density is bounded by the sum density. `hQuadratic` gives almost-everywhere path integrability via Tonelli. Use integral monotonicity on those paths and `hEnergy` for the outer domination; joint measurability supplies the subject integral's strong measurability. -/ classical haveI : IsProbabilityMeasure failureLaw := ⟨hFailure.1⟩ haveI : IsProbabilityMeasure censorLaw := ⟨hHazard.1.1⟩ let μ := sampleLaw n failureLaw censorLaw let ν := (volume : Measure ℝ).restrict (Icc 0 u) haveI : IsProbabilityMeasure μ := by dsimp [μ, sampleLaw] infer_instance let e : Sample n → ℝ → ℝ := fun x s => (H s x) ^ 2 * hazard s * (∑ j : Fin n, riskIndicator j s x) let f : Sample n → ℝ → ℝ := fun x s => (H s x) ^ 2 * hazard s * riskIndicator i s x have hrisk (j : Fin n) : Measurable (fun p : Sample n × ℝ => riskIndicator j p.2 p.1) := by unfold riskIndicator have hf : Measurable (fun p : Sample n × ℝ => (p.1 j).1) := by fun_prop have hc : Measurable (fun p : Sample n × ℝ => (p.1 j).2) := by fun_prop have hs : MeasurableSet {p : Sample n × ℝ | 0 ≤ p.2 ∧ p.2 ≤ (p.1 j).1 ∧ p.2 ≤ (p.1 j).2} := by simpa only [Set.ofPred_and, Set.inter_assoc, id_eq] using (((show MeasurableSet {p : Sample n × ℝ | (0 : ℝ) ≤ p.2} from measurableSet_le measurable_const measurable_snd).inter (measurableSet_le measurable_snd hf)).inter (measurableSet_le measurable_snd hc)) exact measurable_const.ite hs measurable_const have hbase : Measurable (fun p : Sample n × ℝ => (H p.2 p.1) ^ 2 * hazard p.2) := ((hMeasurable.comp (measurable_snd.prodMk measurable_fst)).pow_const 2).mul (hHazard.2.1.comp measurable_snd) have he_meas : Measurable (fun p : Sample n × ℝ => e p.1 p.2) := hbase.mul (Finset.measurable_fun_sum _ (fun j _ => hrisk j)) have hf_meas : Measurable (fun p : Sample n × ℝ => f p.1 p.2) := hbase.mul (hrisk i) have he_nonneg (x : Sample n) (s : ℝ) : 0 ≤ e x s := by dsimp [e] exact mul_nonneg (mul_nonneg (sq_nonneg _) (hHazard.2.2.1 s)) (Finset.sum_nonneg (fun j _ => by unfold riskIndicator; split_ifs <;> norm_num)) have hf_nonneg (x : Sample n) (s : ℝ) : 0 ≤ f x s := by dsimp [f] exact mul_nonneg (mul_nonneg (sq_nonneg _) (hHazard.2.2.1 s)) (by unfold riskIndicator split_ifs <;> norm_num) have hf_le (x : Sample n) (s : ℝ) : f x s ≤ e x s := by dsimp [f, e] exact mul_le_mul_of_nonneg_left (Finset.single_le_sum (f := fun j : Fin n => riskIndicator j s x) (fun j hj => by unfold riskIndicator; split_ifs <;> norm_num) (Finset.mem_univ i)) (mul_nonneg (sq_nonneg _) (hHazard.2.2.1 s)) have he_joint : Integrable (fun p : Sample n × ℝ => e p.1 p.2) (μ.prod ν) := by apply (lintegral_ofReal_ne_top_iff_integrable he_meas.aestronglyMeasurable (Filter.Eventually.of_forall (fun p => he_nonneg p.1 p.2))).1 rw [lintegral_prod _ he_meas.ennreal_ofReal.aemeasurable] exact hQuadratic have he_path : ∀ᵐ x ∂μ, Integrable (e x) ν := he_joint.prod_right_ae have hf_path : ∀ᵐ x ∂μ, Integrable (f x) ν := by filter_upwards [he_path] with x hx exact hx.mono' (hf_meas.comp (measurable_const.prodMk measurable_id)).aestronglyMeasurable (Filter.Eventually.of_forall (fun s => by rw [Real.norm_eq_abs, abs_of_nonneg (hf_nonneg x s)] exact hf_le x s)) have hf_outer_meas : AEStronglyMeasurable (fun x => ∫ s, f x s ∂ν) μ := hf_meas.stronglyMeasurable.integral_prod_right'.aestronglyMeasurable apply integrable_of_le_of_le hf_outer_meas (Filter.Eventually.of_forall (fun x => integral_nonneg (hf_nonneg x))) ?_ (integrable_const 0) hEnergy filter_upwards [hf_path, he_path] with x hx hxe exact integral_mono hx hxe (hf_le x)
4 supporting declarations (lemmas, instances)
  • subject_event_payoff_square_integrable theorem — Suppose subjects are drawn independently with failure times following a nonnegative time law and independent censor times whose law has the given censor hazard, and let the integrand be left predictable and jointly measurable in time and sample. For a horizon u and finite expected quadratic energy, the squared payoff at subject i's observed censor event by u, taken as zero when no such event occurs, is integrable over samples.
    n :
    ℕ
    failureLaw censorLaw :
    hazard :
    ℝ → ℝ
    hFailure :
    hHazard :
    HasCensorHazard censorLaw hazard
    H :
    ℝ → Sample n → ℝ
    hPredictable :
    LeftPredictable H
    hMeasurable :
    Measurable (fun p : ℝ × Sample n => H p.1 p.2)
    i :
    Fin n
    u :
    ℝ
    hQuadratic :
    QuadraticEnergyFinite failureLaw censorLaw hazard H u
    Integrable (fun x : Sample n => (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) ^ 2) (sampleLaw n failureLaw censorLaw)
    Proof (Lean source)
    theorem subject_event_payoff_square_integrable {n : ℕ} (failureLaw censorLaw : Measure ℝ) (hazard : ℝ → ℝ) (hFailure : NonnegativeTimeLaw failureLaw) (hHazard : HasCensorHazard censorLaw hazard) (H : ℝ → Sample n → ℝ) (hPredictable : LeftPredictable H) (hMeasurable : Measurable (fun p : ℝ × Sample n => H p.1 p.2)) (i : Fin n) (u : ℝ) (hQuadratic : QuadraticEnergyFinite failureLaw censorLaw hazard H u) : Integrable (fun x : Sample n => (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) ^ 2) (sampleLaw n failureLaw censorLaw) := by /- Use the nonnegative extended compensator identity `predictable_censor_compensator_lintegral` with payoff H². Bound its right side by `hQuadratic`, then turn the finite nonnegative lintegral into integrability. The Bochner equality in `subject_event_square_expectation` alone cannot certify this, since a nonintegrable Bochner integral is defined to be zero. -/ classical let μ := sampleLaw n failureLaw censorLaw let Q : ℝ → Sample n → ℝ := fun s x => (H s x) ^ 2 have hQpred : LeftPredictable Q := by intro s x y hxy simpa [Q] using congrArg (fun z : ℝ => z ^ 2) (hPredictable s x y hxy) have hQmeas : Measurable (fun p : ℝ × Sample n => Q p.1 p.2) := hMeasurable.pow_const 2 have hQnonneg : ∀ s x, 0 ≤ Q s x := fun s x => sq_nonneg _ have hlin := predictable_censor_compensator_lintegral failureLaw censorLaw hazard hFailure hHazard Q hQpred hQmeas hQnonneg i u have hfinite : (∫⁻ x : Sample n, ∫⁻ s in Icc 0 u, ofReal (Q s x * hazard s * riskIndicator i s x) ∂volume ∂μ) ≠ ⊤ := by have hle : (∫⁻ x : Sample n, ∫⁻ s in Icc 0 u, ofReal (Q s x * hazard s * riskIndicator i s x) ∂volume ∂μ) ≤ ∫⁻ x : Sample n, ∫⁻ s in Icc 0 u, ofReal ((H s x) ^ 2 * hazard s * (∑ j : Fin n, riskIndicator j s x)) ∂volume ∂μ := by apply lintegral_mono intro x apply lintegral_mono intro s apply ENNReal.ofReal_le_ofReal dsimp [Q] apply mul_le_mul_of_nonneg_left · exact Finset.single_le_sum (f := fun j : Fin n => riskIndicator j s x) (fun j hj => by unfold riskIndicator; split_ifs <;> norm_num) (Finset.mem_univ i) · exact mul_nonneg (sq_nonneg _) (hHazard.2.2.1 s) exact ne_top_of_le_ne_top hQuadratic hle have hm : Measurable (fun x : Sample n => if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then Q (x i).2 x else 0) := by have hc : Measurable (fun x : Sample n => (x i).2) := by fun_prop have hf : Measurable (fun x : Sample n => (x i).1) := by fun_prop exact (hQmeas.comp (hc.prodMk measurable_id)).ite ((measurableSet_le hc measurable_const).inter (measurableSet_lt hc hf)) measurable_const have hEventInt : Integrable (fun x : Sample n => if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then Q (x i).2 x else 0) μ := by apply (lintegral_ofReal_ne_top_iff_integrable hm.aestronglyMeasurable (by filter_upwards [] with x split_ifs <;> positivity)).1 rw [hlin] exact hfinite simpa only [Q, ite_pow, zero_pow (by decide : (2 : ℕ) ≠ 0)] using hEventInt
    Causalean.Stat.RecurrentEvent.CountingProcess.subject_event_payoff_square_integrable · Causalean/Stat/RecurrentEvent/CountingProcess/IsometryIntegrability.lean:116
  • cross_prefix_at_event_square_integrable theorem — Suppose subjects are drawn independently with failure times following a nonnegative time law and independent censor times whose law has the given censor hazard, and let the integrand be left predictable and jointly measurable in time and sample. For a horizon u and finite expected quadratic energy, the square of subject j's strict-past compensated integral evaluated at subject i's observed censor event by u, taken as zero when no such event occurs, is integrable over samples.
    n :
    ℕ
    failureLaw censorLaw :
    hazard :
    ℝ → ℝ
    hFailure :
    hHazard :
    HasCensorHazard censorLaw hazard
    H :
    ℝ → Sample n → ℝ
    hPredictable :
    LeftPredictable H
    hMeasurable :
    Measurable (fun p : ℝ × Sample n => H p.1 p.2)
    i j :
    Fin n
    u :
    ℝ
    hQuadratic :
    QuadraticEnergyFinite failureLaw censorLaw hazard H u
    Integrable (fun x : Sample n => (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then subjectIntegralBefore hazard H j (x i).2 x else 0) ^ 2) (sampleLaw n failureLaw censorLaw)
    Proof (Lean source)
    theorem cross_prefix_at_event_square_integrable {n : ℕ} (failureLaw censorLaw : Measure ℝ) (hazard : ℝ → ℝ) (hFailure : NonnegativeTimeLaw failureLaw) (hHazard : HasCensorHazard censorLaw hazard) (H : ℝ → Sample n → ℝ) (hPredictable : LeftPredictable H) (hMeasurable : Measurable (fun p : ℝ × Sample n => H p.1 p.2)) (i j : Fin n) (u : ℝ) (hQuadratic : QuadraticEnergyFinite failureLaw censorLaw hazard H u) : Integrable (fun x : Sample n => (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then subjectIntegralBefore hazard H j (x i).2 x else 0) ^ 2) (sampleLaw n failureLaw censorLaw) := by /- On the event branch, expand `subjectIntegralBefore`. The jump payoff for j is bounded by its horizon-u jump payoff in absolute value; the strict-past hazard integral is bounded by the absolute hazard payoff on [0,u]. Apply (a-b)² ≤ 2a²+2b². The jump square is integrable after establishing `subject_event_payoff_square_integrable` with subject j; the hazard square is integrable by `subject_hazard_square_integrable` (its absolute-payoff version is in `SubjectMoments`). Restrict the pathwise comparison to the full-measure set of nonnegative failure/censor times, since a negative censor time need not appear in the horizon-u event payoff. Joint measurability follows from `subjectIntegralBefore_jointMeasurable`. The strict boundary changes the hazard integral only on a Lebesgue-null singleton. -/ classical let μ := sampleLaw n failureLaw censorLaw let f : Sample n → ℝ := fun x => if (x j).2 ≤ u ∧ (x j).2 < (x j).1 then H (x j).2 x else 0 let g : Sample n → ℝ := fun x => ∫ s in Icc 0 u, |H s x * hazard s * riskIndicator j s x| ∂volume have hJump : Integrable (fun x => (f x) ^ 2) μ := subject_event_payoff_square_integrable failureLaw censorLaw hazard hFailure hHazard H hPredictable hMeasurable j u hQuadratic have hAbsQ : QuadraticEnergyFinite failureLaw censorLaw hazard (fun s x => |H s x|) u := by simpa only [QuadraticEnergyFinite, sq_abs] using hQuadratic have hAbs : Integrable (fun x => (g x) ^ 2) μ := by have h := subject_hazard_square_integrable failureLaw censorLaw hazard hFailure hHazard (fun s x => |H s x|) (by fun_prop) j u hAbsQ convert h using 1 funext x congr 1 apply integral_congr_ae filter_upwards [] with s rw [abs_mul, abs_mul, abs_of_nonneg (hHazard.2.2.1 s)] have hr : 0 ≤ riskIndicator j s x := by unfold riskIndicator split_ifs <;> norm_num rw [abs_of_nonneg hr] have hMeas : AEStronglyMeasurable (fun x : Sample n => (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then subjectIntegralBefore hazard H j (x i).2 x else 0) ^ 2) μ := by have hc : Measurable (fun x : Sample n => (x i).2) := by fun_prop have hf : Measurable (fun x : Sample n => (x i).1) := by fun_prop exact (((subjectIntegralBefore_jointMeasurable hazard hHazard.2.1 H hMeasurable j).comp (hc.prodMk measurable_id)).ite ((measurableSet_le hc measurable_const).inter (measurableSet_lt hc hf)) measurable_const).pow_const 2 |>.aestronglyMeasurable have hCensor : ∀ᵐ x ∂μ, 0 ≤ (x j).2 := by haveI : IsProbabilityMeasure failureLaw := ⟨hFailure.1⟩ haveI : IsProbabilityMeasure censorLaw := ⟨hHazard.1.1⟩ haveI : IsProbabilityMeasure (failureLaw.prod censorLaw) := inferInstance have hC : ∀ᵐ c ∂censorLaw, 0 ≤ c := (mem_ae_iff_prob_eq_one measurableSet_Ici).2 hHazard.1.2 have hPair : ∀ᵐ z ∂failureLaw.prod censorLaw, 0 ≤ z.2 := by apply (Measure.ae_prod_iff_ae_ae (measurableSet_le measurable_const measurable_snd)).2 filter_upwards [] with a exact hC unfold μ sampleLaw exact (Measure.tendsto_eval_ae_ae (μ := fun _ : Fin n => failureLaw.prod censorLaw) (i := j)) hPair have hPath := subject_hazard_path_integrable_ae failureLaw censorLaw hazard hHazard H hMeasurable j u hQuadratic haveI : IsProbabilityMeasure failureLaw := ⟨hFailure.1⟩ haveI : IsProbabilityMeasure censorLaw := ⟨hHazard.1.1⟩ haveI : IsProbabilityMeasure μ := by dsimp [μ, sampleLaw] infer_instance apply integrable_of_le_of_le hMeas (Filter.Eventually.of_forall (fun x => sq_nonneg _)) ?_ (integrable_const 0) ((hJump.const_mul 2).add (hAbs.const_mul 2)) filter_upwards [hCensor, hPath] with x hxC hxPath by_cases hi : (x i).2 ≤ u ∧ (x i).2 < (x i).1 · have hJumpBound : |(if (x j).2 < (x i).2 ∧ (x j).2 < (x j).1 then H (x j).2 x else 0)| ≤ |f x| := by by_cases hj : (x j).2 < (x i).2 ∧ (x j).2 < (x j).1 · have hju : (x j).2 ≤ u ∧ (x j).2 < (x j).1 := ⟨le_trans (le_of_lt hj.1) hi.1, hj.2⟩ simp [hj, hju, f] · simp [hj] have hIntBound : |∫ s in Icc 0 (x i).2, H s x * hazard s * riskIndicator j s x ∂volume| ≤ g x := by let F : ℝ → ℝ := fun s => H s x * hazard s * riskIndicator j s x have hsub : Icc 0 (x i).2 ⊆ Icc 0 u := by intro s hs exact ⟨hs.1, le_trans hs.2 hi.1⟩ have hAbsPath : IntegrableOn (fun s => |F s|) (Icc 0 u) volume := by exact hxPath.abs calc |∫ s in Icc 0 (x i).2, F s ∂volume| ≤ ∫ s in Icc 0 (x i).2, |F s| ∂volume := abs_integral_le_integral_abs _ ≤ ∫ s in Icc 0 u, |F s| ∂volume := setIntegral_mono_set hAbsPath (Filter.Eventually.of_forall (fun s => abs_nonneg _)) (Filter.Eventually.of_forall (fun s hs => hsub hs)) have hmain : |subjectIntegralBefore hazard H j (x i).2 x| ≤ |f x| + g x := by unfold subjectIntegralBefore calc |_ - _| ≤ _ + _ := abs_sub _ _ _ ≤ |f x| + g x := add_le_add hJumpBound hIntBound have hg : 0 ≤ g x := by dsimp [g] exact integral_nonneg (fun s => abs_nonneg _) have hsquare : (subjectIntegralBefore hazard H j (x i).2 x) ^ 2 ≤ 2 * (f x) ^ 2 + 2 * (g x) ^ 2 := by have hsq := (sq_le_sq₀ (abs_nonneg _) (add_nonneg (abs_nonneg _) hg)).2 hmain nlinarith [sq_nonneg (|f x| - g x), sq_abs (f x), sq_abs (subjectIntegralBefore hazard H j (x i).2 x)] simpa [hi] using hsquare · simp only [hi, ↓reduceIte, zero_pow (by decide : (2 : ℕ) ≠ 0)] change 0 ≤ 2 * f x ^ 2 + 2 * g x ^ 2 positivity
    Causalean.Stat.RecurrentEvent.CountingProcess.cross_prefix_at_event_square_integrable · Causalean/Stat/RecurrentEvent/CountingProcess/IsometryIntegrability.lean:188
  • cross_prefix_event_integrable theorem — Suppose subjects are drawn independently with failure times following a nonnegative time law and independent censor times whose law has the given censor hazard, and let the integrand be left predictable and jointly measurable in time and sample. For a horizon u and finite expected quadratic energy, the payoff at subject i's observed censor event by u times subject j's strict-past compensated integral at that event, taken as zero when no such event occurs, is integrable over samples.
    n :
    ℕ
    failureLaw censorLaw :
    hazard :
    ℝ → ℝ
    hFailure :
    hHazard :
    HasCensorHazard censorLaw hazard
    H :
    ℝ → Sample n → ℝ
    hPredictable :
    LeftPredictable H
    hMeasurable :
    Measurable (fun p : ℝ × Sample n => H p.1 p.2)
    i j :
    Fin n
    u :
    ℝ
    hQuadratic :
    QuadraticEnergyFinite failureLaw censorLaw hazard H u
    Integrable (fun x : Sample n => if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x * subjectIntegralBefore hazard H j (x i).2 x else 0) (sampleLaw n failureLaw censorLaw)
    Proof (Lean source)
    theorem cross_prefix_event_integrable {n : ℕ} (failureLaw censorLaw : Measure ℝ) (hazard : ℝ → ℝ) (hFailure : NonnegativeTimeLaw failureLaw) (hHazard : HasCensorHazard censorLaw hazard) (H : ℝ → Sample n → ℝ) (hPredictable : LeftPredictable H) (hMeasurable : Measurable (fun p : ℝ × Sample n => H p.1 p.2)) (i j : Fin n) (u : ℝ) (hQuadratic : QuadraticEnergyFinite failureLaw censorLaw hazard H u) : Integrable (fun x : Sample n => if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x * subjectIntegralBefore hazard H j (x i).2 x else 0) (sampleLaw n failureLaw censorLaw) := by /- Use `subject_event_payoff_square_integrable` for the event payoff of i and `cross_prefix_at_event_square_integrable` for the strict-past integral of j on the same event. Obtain measurability of the first factor from `hMeasurable` and of the second from `subjectIntegralBefore_jointMeasurable`. Convert both square-integrability claims with Mathlib's `memLp_two_iff_integrable_sq`, then apply `MemLp.integrable_mul` with exponents 2 and 2. The product of the two event-restricted factors simplifies to the target. -/ let μ := sampleLaw n failureLaw censorLaw let f : Sample n → ℝ := fun x => if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0 let g : Sample n → ℝ := fun x => if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then subjectIntegralBefore hazard H j (x i).2 x else 0 have hc : Measurable (fun x : Sample n => (x i).2) := by fun_prop have ht : Measurable (fun x : Sample n => (x i).1) := by fun_prop have hevent : MeasurableSet {x : Sample n | (x i).2 ≤ u ∧ (x i).2 < (x i).1} := (measurableSet_le hc measurable_const).inter (measurableSet_lt hc ht) have hfmeas : AEStronglyMeasurable f μ := ((hMeasurable.comp (hc.prodMk measurable_id)).ite hevent measurable_const).aestronglyMeasurable have hgmeas : AEStronglyMeasurable g μ := (((subjectIntegralBefore_jointMeasurable hazard hHazard.2.1 H hMeasurable j).comp (hc.prodMk measurable_id)).ite hevent measurable_const).aestronglyMeasurable have hfLp : MemLp f 2 μ := (MeasureTheory.memLp_two_iff_integrable_sq hfmeas).2 (by simpa only [f, μ] using subject_event_payoff_square_integrable failureLaw censorLaw hazard hFailure hHazard H hPredictable hMeasurable i u hQuadratic) have hgLp : MemLp g 2 μ := (MeasureTheory.memLp_two_iff_integrable_sq hgmeas).2 (by simpa only [g, μ] using cross_prefix_at_event_square_integrable failureLaw censorLaw hazard hFailure hHazard H hPredictable hMeasurable i j u hQuadratic) have hfg : Integrable (f * g) μ := hfLp.integrable_mul hgLp convert hfg using 1 funext x by_cases hx : (x i).2 ≤ u ∧ (x i).2 < (x i).1 <;> simp [f, g, hx]
    Causalean.Stat.RecurrentEvent.CountingProcess.cross_prefix_event_integrable · Causalean/Stat/RecurrentEvent/CountingProcess/IsometryIntegrability.lean:328
  • cross_prefix_compensator_integrable theorem — Suppose subjects are drawn independently with failure times following a nonnegative time law and independent censor times whose law has the given censor hazard, and let the integrand be left predictable and jointly measurable in time and sample. For a horizon u and finite expected quadratic energy, the integral from 0 to u of subject j's strict-past compensated integral times the integrand times the hazard times subject i's at-risk indicator is integrable over samples.
    n :
    ℕ
    failureLaw censorLaw :
    hazard :
    ℝ → ℝ
    hFailure :
    hHazard :
    HasCensorHazard censorLaw hazard
    H :
    ℝ → Sample n → ℝ
    hPredictable :
    LeftPredictable H
    hMeasurable :
    Measurable (fun p : ℝ × Sample n => H p.1 p.2)
    i j :
    Fin n
    u :
    ℝ
    hQuadratic :
    QuadraticEnergyFinite failureLaw censorLaw hazard H u
    Integrable (fun x : Sample n => ∫ s in Icc 0 u, subjectIntegralBefore hazard H j s x * H s x * hazard s * riskIndicator i s x ∂volume) (sampleLaw n failureLaw censorLaw)
    Proof (Lean source)
    theorem cross_prefix_compensator_integrable {n : ℕ} (failureLaw censorLaw : Measure ℝ) (hazard : ℝ → ℝ) (hFailure : NonnegativeTimeLaw failureLaw) (hHazard : HasCensorHazard censorLaw hazard) (H : ℝ → Sample n → ℝ) (hPredictable : LeftPredictable H) (hMeasurable : Measurable (fun p : ℝ × Sample n => H p.1 p.2)) (i j : Fin n) (u : ℝ) (hQuadratic : QuadraticEnergyFinite failureLaw censorLaw hazard H u) : Integrable (fun x : Sample n => ∫ s in Icc 0 u, subjectIntegralBefore hazard H j s x * H s x * hazard s * riskIndicator i s x ∂volume) (sampleLaw n failureLaw censorLaw) := by /- Let P(s,x) be the product of H and the strict-past integral for j. `subjectIntegralBefore_leftPredictable` and `subjectIntegralBefore_jointMeasurable` make P an admissible predictable payoff. `predictable_censor_compensator_integrable` derives the signed compensator's integrability from its event payoff. -/ let P : ℝ → Sample n → ℝ := fun s x => H s x * subjectIntegralBefore hazard H j s x have hPpred : LeftPredictable P := by intro s x y hxy exact congrArg₂ (· * ·) (hPredictable s x y hxy) (subjectIntegralBefore_leftPredictable hazard H hPredictable j s x y hxy) have hPmeas : Measurable (fun p : ℝ × Sample n => P p.1 p.2) := hMeasurable.mul (subjectIntegralBefore_jointMeasurable hazard hHazard.2.1 H hMeasurable j) have hEvent : Integrable (fun x : Sample n => if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then P (x i).2 x else 0) (sampleLaw n failureLaw censorLaw) := by convert cross_prefix_event_integrable failureLaw censorLaw hazard hFailure hHazard H hPredictable hMeasurable i j u hQuadratic using 1 have hComp := predictable_censor_compensator_integrable failureLaw censorLaw hazard hFailure hHazard P hPpred hPmeas i u hEvent convert hComp using 1 funext x apply integral_congr_ae filter_upwards [] with s dsimp [P] ring
    Causalean.Stat.RecurrentEvent.CountingProcess.cross_prefix_compensator_integrable · Causalean/Stat/RecurrentEvent/CountingProcess/IsometryIntegrability.lean:389
Nelson­Aalen 1 core · 7 supporting The zero-safe Nelson–Aalen inverse-risk integrand specializes the counting process isometry. ★ nelsonAalen_squared_risk

The zero-safe Nelson–Aalen inverse-risk integrand specializes the counting process isometry. An independent random evaluation time weights the fixed-time risk integrand by the evaluation-time survival probability.

theorem nelsonAalen_squared_risk reviewed
Causalean.Stat.RecurrentEvent.CountingProcess

Under independent sampling with failure times following a nonnegative time law and independent censor times whose law has the given censor hazard, at a nonnegative horizon u the expected squared compensated Nelson–Aalen error equals the integral over times from 0 to u of the censor hazard times the expected zero-safe inverse risk-set size.

Formal statement
n :
ℕ
failureLaw censorLaw :
hazard :
ℝ → ℝ
hFailure :
hHazard :
HasCensorHazard censorLaw hazard
u :
ℝ
hu :
0 ≤ u
(∫ x : Sample n, (nelsonAalenError hazard u x) ^ 2 ∂sampleLaw n failureLaw censorLaw)
= ∫ s in Icc 0 u, hazard s * (∫ x : Sample n, inverseRisk s x ∂sampleLaw n failureLaw censorLaw) ∂volume
Proof (Lean source)
theorem nelsonAalen_squared_risk {n : ℕ} (failureLaw censorLaw : Measure ℝ) (hazard : ℝ → ℝ) (hFailure : NonnegativeTimeLaw failureLaw) (hHazard : HasCensorHazard censorLaw hazard) (u : ℝ) (hu : 0 ≤ u) : (∫ x : Sample n, (nelsonAalenError hazard u x) ^ 2 ∂sampleLaw n failureLaw censorLaw) = ∫ s in Icc 0 u, hazard s * (∫ x : Sample n, inverseRisk s x ∂sampleLaw n failureLaw censorLaw) ∂volume := by letI : IsProbabilityMeasure failureLaw := ⟨hFailure.1⟩ letI : IsProbabilityMeasure censorLaw := ⟨hHazard.1.1⟩ letI : IsProbabilityMeasure (sampleLaw n failureLaw censorLaw) := by unfold sampleLaw infer_instance let μ := sampleLaw n failureLaw censorLaw let ν := volume.restrict (Icc 0 u) have hprod : Integrable (fun p : Sample n × ℝ => hazard p.2 * inverseRisk p.2 p.1) (μ.prod ν) := inverseRisk_hazard_integrable_prod failureLaw censorLaw hazard hFailure hHazard u have hrewrite (x : Sample n) (s : ℝ) : (inverseRisk s x) ^ 2 * hazard s * (∑ i : Fin n, riskIndicator i s x) = hazard s * inverseRisk s x := by calc _ = hazard s * ((inverseRisk s x) ^ 2 * (∑ i : Fin n, riskIndicator i s x)) := by ring _ = hazard s * inverseRisk s x := by rw [inverseRisk_square_risk] calc _ = ∫ x : Sample n, predictableEnergy hazard (inverseRisk (n := n)) u x ∂μ := by simpa only [nelsonAalenError, μ] using aggregate_integral_isometry failureLaw censorLaw hazard hFailure hHazard (inverseRisk (n := n)) inverseRisk_leftPredictable inverseRisk_jointMeasurable u hu (inverseRisk_quadratic_energy_finite failureLaw censorLaw hazard hFailure hHazard u) (inverseRisk_energy_integrable failureLaw censorLaw hazard hFailure hHazard u) _ = ∫ x : Sample n, ∫ s : ℝ, hazard s * inverseRisk s x ∂ν ∂μ := by simp_rw [predictableEnergy, hrewrite] rfl _ = ∫ s : ℝ, ∫ x : Sample n, hazard s * inverseRisk s x ∂μ ∂ν := by exact integral_integral_swap hprod _ = ∫ s : ℝ, hazard s * (∫ x : Sample n, inverseRisk s x ∂μ) ∂ν := by simp_rw [integral_const_mul] _ = _ := rfl
7 supporting declarations (lemmas, instances)
No­Ties 1 core · 0 supporting Distinct subjects have almost surely different censor times under an iid sample law with an absolutely continuous censor hazard. ★ distinct_censor_times_ae

Distinct subjects have almost surely different censor times under an iid sample law with an absolutely continuous censor hazard. This removes the common-jump term in pairwise counting-process calculations.

theorem distinct_censor_times_ae reviewed
Causalean.Stat.RecurrentEvent.CountingProcess

Under independent sampling with failure times following a nonnegative time law and independent censor times whose law has the given (absolutely continuous) censor hazard, two different subjects almost surely have different censor times.

Formal statement
n :
ℕ
failureLaw censorLaw :
hazard :
ℝ → ℝ
hFailure :
hHazard :
HasCensorHazard censorLaw hazard
i j :
Fin n
hij :
i ≠ j
∀ᵐ x ∂sampleLaw n failureLaw censorLaw, (x i).2 ≠ (x j).2
Proof (Lean source)
theorem distinct_censor_times_ae {n : ℕ} (failureLaw censorLaw : Measure ℝ) (hazard : ℝ → ℝ) (hFailure : NonnegativeTimeLaw failureLaw) (hHazard : HasCensorHazard censorLaw hazard) (i j : Fin n) (hij : i ≠ j) : ∀ᵐ x ∂sampleLaw n failureLaw censorLaw, (x i).2 ≠ (x j).2 := by haveI : IsProbabilityMeasure failureLaw := ⟨hFailure.1⟩ haveI : IsProbabilityMeasure censorLaw := ⟨hHazard.1.1⟩ haveI : NullSingletonClass censorLaw := by rw [hHazard.2.2.2.2] infer_instance haveI : IsProbabilityMeasure (failureLaw.prod censorLaw) := inferInstance haveI : IsProbabilityMeasure (sampleLaw n failureLaw censorLaw) := by unfold sampleLaw infer_instance have hmap (k : Fin n) : (sampleLaw n failureLaw censorLaw).map (fun x => (x k).2) = censorLaw := by change (Measure.pi (fun _ : Fin n => failureLaw.prod censorLaw)).map (fun x => (x k).2) = censorLaw calc _ = Measure.map snd (Measure.map (Function.eval k) (Measure.pi (fun _ : Fin n => failureLaw.prod censorLaw))) := by rw [Measure.map_map measurable_snd (measurable_pi_apply k)] rfl _ = censorLaw := by rw [(measurePreserving_eval (fun _ : Fin n => failureLaw.prod censorLaw) k).map_eq, Measure.map_snd_prod, measure_univ, one_smul] have hind : IndepFun (fun x : Sample n => (x i).2) (fun x : Sample n => (x j).2) (sampleLaw n failureLaw censorLaw) := by have h := ProbabilityTheory.iIndepFun_pi (μ := fun _ : Fin n => failureLaw.prod censorLaw) (X := fun _ => snd) (fun _ => measurable_snd.aemeasurable) exact h.indepFun hij have hprod : (∀ᵐ z ∂censorLaw.prod censorLaw, z.1 ≠ z.2) := by apply (Measure.ae_prod_iff_ae_ae (measurableSet_eq_fun measurable_fst measurable_snd).compl).2 filter_upwards [] with a exact (censorLaw.ae_ne a).mono (fun b hb => Ne.symm hb) have hpair := hind.map_prod_eq_prod_map_map ((measurable_pi_apply i).snd.aemeasurable : AEMeasurable (fun x : Sample n => (x i).2) (sampleLaw n failureLaw censorLaw)) ((measurable_pi_apply j).snd.aemeasurable : AEMeasurable (fun x : Sample n => (x j).2) (sampleLaw n failureLaw censorLaw)) rw [hmap i, hmap j] at hpair have hp : MeasurableSet {z : ℝ × ℝ | z.1 ≠ z.2} := (measurableSet_eq_fun measurable_fst measurable_snd).compl exact (ae_map_iff (by fun_prop : AEMeasurable (fun x : Sample n => ((x i).2, (x j).2)) (sampleLaw n failureLaw censorLaw)) hp).1 (hpair.symm ▸ hprod)
Causalean.Stat.RecurrentEvent.CountingProcess.distinct_censor_times_ae · Causalean/Stat/RecurrentEvent/CountingProcess/NoTies.lean:17 · uses HasCensorHazard , NonnegativeTimeLaw , Sample , sampleLaw
Pathwise­Stop 1 core · 0 supporting A subject's at-risk hazard integral stops at its censor time. ★ subject_hazard_stops_at_censor

A subject's at-risk hazard integral stops at its censor time. This pathwise fact identifies the compensator value used at an observed censor jump.

theorem subject_hazard_stops_at_censor reviewed
Causalean.Stat.RecurrentEvent.CountingProcess

If a subject's censor time occurs by the horizon u, then for a censor hazard the integral of the subject's at-risk payoff weighted by the hazard from 0 to u equals its integral from 0 to the censor time, since the subject leaves the risk set after censoring.

Formal statement
n :
ℕ
hazard :
ℝ → ℝ
H :
ℝ → Sample n → ℝ
i :
Fin n
x :
u :
ℝ
hcu :
(x i).2 ≤ u
(∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume)
= ∫ s in Icc 0 (x i).2, H s x * hazard s * riskIndicator i s x ∂volume
Proof (Lean source)
theorem subject_hazard_stops_at_censor {n : ℕ} (hazard : ℝ → ℝ) (H : ℝ → Sample n → ℝ) (i : Fin n) (x : Sample n) (u : ℝ) (hcu : (x i).2 ≤ u) : (∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume) = ∫ s in Icc 0 (x i).2, H s x * hazard s * riskIndicator i s x ∂volume := by apply setIntegral_eq_of_subset_of_forall_sdiff_eq_zero measurableSet_Icc · exact Set.Icc_subset_Icc_right hcu · intro s hs have hcs : (x i).2 < s := by by_contra h exact hs.2 ⟨hs.1.1, le_of_not_gt h⟩ simp [riskIndicator, not_le.mpr hcs]
Causalean.Stat.RecurrentEvent.CountingProcess.subject_hazard_stops_at_censor · Causalean/Stat/RecurrentEvent/CountingProcess/PathwiseStop.lean:16 · uses Sample , riskIndicator
Predictable­Prefix 1 core · 1 supporting Predictability and joint measurability of a cumulative at-risk hazard payoff multiplied by its current predictable payoff. ★ subject_prefix_mixed_predictable

Predictability and joint measurability of a cumulative at-risk hazard payoff multiplied by its current predictable payoff. These properties prepare the signed compensator identity used in subjectwise isometry.

theorem subject_prefix_mixed_predictable reviewed
Causalean.Stat.RecurrentEvent.CountingProcess

For any censor hazard, if the payoff process is left predictable, then the process whose value at time s is subject i's hazard-weighted accumulated at-risk payoff up to s times the payoff at s is also left predictable.

Formal statement
n :
ℕ
hazard :
ℝ → ℝ
H :
ℝ → Sample n → ℝ
hPredictable :
LeftPredictable H
i :
Fin n
LeftPredictable (fun s x => (∫ t in Icc 0 s, H t x * hazard t * riskIndicator i t x ∂volume) * H s x)
Proof (Lean source)
theorem subject_prefix_mixed_predictable {n : ℕ} (hazard : ℝ → ℝ) (H : ℝ → Sample n → ℝ) (hPredictable : LeftPredictable H) (i : Fin n) : LeftPredictable (fun s x => (∫ t in Icc 0 s, H t x * hazard t * riskIndicator i t x ∂volume) * H s x) := by have hRisk (t : ℝ) (z : Sample n) (hf : t ≠ (z i).1) (hc : t ≠ (z i).2) : riskIndicator i t z = if 0 ≤ t ∧ censorCount i t z = 0 ∧ failureCount i t z = 0 then 1 else 0 := by by_cases h0 : 0 ≤ t · rcases lt_or_gt_of_ne hf with htf | htf · rcases lt_or_gt_of_ne hc with htc | htc · simp [riskIndicator, censorCount, failureCount, h0, htf, htc, le_of_lt] · have hcf : (z i).2 < (z i).1 := lt_trans htc htf simp [riskIndicator, censorCount, failureCount, h0, htf, htc, hcf, le_of_lt] · rcases lt_or_gt_of_ne hc with htc | htc · have hfc : (z i).1 < (z i).2 := lt_trans htf htc simp [riskIndicator, censorCount, failureCount, h0, htf, htc, hfc, le_of_lt] · by_cases hfc : (z i).1 ≤ (z i).2 · simp [riskIndicator, censorCount, failureCount, h0, htf, htc, hfc, le_of_lt] · have hcf : (z i).2 < (z i).1 := lt_of_not_ge hfc simp [riskIndicator, censorCount, failureCount, h0, htf, htc, hcf, le_of_lt] · simp [riskIndicator, censorCount, failureCount, h0] have hNe (a : ℝ) : ∀ᵐ t ∂(volume : Measure ℝ), t ≠ a := by rw [ae_iff] simpa only [not_ne_iff, Set.ofPred_eq_eq_singleton] using (measure_singleton a : (volume : Measure ℝ) {a} = 0) intro s x y hHist have hHs : H s x = H s y := hPredictable s x y hHist have hInt : (∫ t in Icc 0 s, H t x * hazard t * riskIndicator i t x ∂volume) = ∫ t in Icc 0 s, H t y * hazard t * riskIndicator i t y ∂volume := by rw [integral_Icc_eq_integral_Ico, integral_Icc_eq_integral_Ico] apply integral_congr_ae have hxF := ae_restrict_of_ae (s := Ico 0 s) (hNe (x i).1) have hxC := ae_restrict_of_ae (s := Ico 0 s) (hNe (x i).2) have hyF := ae_restrict_of_ae (s := Ico 0 s) (hNe (y i).1) have hyC := ae_restrict_of_ae (s := Ico 0 s) (hNe (y i).2) have htMem : ∀ᵐ t ∂(volume : Measure ℝ).restrict (Ico 0 s), t ∈ Ico 0 s := ae_restrict_mem measurableSet_Ico filter_upwards [hxF, hxC, hyF, hyC, htMem] with t hxF hxC hyF hyC ht have hHistory := hHist i t ht.2 have hHt : H t x = H t y := hPredictable t x y (fun j u hu => hHist j u (lt_trans hu ht.2)) rw [hHt, hRisk t x hxF hxC, hRisk t y hyF hyC, hHistory.1, hHistory.2] change (∫ t in Icc 0 s, H t x * hazard t * riskIndicator i t x ∂volume) * H s x = (∫ t in Icc 0 s, H t y * hazard t * riskIndicator i t y ∂volume) * H s y rw [hInt, hHs]
Causalean.Stat.RecurrentEvent.CountingProcess.subject_prefix_mixed_predictable · Causalean/Stat/RecurrentEvent/CountingProcess/PredictablePrefix.lean:17 · uses LeftPredictable , Sample , riskIndicator
1 supporting declaration (lemmas, instances)
  • subject_prefix_mixed_jointMeasurable theorem — If the censor hazard is measurable and the payoff is jointly measurable in time and sample, then subject i's accumulated hazard-weighted at-risk payoff up to each time, multiplied by the payoff at that time, is jointly measurable in time and sample.
    n :
    ℕ
    hazard :
    ℝ → ℝ
    hHazardMeasurable :
    Measurable hazard
    H :
    ℝ → Sample n → ℝ
    hMeasurable :
    Measurable (fun p : ℝ × Sample n => H p.1 p.2)
    i :
    Fin n
    Measurable (fun p : ℝ × Sample n => (∫ t in Icc 0 p.1, H t p.2 * hazard t * riskIndicator i t p.2 ∂volume) * H p.1 p.2)
    Proof (Lean source)
    theorem subject_prefix_mixed_jointMeasurable {n : ℕ} (hazard : ℝ → ℝ) (hHazardMeasurable : Measurable hazard) (H : ℝ → Sample n → ℝ) (hMeasurable : Measurable (fun p : ℝ × Sample n => H p.1 p.2)) (i : Fin n) : Measurable (fun p : ℝ × Sample n => (∫ t in Icc 0 p.1, H t p.2 * hazard t * riskIndicator i t p.2 ∂volume) * H p.1 p.2) := by let F : (ℝ × Sample n) × ℝ → ℝ := fun q => if 0 ≤ q.2 ∧ q.2 ≤ q.1.1 then H q.2 q.1.2 * hazard q.2 * riskIndicator i q.2 q.1.2 else 0 have hq2 : Measurable (fun q : (ℝ × Sample n) × ℝ => q.2) := by fun_prop have hq1 : Measurable (fun q : (ℝ × Sample n) × ℝ => q.1.1) := by fun_prop have hf : Measurable (fun q : (ℝ × Sample n) × ℝ => (q.1.2 i).1) := by fun_prop have hc : Measurable (fun q : (ℝ × Sample n) × ℝ => (q.1.2 i).2) := by fun_prop have hp : Measurable (fun q : (ℝ × Sample n) × ℝ => (q.2, q.1.2)) := by fun_prop have hRisk : Measurable (fun q : (ℝ × Sample n) × ℝ => riskIndicator i q.2 q.1.2) := by unfold riskIndicator apply Measurable.ite · simpa only [Set.ofPred_and, Set.inter_assoc] using ((measurableSet_le (measurable_const : Measurable (fun _ : (ℝ × Sample n) × ℝ => (0 : ℝ))) hq2).inter (measurableSet_le hq2 hf)).inter (measurableSet_le hq2 hc) · exact measurable_const · exact measurable_const have hF : Measurable F := by dsimp [F] apply Measurable.ite · simpa only [Set.ofPred_and] using (measurableSet_le (measurable_const : Measurable (fun _ : (ℝ × Sample n) × ℝ => (0 : ℝ))) hq2).inter (measurableSet_le hq2 hq1) · exact ((hMeasurable.comp hp).mul (hHazardMeasurable.comp hq2)).mul hRisk · exact measurable_const have hI : Measurable (fun p : ℝ × Sample n => ∫ t, F (p, t) ∂volume) := hF.stronglyMeasurable.integral_prod_right'.measurable have hEq : ∀ p : ℝ × Sample n, (∫ t, F (p, t) ∂volume) = ∫ t in Icc 0 p.1, H t p.2 * hazard t * riskIndicator i t p.2 ∂volume := by intro p rw [← integral_indicator measurableSet_Icc] congr 1 funext t simp only [F, indicator, Set.mem_Icc] rw [show (fun p : ℝ × Sample n => ∫ t, F (p, t) ∂volume) = (fun p => ∫ t in Icc 0 p.1, H t p.2 * hazard t * riskIndicator i t p.2 ∂volume) from funext hEq] at hI exact hI.mul hMeasurable
    Causalean.Stat.RecurrentEvent.CountingProcess.subject_prefix_mixed_jointMeasurable · Causalean/Stat/RecurrentEvent/CountingProcess/PredictablePrefix.lean:77
Product­Resampling 1 core · 2 supporting Coordinate resampling under the finite iid law. ★ lintegral_resample_censor

Coordinate resampling under the finite iid law. Integrating out an original censor time and drawing a fresh censor time leaves the law of the sample unchanged. This product-measure fact is the disintegration step for the predictable censor-compensator identity.

theorem lintegral_resample_censor reviewed
Causalean.Stat.RecurrentEvent.CountingProcess

Under independent sampling with failure times following a nonnegative time law and censor times following a nonnegative time law, the expectation of a nonnegative measurable function of the sample is unchanged when one subject's censor time is redrawn independently from the censor law, as an extended nonnegative integral.

Formal statement
n :
ℕ
failureLaw censorLaw :
hFailure :
hCensor :
F :
hF :
i :
Fin n
(∫⁻ x : Sample n, F x ∂sampleLaw n failureLaw censorLaw)
= ∫⁻ x : Sample n, ∫⁻ c : ℝ, F (update x i ((x i).1, c)) ∂censorLaw ∂sampleLaw n failureLaw censorLaw
Proof (Lean source)
theorem lintegral_resample_censor {n : ℕ} (failureLaw censorLaw : Measure ℝ) (hFailure : NonnegativeTimeLaw failureLaw) (hCensor : NonnegativeTimeLaw censorLaw) (F : Sample n → ENNReal) (hF : Measurable F) (i : Fin n) : (∫⁻ x : Sample n, F x ∂sampleLaw n failureLaw censorLaw) = ∫⁻ x : Sample n, ∫⁻ c : ℝ, F (update x i ((x i).1, c)) ∂censorLaw ∂sampleLaw n failureLaw censorLaw := by classical have : IsProbabilityMeasure failureLaw := ⟨hFailure.1⟩ have : IsProbabilityMeasure censorLaw := ⟨hCensor.1⟩ let μ : Fin n → Measure (ℝ × ℝ) := fun _ => failureLaw.prod censorLaw let G : Sample n → ENNReal := fun x => ∫⁻ c : ℝ, F (update x i ((x i).1, c)) ∂censorLaw have hG : Measurable G := by dsimp [G] apply Measurable.lintegral_prod_right fun_prop change (∫⁻ x, F x ∂Measure.pi μ) = ∫⁻ x, G x ∂Measure.pi μ apply lintegral_eq_of_lmarginal_eq {i} hF hG rw [lmarginal_singleton, lmarginal_singleton] funext x dsimp [μ, G] simp only [Function.update_idem] rw [lintegral_prod _ (by fun_prop)] rw [lintegral_prod _ (by fun_prop)] simp
Causalean.Stat.RecurrentEvent.CountingProcess.lintegral_resample_censor · Causalean/Stat/RecurrentEvent/CountingProcess/ProductResampling.lean:18 · uses NonnegativeTimeLaw , Sample , sampleLaw
2 supporting declarations (lemmas, instances)
  • lintegral_censor_event_resample theorem — Under independent sampling with failure times following a nonnegative time law and censor times following a nonnegative time law, for a payoff process jointly measurable in time and sample, the expected payoff at subject i's observed censor event by time u equals the expectation obtained by drawing that subject's censor time afresh from the censor law, holding the rest of the sample fixed, and evaluating the payoff at the fresh time in the updated sample, as extended nonnegative integrals.
    n :
    ℕ
    failureLaw censorLaw :
    hFailure :
    hCensor :
    H :
    ℝ → Sample n → ℝ
    hMeasurable :
    Measurable (fun p : ℝ × Sample n => H p.1 p.2)
    i :
    Fin n
    u :
    ℝ
    (∫⁻ x : Sample n, ofReal (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) ∂sampleLaw n failureLaw censorLaw)
    = ∫⁻ x : Sample n, ∫⁻ c : ℝ, ofReal (if c ≤ u ∧ c < (x i).1 then H c (update x i ((x i).1, c)) else 0) ∂censorLaw ∂sampleLaw n failureLaw censorLaw
    Proof (Lean source)
    theorem lintegral_censor_event_resample {n : ℕ} (failureLaw censorLaw : Measure ℝ) (hFailure : NonnegativeTimeLaw failureLaw) (hCensor : NonnegativeTimeLaw censorLaw) (H : ℝ → Sample n → ℝ) (hMeasurable : Measurable (fun p : ℝ × Sample n => H p.1 p.2)) (i : Fin n) (u : ℝ) : (∫⁻ x : Sample n, ofReal (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) ∂sampleLaw n failureLaw censorLaw) = ∫⁻ x : Sample n, ∫⁻ c : ℝ, ofReal (if c ≤ u ∧ c < (x i).1 then H c (update x i ((x i).1, c)) else 0) ∂censorLaw ∂sampleLaw n failureLaw censorLaw := by classical let F : Sample n → ENNReal := fun x => ofReal (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) have hF : Measurable F := by dsimp [F] have hCensorCoord : Measurable (fun x : Sample n => (x i).2) := by fun_prop have hFailureCoord : Measurable (fun x : Sample n => (x i).1) := by fun_prop have hEvent : MeasurableSet {x : Sample n | (x i).2 ≤ u ∧ (x i).2 < (x i).1} := by exact (measurableSet_le hCensorCoord measurable_const).inter (measurableSet_lt hCensorCoord hFailureCoord) have hPair : Measurable (fun x : Sample n => ((x i).2, x)) := by fun_prop have hPayoff : Measurable (fun x : Sample n => H (x i).2 x) := hMeasurable.comp hPair exact ENNReal.measurable_ofReal.comp (hPayoff.ite hEvent measurable_const) simpa only [F, Function.update_self, fst, snd] using lintegral_resample_censor failureLaw censorLaw hFailure hCensor F hF i
    Causalean.Stat.RecurrentEvent.CountingProcess.lintegral_censor_event_resample · Causalean/Stat/RecurrentEvent/CountingProcess/ProductResampling.lean:52
  • distinct_censor_times_null theorem — Under independent sampling with failure times following a nonnegative time law and independent censor times whose law has the given (absolutely continuous) censor hazard, the event that two different subjects share the same censor time has probability zero.
    n :
    ℕ
    failureLaw censorLaw :
    hazard :
    ℝ → ℝ
    hFailure :
    hHazard :
    HasCensorHazard censorLaw hazard
    i j :
    Fin n
    hij :
    i ≠ j
    sampleLaw n failureLaw censorLaw {x : Sample n | (x i).2 = (x j).2} = 0
    Proof (Lean source)
    theorem distinct_censor_times_null {n : ℕ} (failureLaw censorLaw : Measure ℝ) (hazard : ℝ → ℝ) (hFailure : NonnegativeTimeLaw failureLaw) (hHazard : HasCensorHazard censorLaw hazard) (i j : Fin n) (hij : i ≠ j) : sampleLaw n failureLaw censorLaw {x : Sample n | (x i).2 = (x j).2} = 0 := by classical have hsingle (a : ℝ) : censorLaw {a} = 0 := by rw [hHazard.2.2.2.2, withDensity_apply _ (measurableSet_singleton a)] simp let F : Sample n → ENNReal := fun x => if (x i).2 = (x j).2 then 1 else 0 have hset : MeasurableSet {x : Sample n | (x i).2 = (x j).2} := by exact measurableSet_eq_fun (by fun_prop) (by fun_prop) have hF : Measurable F := by exact measurable_const.ite hset measurable_const have hmeasure : sampleLaw n failureLaw censorLaw {x : Sample n | (x i).2 = (x j).2} = ∫⁻ x : Sample n, F x ∂sampleLaw n failureLaw censorLaw := by simpa only [F, indicator, Set.mem_ofPred_eq, one_mul] using (lintegral_indicator_const hset (1 : ENNReal)).symm rw [hmeasure, lintegral_resample_censor failureLaw censorLaw hFailure hHazard.1 F hF i] simp only [F, Function.update_self, Function.update_of_ne (Ne.symm hij)] have hinner (x : Sample n) : (∫⁻ c : ℝ, (if c = (x j).2 then (1 : ENNReal) else 0) ∂censorLaw) = 0 := by have hs : MeasurableSet ({(x j).2} : Set ℝ) := measurableSet_singleton _ have h := (lintegral_indicator_const (μ := censorLaw) hs (1 : ENNReal)) simpa [indicator, hsingle] using h simp [hinner]
    Causalean.Stat.RecurrentEvent.CountingProcess.distinct_censor_times_null · Causalean/Stat/RecurrentEvent/CountingProcess/ProductResampling.lean:98
Random­Horizon 1 core · 0 supporting Tonelli's identity for integrating a nonnegative time kernel to an independent random horizon. ★ lintegral_random_horizon

Tonelli's identity for integrating a nonnegative time kernel to an independent random horizon. The horizon contributes its inclusive tail probability.

theorem lintegral_random_horizon reviewed
Causalean.Stat.RecurrentEvent.CountingProcess

For a random horizon drawn from a nonnegative time law and a nonnegative extended-valued measurable function of time, the expected integral of the function from 0 to the random horizon equals the integral over nonnegative times s of the function times the probability that the horizon is at least s.

Formal statement
evaluationLaw :
hEvaluation :
NonnegativeTimeLaw evaluationLaw
f :
ℝ → ENNReal
hf :
(∫⁻ u : ℝ, ∫⁻ s in Icc 0 u, f s ∂volume ∂evaluationLaw)
= ∫⁻ s : ℝ, f s * evaluationLaw (Ici s) ∂(volume.restrict (Ici (0 : ℝ)))
Proof (Lean source)
theorem lintegral_random_horizon (evaluationLaw : Measure ℝ) (hEvaluation : NonnegativeTimeLaw evaluationLaw) (f : ℝ → ENNReal) (hf : Measurable f) : (∫⁻ u : ℝ, ∫⁻ s in Icc 0 u, f s ∂volume ∂evaluationLaw) = ∫⁻ s : ℝ, f s * evaluationLaw (Ici s) ∂(volume.restrict (Ici (0 : ℝ))) := by /- Use Tonelli on `(u,s) ↦ 1_{0≤s≤u} f(s)`; the `u` section is `evaluationLaw (Ici s)` and the `s` section is the restricted time integral. -/ classical haveI : IsProbabilityMeasure evaluationLaw := ⟨hEvaluation.1⟩ have hkernel : Measurable (fun p : ℝ × ℝ => (Icc 0 p.1).indicator f p.2) := by have hset : MeasurableSet {p : ℝ × ℝ | 0 ≤ p.2 ∧ p.2 ≤ p.1} := (measurableSet_le measurable_const measurable_snd).inter (measurableSet_le measurable_snd measurable_fst) simpa only [indicator, Set.mem_Icc, Function.comp_def] using (@Measurable.ite (ℝ × ℝ) ENNReal (f ∘ snd) (fun _ => 0) _ _ (fun p => 0 ≤ p.2 ∧ p.2 ≤ p.1) (Classical.decPred _) hset (hf.comp measurable_snd) measurable_const) calc (∫⁻ u : ℝ, ∫⁻ s in Icc 0 u, f s ∂volume ∂evaluationLaw) = ∫⁻ u : ℝ, ∫⁻ s : ℝ, (Icc 0 u).indicator f s ∂volume ∂evaluationLaw := by apply lintegral_congr intro u exact (lintegral_indicator measurableSet_Icc f).symm _ = ∫⁻ s : ℝ, ∫⁻ u : ℝ, (Icc 0 u).indicator f s ∂evaluationLaw ∂volume := lintegral_lintegral_swap hkernel.aemeasurable _ = ∫⁻ s : ℝ, (Ici (0 : ℝ)).indicator (fun s => f s * evaluationLaw (Ici s)) s ∂volume := by apply lintegral_congr intro s by_cases hs : 0 ≤ s · have hsection : (fun u : ℝ => (Icc 0 u).indicator f s) = (Ici s).indicator (fun _ => f s) := by funext u simp [indicator, hs, Set.mem_Icc, Set.mem_Ici] rw [hsection, lintegral_indicator_const measurableSet_Ici] simp [indicator, hs] · have hsection : (fun u : ℝ => (Icc 0 u).indicator f s) = fun _ => 0 := by funext u simp [indicator, hs, Set.mem_Icc] rw [hsection] simp [indicator, hs] _ = ∫⁻ s : ℝ, f s * evaluationLaw (Ici s) ∂(volume.restrict (Ici (0 : ℝ))) := lintegral_indicator measurableSet_Ici _
Causalean.Stat.RecurrentEvent.CountingProcess.lintegral_random_horizon · Causalean/Stat/RecurrentEvent/CountingProcess/RandomHorizon.lean:16 · uses NonnegativeTimeLaw
Subject­Isometry 1 core · 5 supporting The single-subject predictable isometry for compensated censor counts, with square-integrability and cancellation lemmas for its two terms. ★ subject_integral_isometry

The single-subject predictable isometry for compensated censor counts, with square-integrability and cancellation lemmas for its two terms.

theorem subject_integral_isometry reviewed
Causalean.Stat.RecurrentEvent.CountingProcess

Suppose subjects are drawn independently with failure times following a nonnegative time law and independent censor times whose law has the given censor hazard, and let the integrand be left predictable and jointly measurable in time and sample. For a nonnegative horizon u and finite expected quadratic energy, the expected square of the subject's integral against its compensated censor count up to u equals the expected integral from 0 to u of the squared integrand times the hazard times the subject's at-risk indicator.

Formal statement
n :
ℕ
failureLaw censorLaw :
hazard :
ℝ → ℝ
hFailure :
hHazard :
HasCensorHazard censorLaw hazard
H :
ℝ → Sample n → ℝ
hPredictable :
LeftPredictable H
hMeasurable :
Measurable (fun p : ℝ × Sample n => H p.1 p.2)
i :
Fin n
u :
ℝ
hu :
0 ≤ u
hQuadratic :
QuadraticEnergyFinite failureLaw censorLaw hazard H u
(∫ x : Sample n, (subjectIntegral hazard H i u x) ^ 2 ∂sampleLaw n failureLaw censorLaw)
= ∫ x : Sample n, (∫ s in Icc 0 u, (H s x) ^ 2 * hazard s * riskIndicator i s x ∂volume) ∂sampleLaw n failureLaw censorLaw
Proof (Lean source)
theorem subject_integral_isometry {n : ℕ} (failureLaw censorLaw : Measure ℝ) (hazard : ℝ → ℝ) (hFailure : NonnegativeTimeLaw failureLaw) (hHazard : HasCensorHazard censorLaw hazard) (H : ℝ → Sample n → ℝ) (hPredictable : LeftPredictable H) (hMeasurable : Measurable (fun p : ℝ × Sample n => H p.1 p.2)) (i : Fin n) (u : ℝ) (hu : 0 ≤ u) (hQuadratic : QuadraticEnergyFinite failureLaw censorLaw hazard H u) : (∫ x : Sample n, (subjectIntegral hazard H i u x) ^ 2 ∂sampleLaw n failureLaw censorLaw) = ∫ x : Sample n, (∫ s in Icc 0 u, (H s x) ^ 2 * hazard s * riskIndicator i s x ∂volume) ∂sampleLaw n failureLaw censorLaw := by /- Write the subject integral as J - B. `subject_event_square_expectation` gives E[J²] = E[energy], while `subject_jump_compensator_cancellation` gives E[2 J B - B²] = 0. Establish integrability of J² from the event-square bridge and of B² from `subject_hazard_square_integrable`; then split the integral of (J - B)², using the cancellation identity. -/ classical let μ := sampleLaw n failureLaw censorLaw let Q : ℝ → Sample n → ℝ := fun s x => (H s x) ^ 2 have hQpred : LeftPredictable Q := by intro s x y hxy simpa [Q] using congrArg (fun z : ℝ => z ^ 2) (hPredictable s x y hxy) have hQmeas : Measurable (fun p : ℝ × Sample n => Q p.1 p.2) := hMeasurable.pow_const 2 have hlin := predictable_censor_compensator_lintegral failureLaw censorLaw hazard hFailure hHazard Q hQpred hQmeas (fun s x => sq_nonneg _) i u have hfinite : (∫⁻ x : Sample n, ∫⁻ s in Icc 0 u, ofReal (Q s x * hazard s * riskIndicator i s x) ∂volume ∂μ) ≠ ⊤ := by have hle : (∫⁻ x : Sample n, ∫⁻ s in Icc 0 u, ofReal (Q s x * hazard s * riskIndicator i s x) ∂volume ∂μ) ≤ ∫⁻ x : Sample n, ∫⁻ s in Icc 0 u, ofReal ((H s x) ^ 2 * hazard s * (∑ j : Fin n, riskIndicator j s x)) ∂volume ∂μ := by apply lintegral_mono intro x apply lintegral_mono intro s apply ENNReal.ofReal_le_ofReal dsimp [Q] apply mul_le_mul_of_nonneg_left · exact Finset.single_le_sum (f := fun j : Fin n => riskIndicator j s x) (fun j hj => by unfold riskIndicator; split_ifs <;> norm_num) (Finset.mem_univ i) · exact mul_nonneg (sq_nonneg _) (hHazard.2.2.1 s) exact ne_top_of_le_ne_top hQuadratic hle have hEventQ : Integrable (fun x : Sample n => if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then Q (x i).2 x else 0) μ := by have hm : Measurable (fun x : Sample n => if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then Q (x i).2 x else 0) := by have hc : Measurable (fun x : Sample n => (x i).2) := by fun_prop have hf : Measurable (fun x : Sample n => (x i).1) := by fun_prop exact (hQmeas.comp (hc.prodMk measurable_id)).ite ((measurableSet_le hc measurable_const).inter (measurableSet_lt hc hf)) measurable_const apply (lintegral_ofReal_ne_top_iff_integrable hm.aestronglyMeasurable (by filter_upwards [] with x split_ifs <;> positivity)).1 rw [hlin] exact hfinite have hEventSquare : Integrable (fun x : Sample n => (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) ^ 2) μ := by convert hEventQ using 1 <;> simp only [Q, ite_pow, zero_pow (by decide : (2 : ℕ) ≠ 0)] have hSquare := subject_hazard_square_integrable failureLaw censorLaw hazard hFailure hHazard H hMeasurable i u hQuadratic haveI : IsProbabilityMeasure failureLaw := ⟨hFailure.1⟩ haveI : IsProbabilityMeasure censorLaw := ⟨hHazard.1.1⟩ haveI : IsProbabilityMeasure (failureLaw.prod censorLaw) := inferInstance have hCensor : ∀ᵐ c ∂censorLaw, 0 ≤ c := (mem_ae_iff_prob_eq_one measurableSet_Ici).2 hHazard.1.2 have hPair : ∀ᵐ z ∂failureLaw.prod censorLaw, 0 ≤ z.2 := by apply (Measure.ae_prod_iff_ae_ae (measurableSet_le measurable_const measurable_snd)).2 filter_upwards [] with a exact hCensor have hCensorSample : ∀ᵐ x ∂μ, 0 ≤ (x i).2 := by unfold μ sampleLaw exact (Measure.tendsto_eval_ae_ae (μ := fun _ : Fin n => failureLaw.prod censorLaw) (i := i)) hPair have hStopped := subject_prefix_mixed_event_integrable failureLaw censorLaw hazard hFailure hHazard H hPredictable hMeasurable i u hu hQuadratic have hMixedAE : (fun x : Sample n => if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then (∫ t in Icc 0 (x i).2, H t x * hazard t * riskIndicator i t x ∂volume) * H (x i).2 x else 0) =ᵐ[μ] (fun x : Sample n => (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) * (∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume)) := by filter_upwards [hCensorSample, subject_hazard_path_integrable_ae failureLaw censorLaw hazard hHazard H hMeasurable i u hQuadratic] with x hc0 hPath by_cases hEvent : (x i).2 ≤ u ∧ (x i).2 < (x i).1 · simp only [if_pos hEvent] rw [mul_comm (H (x i).2 x), subject_mixed_event_stops hazard H i x u hEvent.1] · simp [hEvent] have hMixed := hStopped.congr hMixedAE have hCross : Integrable (fun x : Sample n => 2 * (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) * (∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume)) μ := by apply (hMixed.const_mul 2).congr filter_upwards [] with x ring have hCancel := hCross.sub hSquare calc (∫ x : Sample n, (subjectIntegral hazard H i u x) ^ 2 ∂μ) = ∫ x : Sample n, (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) ^ 2 - (2 * (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) * (∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume) - (∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume) ^ 2) ∂μ := by apply integral_congr_ae filter_upwards [] with x unfold subjectIntegral ring _ = (∫ x : Sample n, (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) ^ 2 ∂μ) - (∫ x : Sample n, 2 * (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) * (∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume) - (∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume) ^ 2 ∂μ) := integral_sub hEventSquare hCancel _ = _ := by rw [subject_jump_compensator_cancellation failureLaw censorLaw hazard hFailure hHazard H hPredictable hMeasurable i u hu hQuadratic, sub_zero] exact subject_event_square_expectation failureLaw censorLaw hazard hFailure hHazard H hPredictable hMeasurable i u hQuadratic
5 supporting declarations (lemmas, instances)
  • subject_hazard_square_integrable theorem — Suppose subjects are drawn independently with failure times following a nonnegative time law and independent censor times whose law has the given censor hazard, and let the payoff process be jointly measurable in time and sample. For a horizon u and finite expected quadratic energy, the square of subject i's accumulated hazard-weighted at-risk payoff up to u is integrable over samples.
    n :
    ℕ
    failureLaw censorLaw :
    hazard :
    ℝ → ℝ
    hFailure :
    hHazard :
    HasCensorHazard censorLaw hazard
    H :
    ℝ → Sample n → ℝ
    hMeasurable :
    Measurable (fun p : ℝ × Sample n => H p.1 p.2)
    i :
    Fin n
    u :
    ℝ
    hQuadratic :
    QuadraticEnergyFinite failureLaw censorLaw hazard H u
    Integrable (fun x : Sample n => (∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume) ^ 2) (sampleLaw n failureLaw censorLaw)
    Proof (Lean source)
    theorem subject_hazard_square_integrable {n : ℕ} (failureLaw censorLaw : Measure ℝ) (hazard : ℝ → ℝ) (hFailure : NonnegativeTimeLaw failureLaw) (hHazard : HasCensorHazard censorLaw hazard) (H : ℝ → Sample n → ℝ) (hMeasurable : Measurable (fun p : ℝ × Sample n => H p.1 p.2)) (i : Fin n) (u : ℝ) (hQuadratic : QuadraticEnergyFinite failureLaw censorLaw hazard H u) : Integrable (fun x : Sample n => (∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume) ^ 2) (sampleLaw n failureLaw censorLaw) := by /- Apply `subject_absolute_payoff_square_le_energy` on almost every path. The right side is a fixed finite hazard mass times subject energy; its expected integral is finite by `hQuadratic`. Joint measurability of the prefix integral supplies strong measurability of the square. -/ classical haveI : IsProbabilityMeasure failureLaw := ⟨hFailure.1⟩ haveI : IsProbabilityMeasure censorLaw := ⟨hHazard.1.1⟩ let μ := sampleLaw n failureLaw censorLaw let ν := (volume : Measure ℝ).restrict (Icc 0 u) haveI : IsProbabilityMeasure μ := by dsimp [μ, sampleLaw] infer_instance let e : Sample n → ℝ → ℝ := fun x s => (H s x) ^ 2 * hazard s * (∑ j : Fin n, riskIndicator j s x) have he_meas : Measurable (fun p : Sample n × ℝ => e p.1 p.2) := by have hrisk (j : Fin n) : Measurable (fun p : Sample n × ℝ => riskIndicator j p.2 p.1) := by unfold riskIndicator have hf : Measurable (fun p : Sample n × ℝ => (p.1 j).1) := by fun_prop have hc : Measurable (fun p : Sample n × ℝ => (p.1 j).2) := by fun_prop have hs : MeasurableSet {p : Sample n × ℝ | 0 ≤ p.2 ∧ p.2 ≤ (p.1 j).1 ∧ p.2 ≤ (p.1 j).2} := by simpa only [Set.ofPred_and, Set.inter_assoc, id_eq] using (((show MeasurableSet {p : Sample n × ℝ | (0 : ℝ) ≤ p.2} from measurableSet_le measurable_const measurable_snd).inter (measurableSet_le measurable_snd hf)).inter (measurableSet_le measurable_snd hc)) exact measurable_const.ite hs measurable_const exact (((hMeasurable.comp (measurable_snd.prodMk measurable_fst)).pow_const 2).mul (hHazard.2.1.comp measurable_snd)).mul (Finset.measurable_fun_sum _ (fun j _ => hrisk j)) have he_nonneg (x : Sample n) (s : ℝ) : 0 ≤ e x s := by dsimp [e] exact mul_nonneg (mul_nonneg (sq_nonneg _) (hHazard.2.2.1 s)) (Finset.sum_nonneg (fun j _ => by unfold riskIndicator; split_ifs <;> norm_num)) have he_joint : Integrable (fun p : Sample n × ℝ => e p.1 p.2) (μ.prod ν) := by apply (lintegral_ofReal_ne_top_iff_integrable he_meas.aestronglyMeasurable (Filter.Eventually.of_forall (fun p => he_nonneg p.1 p.2))).1 rw [lintegral_prod _ he_meas.ennreal_ofReal.aemeasurable] exact hQuadratic have he_outer : Integrable (fun x => ∫ s, e x s ∂ν) μ := he_joint.integral_prod_left have he_path : ∀ᵐ x ∂μ, Integrable (e x) ν := he_joint.prod_right_ae have hprefix : Measurable (fun x : Sample n => ∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume) := by let F : Sample n × ℝ → ℝ := fun p => H p.2 p.1 * hazard p.2 * riskIndicator i p.2 p.1 have hrisk : Measurable (fun p : Sample n × ℝ => riskIndicator i p.2 p.1) := by unfold riskIndicator have hf : Measurable (fun p : Sample n × ℝ => (p.1 i).1) := by fun_prop have hc : Measurable (fun p : Sample n × ℝ => (p.1 i).2) := by fun_prop have hs : MeasurableSet {p : Sample n × ℝ | 0 ≤ p.2 ∧ p.2 ≤ (p.1 i).1 ∧ p.2 ≤ (p.1 i).2} := by simpa only [Set.ofPred_and, Set.inter_assoc, id_eq] using (((show MeasurableSet {p : Sample n × ℝ | (0 : ℝ) ≤ p.2} from measurableSet_le measurable_const measurable_snd).inter (measurableSet_le measurable_snd hf)).inter (measurableSet_le measurable_snd hc)) exact measurable_const.ite hs measurable_const have hF : Measurable F := ((hMeasurable.comp (measurable_snd.prodMk measurable_fst)).mul (hHazard.2.1.comp measurable_snd)).mul hrisk exact hF.stronglyMeasurable.integral_prod_right'.measurable have hmeas : AEStronglyMeasurable (fun x : Sample n => (∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume) ^ 2) μ := (hprefix.pow_const 2).aestronglyMeasurable apply integrable_of_le_of_le hmeas (Filter.Eventually.of_forall (fun x => sq_nonneg _)) ?_ (integrable_const 0) (he_outer.const_mul (∫ s in Icc 0 u, hazard s ∂volume)) filter_upwards [subject_hazard_path_integrable_ae failureLaw censorLaw hazard hHazard H hMeasurable i u hQuadratic, he_path] with x hx hxe have henergy : Integrable (fun s => (H s x) ^ 2 * hazard s * riskIndicator i s x) ν := by have hm : Measurable (fun s => (H s x) ^ 2 * hazard s * riskIndicator i s x) := by have hrisk : Measurable (fun s : ℝ => riskIndicator i s x) := by unfold riskIndicator have hs : MeasurableSet {s : ℝ | 0 ≤ s ∧ s ≤ (x i).1 ∧ s ≤ (x i).2} := by simpa only [Set.ofPred_and, Set.inter_assoc, id_eq] using (((show MeasurableSet {s : ℝ | (0 : ℝ) ≤ s} from measurableSet_le measurable_const measurable_id).inter (measurableSet_le measurable_id measurable_const)).inter (measurableSet_le measurable_id measurable_const)) exact measurable_const.ite hs measurable_const exact (((hMeasurable.comp (measurable_id.prodMk measurable_const)).pow_const 2).mul hHazard.2.1).mul hrisk apply hxe.mono' hm.aestronglyMeasurable filter_upwards [] with s rw [Real.norm_eq_abs, abs_of_nonneg (mul_nonneg (mul_nonneg (sq_nonneg _) (hHazard.2.2.1 s)) (by unfold riskIndicator split_ifs <;> norm_num))] exact mul_le_mul_of_nonneg_left (Finset.single_le_sum (f := fun j : Fin n => riskIndicator j s x) (fun j hj => by unfold riskIndicator; split_ifs <;> norm_num) (Finset.mem_univ i)) (mul_nonneg (sq_nonneg _) (hHazard.2.2.1 s)) have hsq := subject_absolute_payoff_square_le_energy hazard hHazard.2.2.1 H i u x (hHazard.2.2.2.1 u) henergy have hmass : 0 ≤ ∫ s in Icc 0 u, hazard s ∂volume := integral_nonneg hHazard.2.2.1 have henergy_le : (∫ s in Icc 0 u, (H s x) ^ 2 * hazard s * riskIndicator i s x ∂volume) ≤ ∫ s, e x s ∂ν := by apply integral_mono henergy hxe intro s exact mul_le_mul_of_nonneg_left (Finset.single_le_sum (f := fun j : Fin n => riskIndicator j s x) (fun j hj => by unfold riskIndicator; split_ifs <;> norm_num) (Finset.mem_univ i)) (mul_nonneg (sq_nonneg _) (hHazard.2.2.1 s)) calc (∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume) ^ 2 ≤ (∫ s in Icc 0 u, |H s x * hazard s * riskIndicator i s x| ∂volume) ^ 2 := by have habs := abs_integral_le_integral_abs (μ := ν) (f := fun s => H s x * hazard s * riskIndicator i s x) have hnonneg : 0 ≤ ∫ s in Icc 0 u, |H s x * hazard s * riskIndicator i s x| ∂volume := integral_nonneg (fun s => abs_nonneg _) simpa only [sq_abs] using (pow_le_pow_left₀ (abs_nonneg _) habs 2) _ ≤ _ := hsq.trans (mul_le_mul_of_nonneg_left henergy_le hmass)
    Causalean.Stat.RecurrentEvent.CountingProcess.subject_hazard_square_integrable · Causalean/Stat/RecurrentEvent/CountingProcess/SubjectIsometry.lean:15
  • subject_hazard_square_expectation theorem — Suppose subjects have independent failure and censor times whose law has the given censor hazard, and let the payoff process be jointly measurable in time and sample. For a nonnegative horizon u and finite expected quadratic energy, the expected square of subject i's accumulated hazard-weighted at-risk payoff up to u equals the expected integral from 0 to u of twice the accumulated payoff times its current rate.
    n :
    ℕ
    failureLaw censorLaw :
    hazard :
    ℝ → ℝ
    hHazard :
    HasCensorHazard censorLaw hazard
    H :
    ℝ → Sample n → ℝ
    hMeasurable :
    Measurable (fun p : ℝ × Sample n => H p.1 p.2)
    i :
    Fin n
    u :
    ℝ
    hu :
    0 ≤ u
    hQuadratic :
    QuadraticEnergyFinite failureLaw censorLaw hazard H u
    (∫ x : Sample n, (∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume) ^ 2 ∂sampleLaw n failureLaw censorLaw)
    = ∫ x : Sample n, (∫ s in Icc 0 u, 2 * (∫ t in Icc 0 s, H t x * hazard t * riskIndicator i t x ∂volume) * (H s x * hazard s * riskIndicator i s x) ∂volume) ∂sampleLaw n failureLaw censorLaw
    Proof (Lean source)
    theorem subject_hazard_square_expectation {n : ℕ} (failureLaw censorLaw : Measure ℝ) (hazard : ℝ → ℝ) (hHazard : HasCensorHazard censorLaw hazard) (H : ℝ → Sample n → ℝ) (hMeasurable : Measurable (fun p : ℝ × Sample n => H p.1 p.2)) (i : Fin n) (u : ℝ) (hu : 0 ≤ u) (hQuadratic : QuadraticEnergyFinite failureLaw censorLaw hazard H u) : (∫ x : Sample n, (∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume) ^ 2 ∂sampleLaw n failureLaw censorLaw) = ∫ x : Sample n, (∫ s in Icc 0 u, 2 * (∫ t in Icc 0 s, H t x * hazard t * riskIndicator i t x ∂volume) * (H s x * hazard s * riskIndicator i s x) ∂volume) ∂sampleLaw n failureLaw censorLaw := by /- `subject_hazard_path_integrable_ae` gives an integrable path for almost every sample. Apply `cumulative_hazard_square` there and finish with `integral_congr_ae`. The mixed time integrand is integrable by `subject_prefix_mixed_hazard_integrable_prod`. -/ apply integral_congr_ae filter_upwards [subject_hazard_path_integrable_ae failureLaw censorLaw hazard hHazard H hMeasurable i u hQuadratic] with x hPath exact cumulative_hazard_square hazard H i u hu x hPath
    Causalean.Stat.RecurrentEvent.CountingProcess.subject_hazard_square_expectation · Causalean/Stat/RecurrentEvent/CountingProcess/SubjectIsometry.lean:165
  • subject_prefix_mixed_compensator_expectation theorem — Suppose subjects are drawn independently with failure times following a nonnegative time law and independent censor times whose law has the given censor hazard, and let the payoff process be left predictable and jointly measurable in time and sample. For a nonnegative horizon u and finite expected quadratic energy, the expected value, at subject i's observed censor event by u, of the accumulated hazard-weighted at-risk payoff up to the censor time times the payoff there equals the expected integral from 0 to u of the accumulated payoff times the payoff times the hazard times the subject's at-risk indicator.
    n :
    ℕ
    failureLaw censorLaw :
    hazard :
    ℝ → ℝ
    hFailure :
    hHazard :
    HasCensorHazard censorLaw hazard
    H :
    ℝ → Sample n → ℝ
    hPredictable :
    LeftPredictable H
    hMeasurable :
    Measurable (fun p : ℝ × Sample n => H p.1 p.2)
    i :
    Fin n
    u :
    ℝ
    hu :
    0 ≤ u
    hQuadratic :
    QuadraticEnergyFinite failureLaw censorLaw hazard H u
    (∫ x : Sample n, (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then (∫ t in Icc 0 (x i).2, H t x * hazard t * riskIndicator i t x ∂volume) * H (x i).2 x else 0) ∂sampleLaw n failureLaw censorLaw)
    = ∫ x : Sample n, (∫ s in Icc 0 u, (∫ t in Icc 0 s, H t x * hazard t * riskIndicator i t x ∂volume) * H s x * hazard s * riskIndicator i s x ∂volume) ∂sampleLaw n failureLaw censorLaw
    Proof (Lean source)
    theorem subject_prefix_mixed_compensator_expectation {n : ℕ} (failureLaw censorLaw : Measure ℝ) (hazard : ℝ → ℝ) (hFailure : NonnegativeTimeLaw failureLaw) (hHazard : HasCensorHazard censorLaw hazard) (H : ℝ → Sample n → ℝ) (hPredictable : LeftPredictable H) (hMeasurable : Measurable (fun p : ℝ × Sample n => H p.1 p.2)) (i : Fin n) (u : ℝ) (hu : 0 ≤ u) (hQuadratic : QuadraticEnergyFinite failureLaw censorLaw hazard H u) : (∫ x : Sample n, (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then (∫ t in Icc 0 (x i).2, H t x * hazard t * riskIndicator i t x ∂volume) * H (x i).2 x else 0) ∂sampleLaw n failureLaw censorLaw) = ∫ x : Sample n, (∫ s in Icc 0 u, (∫ t in Icc 0 s, H t x * hazard t * riskIndicator i t x ∂volume) * H s x * hazard s * riskIndicator i s x ∂volume) ∂sampleLaw n failureLaw censorLaw := by /- Apply `predictable_censor_compensator` to the prefix-product process. Predictability, joint measurability, and both integrability claims are already proved in `PredictablePrefix` and above in this file. -/ let P : ℝ → Sample n → ℝ := fun s x => (∫ t in Icc 0 s, H t x * hazard t * riskIndicator i t x ∂volume) * H s x have hPpred : LeftPredictable P := subject_prefix_mixed_predictable hazard H hPredictable i have hPmeas : Measurable (fun p : ℝ × Sample n => P p.1 p.2) := subject_prefix_mixed_jointMeasurable hazard hHazard.2.1 H hMeasurable i have hEvent := subject_prefix_mixed_event_integrable failureLaw censorLaw hazard hFailure hHazard H hPredictable hMeasurable i u hu hQuadratic exact predictable_censor_compensator failureLaw censorLaw hazard hFailure hHazard P hPpred hPmeas i u hEvent
    Causalean.Stat.RecurrentEvent.CountingProcess.subject_prefix_mixed_compensator_expectation · Causalean/Stat/RecurrentEvent/CountingProcess/SubjectIsometry.lean:196
  • subject_event_hazard_product_expectation theorem — Suppose subjects are drawn independently with failure times following a nonnegative time law and independent censor times whose law has the given censor hazard, and let the payoff process be left predictable and jointly measurable in time and sample. For a nonnegative horizon u and finite expected quadratic energy, the expected product of the payoff at subject i's observed censor event by u and the subject's full hazard-weighted at-risk payoff up to u equals the expected integral from 0 to u of the accumulated payoff times the payoff times the hazard times the at-risk indicator.
    n :
    ℕ
    failureLaw censorLaw :
    hazard :
    ℝ → ℝ
    hFailure :
    hHazard :
    HasCensorHazard censorLaw hazard
    H :
    ℝ → Sample n → ℝ
    hPredictable :
    LeftPredictable H
    hMeasurable :
    Measurable (fun p : ℝ × Sample n => H p.1 p.2)
    i :
    Fin n
    u :
    ℝ
    hu :
    0 ≤ u
    hQuadratic :
    QuadraticEnergyFinite failureLaw censorLaw hazard H u
    (∫ x : Sample n, (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) * (∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume) ∂sampleLaw n failureLaw censorLaw)
    = ∫ x : Sample n, (∫ s in Icc 0 u, (∫ t in Icc 0 s, H t x * hazard t * riskIndicator i t x ∂volume) * H s x * hazard s * riskIndicator i s x ∂volume) ∂sampleLaw n failureLaw censorLaw
    Proof (Lean source)
    theorem subject_event_hazard_product_expectation {n : ℕ} (failureLaw censorLaw : Measure ℝ) (hazard : ℝ → ℝ) (hFailure : NonnegativeTimeLaw failureLaw) (hHazard : HasCensorHazard censorLaw hazard) (H : ℝ → Sample n → ℝ) (hPredictable : LeftPredictable H) (hMeasurable : Measurable (fun p : ℝ × Sample n => H p.1 p.2)) (i : Fin n) (u : ℝ) (hu : 0 ≤ u) (hQuadratic : QuadraticEnergyFinite failureLaw censorLaw hazard H u) : (∫ x : Sample n, (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) * (∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume) ∂sampleLaw n failureLaw censorLaw) = ∫ x : Sample n, (∫ s in Icc 0 u, (∫ t in Icc 0 s, H t x * hazard t * riskIndicator i t x ∂volume) * H s x * hazard s * riskIndicator i s x ∂volume) ∂sampleLaw n failureLaw censorLaw := by /- On almost every sample path the censor time is nonnegative and the hazard payoff is integrable. On a censor event, the full compensator equals its value at the event by `subject_mixed_event_stops`; outside the event both products vanish. Then use `subject_prefix_mixed_compensator_expectation`. -/ haveI : IsProbabilityMeasure failureLaw := ⟨hFailure.1⟩ haveI : IsProbabilityMeasure censorLaw := ⟨hHazard.1.1⟩ haveI : IsProbabilityMeasure (failureLaw.prod censorLaw) := inferInstance have hCensor : ∀ᵐ c ∂censorLaw, 0 ≤ c := (mem_ae_iff_prob_eq_one measurableSet_Ici).2 hHazard.1.2 have hPair : ∀ᵐ z ∂failureLaw.prod censorLaw, 0 ≤ z.2 := by apply (Measure.ae_prod_iff_ae_ae (measurableSet_le measurable_const measurable_snd)).2 filter_upwards [] with a exact hCensor have hCensorSample : ∀ᵐ x ∂sampleLaw n failureLaw censorLaw, 0 ≤ (x i).2 := by unfold sampleLaw exact (Measure.tendsto_eval_ae_ae (μ := fun _ : Fin n => failureLaw.prod censorLaw) (i := i)) hPair calc _ = ∫ x : Sample n, (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then (∫ t in Icc 0 (x i).2, H t x * hazard t * riskIndicator i t x ∂volume) * H (x i).2 x else 0) ∂sampleLaw n failureLaw censorLaw := by apply integral_congr_ae filter_upwards [hCensorSample, subject_hazard_path_integrable_ae failureLaw censorLaw hazard hHazard H hMeasurable i u hQuadratic] with x hc0 hPath by_cases hEvent : (x i).2 ≤ u ∧ (x i).2 < (x i).1 · simp only [if_pos hEvent] rw [mul_comm (H (x i).2 x), subject_mixed_event_stops hazard H i x u hEvent.1] · simp [hEvent] _ = _ := subject_prefix_mixed_compensator_expectation failureLaw censorLaw hazard hFailure hHazard H hPredictable hMeasurable i u hu hQuadratic
    Causalean.Stat.RecurrentEvent.CountingProcess.subject_event_hazard_product_expectation · Causalean/Stat/RecurrentEvent/CountingProcess/SubjectIsometry.lean:239
  • subject_jump_compensator_cancellation theorem — Suppose subjects are drawn independently with failure times following a nonnegative time law and independent censor times whose law has the given censor hazard, and let the payoff process be left predictable and jointly measurable in time and sample. For a nonnegative horizon u and finite expected quadratic energy, the expectation of twice the censor-event payoff times the subject's compensator up to u, minus the square of that compensator, is zero.
    n :
    ℕ
    failureLaw censorLaw :
    hazard :
    ℝ → ℝ
    hFailure :
    hHazard :
    HasCensorHazard censorLaw hazard
    H :
    ℝ → Sample n → ℝ
    hPredictable :
    LeftPredictable H
    hMeasurable :
    Measurable (fun p : ℝ × Sample n => H p.1 p.2)
    i :
    Fin n
    u :
    ℝ
    hu :
    0 ≤ u
    hQuadratic :
    QuadraticEnergyFinite failureLaw censorLaw hazard H u
    (∫ x : Sample n, (2 * (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) * (∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume) - (∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume) ^ 2) ∂sampleLaw n failureLaw censorLaw)
    = 0
    Proof (Lean source)
    theorem subject_jump_compensator_cancellation {n : ℕ} (failureLaw censorLaw : Measure ℝ) (hazard : ℝ → ℝ) (hFailure : NonnegativeTimeLaw failureLaw) (hHazard : HasCensorHazard censorLaw hazard) (H : ℝ → Sample n → ℝ) (hPredictable : LeftPredictable H) (hMeasurable : Measurable (fun p : ℝ × Sample n => H p.1 p.2)) (i : Fin n) (u : ℝ) (hu : 0 ≤ u) (hQuadratic : QuadraticEnergyFinite failureLaw censorLaw hazard H u) : (∫ x : Sample n, (2 * (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) * (∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume) - (∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume) ^ 2) ∂sampleLaw n failureLaw censorLaw) = 0 := by /- First obtain integrability of B(u)² from `subject_hazard_square_integrable`. The mixed event term is integrable: `subject_prefix_mixed_event_integrable` supplies its stopped form, and `subject_mixed_event_stops` identifies it with H(C) * B(u) almost surely. `subject_hazard_square_expectation` expresses E[B(u)²] as twice the expected prefix-hazard product. The same product is E[H(C) * B(u)] by `subject_event_hazard_product_expectation`. Now split the integral of the difference with `integral_sub` and `integral_const_mul`, using the established integrability; finish by arithmetic. -/ have hSquare := subject_hazard_square_integrable failureLaw censorLaw hazard hFailure hHazard H hMeasurable i u hQuadratic haveI : IsProbabilityMeasure failureLaw := ⟨hFailure.1⟩ haveI : IsProbabilityMeasure censorLaw := ⟨hHazard.1.1⟩ haveI : IsProbabilityMeasure (failureLaw.prod censorLaw) := inferInstance have hCensor : ∀ᵐ c ∂censorLaw, 0 ≤ c := (mem_ae_iff_prob_eq_one measurableSet_Ici).2 hHazard.1.2 have hPair : ∀ᵐ z ∂failureLaw.prod censorLaw, 0 ≤ z.2 := by apply (Measure.ae_prod_iff_ae_ae (measurableSet_le measurable_const measurable_snd)).2 filter_upwards [] with a exact hCensor have hCensorSample : ∀ᵐ x ∂sampleLaw n failureLaw censorLaw, 0 ≤ (x i).2 := by unfold sampleLaw exact (Measure.tendsto_eval_ae_ae (μ := fun _ : Fin n => failureLaw.prod censorLaw) (i := i)) hPair have hStopped := subject_prefix_mixed_event_integrable failureLaw censorLaw hazard hFailure hHazard H hPredictable hMeasurable i u hu hQuadratic have hMixedAE : (fun x : Sample n => if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then (∫ t in Icc 0 (x i).2, H t x * hazard t * riskIndicator i t x ∂volume) * H (x i).2 x else 0) =ᵐ[sampleLaw n failureLaw censorLaw] (fun x : Sample n => (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) * (∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume)) := by filter_upwards [hCensorSample, subject_hazard_path_integrable_ae failureLaw censorLaw hazard hHazard H hMeasurable i u hQuadratic] with x hc0 hPath by_cases hEvent : (x i).2 ≤ u ∧ (x i).2 < (x i).1 · simp only [if_pos hEvent] rw [mul_comm (H (x i).2 x), subject_mixed_event_stops hazard H i x u hEvent.1] · simp [hEvent] have hMixed := hStopped.congr hMixedAE have hSquareExpectation : (∫ x : Sample n, (∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume) ^ 2 ∂sampleLaw n failureLaw censorLaw) = 2 * (∫ x : Sample n, (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) * (∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume) ∂sampleLaw n failureLaw censorLaw) := by calc _ = ∫ x : Sample n, (∫ s in Icc 0 u, 2 * (∫ t in Icc 0 s, H t x * hazard t * riskIndicator i t x ∂volume) * (H s x * hazard s * riskIndicator i s x) ∂volume) ∂sampleLaw n failureLaw censorLaw := subject_hazard_square_expectation failureLaw censorLaw hazard hHazard H hMeasurable i u hu hQuadratic _ = ∫ x : Sample n, 2 * (∫ s in Icc 0 u, (∫ t in Icc 0 s, H t x * hazard t * riskIndicator i t x ∂volume) * H s x * hazard s * riskIndicator i s x ∂volume) ∂sampleLaw n failureLaw censorLaw := by apply integral_congr_ae filter_upwards [] with x calc _ = ∫ s in Icc 0 u, 2 * ((∫ t in Icc 0 s, H t x * hazard t * riskIndicator i t x ∂volume) * H s x * hazard s * riskIndicator i s x) ∂volume := by congr 1 funext s ring _ = _ := integral_const_mul 2 _ _ = 2 * (∫ x : Sample n, (∫ s in Icc 0 u, (∫ t in Icc 0 s, H t x * hazard t * riskIndicator i t x ∂volume) * H s x * hazard s * riskIndicator i s x ∂volume) ∂sampleLaw n failureLaw censorLaw) := integral_const_mul 2 _ _ = _ := congrArg (fun z : ℝ => 2 * z) (subject_event_hazard_product_expectation failureLaw censorLaw hazard hFailure hHazard H hPredictable hMeasurable i u hu hQuadratic).symm have hFirst : Integrable (fun x : Sample n => (2 * (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0)) * (∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume)) (sampleLaw n failureLaw censorLaw) := by apply (hMixed.const_mul 2).congr filter_upwards [] with x ring have hFirstIntegral : (∫ x : Sample n, (2 * (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0)) * (∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume) ∂sampleLaw n failureLaw censorLaw) = 2 * (∫ x : Sample n, (if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) * (∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume) ∂sampleLaw n failureLaw censorLaw) := by calc _ = ∫ x : Sample n, 2 * ((if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then H (x i).2 x else 0) * (∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume)) ∂sampleLaw n failureLaw censorLaw := by apply integral_congr_ae filter_upwards [] with x ring _ = _ := integral_const_mul 2 _ rw [integral_sub hFirst hSquare, hFirstIntegral, ← hSquareExpectation, sub_self]
    Causalean.Stat.RecurrentEvent.CountingProcess.subject_jump_compensator_cancellation · Causalean/Stat/RecurrentEvent/CountingProcess/SubjectIsometry.lean:305
Subject­Moments 1 core · 2 supporting This module derives the mixed event and compensator integrability estimates needed to turn finite predictable quadratic energy into compensated-count second-moment identities. ★ subject_mixed_event_stops

Mixed predictable-moment bounds

This module derives the mixed event and compensator integrability estimates needed to turn finite predictable quadratic energy into compensated-count second-moment identities.

theorem subject_mixed_event_stops reviewed
Causalean.Stat.RecurrentEvent.CountingProcess

If a subject's censor time occurs by the horizon u, then for a censor hazard the accumulated payoff up to u times the payoff at the censor time equals the accumulated payoff up to the censor time times the same payoff.

Formal statement
n :
ℕ
hazard :
ℝ → ℝ
H :
ℝ → Sample n → ℝ
i :
Fin n
x :
u :
ℝ
hcu :
(x i).2 ≤ u
(∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume) * H (x i).2 x
= (∫ s in Icc 0 (x i).2, H s x * hazard s * riskIndicator i s x ∂volume) * H (x i).2 x
Proof (Lean source)
theorem subject_mixed_event_stops {n : ℕ} (hazard : ℝ → ℝ) (H : ℝ → Sample n → ℝ) (i : Fin n) (x : Sample n) (u : ℝ) (hcu : (x i).2 ≤ u) : (∫ s in Icc 0 u, H s x * hazard s * riskIndicator i s x ∂volume) * H (x i).2 x = (∫ s in Icc 0 (x i).2, H s x * hazard s * riskIndicator i s x ∂volume) * H (x i).2 x := by exact congrArg (fun z : ℝ => z * H (x i).2 x) (subject_hazard_stops_at_censor hazard H i x u hcu)
Causalean.Stat.RecurrentEvent.CountingProcess.subject_mixed_event_stops · Causalean/Stat/RecurrentEvent/CountingProcess/SubjectMoments.lean:308 · uses Sample , riskIndicator
2 supporting declarations (lemmas, instances)
  • subject_prefix_mixed_hazard_integrable_prod theorem — Suppose subjects are drawn independently with failure times following a nonnegative time law and independent censor times whose law has the given censor hazard, and let the payoff process be jointly measurable in time and sample. For a nonnegative horizon u and finite expected quadratic energy, subject i's accumulated hazard-weighted at-risk payoff up to time s times its current hazard-weighted at-risk payoff at s is integrable jointly over samples and times s from 0 to u.
    n :
    ℕ
    failureLaw censorLaw :
    hazard :
    ℝ → ℝ
    hFailure :
    hHazard :
    HasCensorHazard censorLaw hazard
    H :
    ℝ → Sample n → ℝ
    hMeasurable :
    Measurable (fun p : ℝ × Sample n => H p.1 p.2)
    i :
    Fin n
    u :
    ℝ
    hu :
    0 ≤ u
    hQuadratic :
    QuadraticEnergyFinite failureLaw censorLaw hazard H u
    Integrable (fun p : Sample n × ℝ => (∫ t in Icc 0 p.2, H t p.1 * hazard t * riskIndicator i t p.1 ∂volume) * H p.2 p.1 * hazard p.2 * riskIndicator i p.2 p.1) ((sampleLaw n failureLaw censorLaw).prod (volume.restrict (Icc 0 u)))
    Proof (Lean source)
    theorem subject_prefix_mixed_hazard_integrable_prod {n : ℕ} (failureLaw censorLaw : Measure ℝ) (hazard : ℝ → ℝ) (hFailure : NonnegativeTimeLaw failureLaw) (hHazard : HasCensorHazard censorLaw hazard) (H : ℝ → Sample n → ℝ) (hMeasurable : Measurable (fun p : ℝ × Sample n => H p.1 p.2)) (i : Fin n) (u : ℝ) (hu : 0 ≤ u) (hQuadratic : QuadraticEnergyFinite failureLaw censorLaw hazard H u) : Integrable (fun p : Sample n × ℝ => (∫ t in Icc 0 p.2, H t p.1 * hazard t * riskIndicator i t p.1 ∂volume) * H p.2 p.1 * hazard p.2 * riskIndicator i p.2 p.1) ((sampleLaw n failureLaw censorLaw).prod (volume.restrict (Icc 0 u))) := by /- Apply `integrable_prod_iff` to the jointly measurable mixed payoff. Almost-everywhere section integrability follows from hazard-path integrability and continuity of its indefinite integral. The previous pathwise bound controls the integral of the absolute section by total hazard mass times subject energy; Tonelli and finite expected quadratic energy make that bound integrable over the sample law. -/ classical haveI : IsProbabilityMeasure failureLaw := ⟨hFailure.1⟩ haveI : IsProbabilityMeasure censorLaw := ⟨hHazard.1.1⟩ let μ := sampleLaw n failureLaw censorLaw let ν := (volume : Measure ℝ).restrict (Icc 0 u) haveI : IsProbabilityMeasure μ := by dsimp [μ, sampleLaw] infer_instance let e : Sample n → ℝ → ℝ := fun x s => (H s x) ^ 2 * hazard s * (∑ j : Fin n, riskIndicator j s x) let f : Sample n × ℝ → ℝ := fun p => (∫ t in Icc 0 p.2, H t p.1 * hazard t * riskIndicator i t p.1 ∂volume) * H p.2 p.1 * hazard p.2 * riskIndicator i p.2 p.1 have he_meas : Measurable (fun p : Sample n × ℝ => e p.1 p.2) := by have hrisk (j : Fin n) : Measurable (fun p : Sample n × ℝ => riskIndicator j p.2 p.1) := by unfold riskIndicator have hf : Measurable (fun p : Sample n × ℝ => (p.1 j).1) := by fun_prop have hc : Measurable (fun p : Sample n × ℝ => (p.1 j).2) := by fun_prop have hs : MeasurableSet {p : Sample n × ℝ | 0 ≤ p.2 ∧ p.2 ≤ (p.1 j).1 ∧ p.2 ≤ (p.1 j).2} := by simpa only [Set.ofPred_and, Set.inter_assoc, id_eq] using (((show MeasurableSet {p : Sample n × ℝ | (0 : ℝ) ≤ p.2} from measurableSet_le measurable_const measurable_snd).inter (measurableSet_le measurable_snd hf)).inter (measurableSet_le measurable_snd hc)) exact measurable_const.ite hs measurable_const exact (((hMeasurable.comp (measurable_snd.prodMk measurable_fst)).pow_const 2).mul (hHazard.2.1.comp measurable_snd)).mul (Finset.measurable_fun_sum _ (fun j _ => hrisk j)) have he_nonneg (x : Sample n) (s : ℝ) : 0 ≤ e x s := by dsimp [e] apply mul_nonneg (mul_nonneg (sq_nonneg _) (hHazard.2.2.1 s)) exact Finset.sum_nonneg (fun j _ => by unfold riskIndicator; split_ifs <;> norm_num) have he_joint : Integrable (fun p : Sample n × ℝ => e p.1 p.2) (μ.prod ν) := by apply (lintegral_ofReal_ne_top_iff_integrable he_meas.aestronglyMeasurable (Filter.Eventually.of_forall (fun p => he_nonneg p.1 p.2))).1 rw [lintegral_prod _ he_meas.ennreal_ofReal.aemeasurable] exact hQuadratic have he_outer : Integrable (fun x => ∫ s, e x s ∂ν) μ := he_joint.integral_prod_left have he_path : ∀ᵐ x ∂μ, Integrable (e x) ν := he_joint.prod_right_ae have hf_meas : Measurable f := by dsimp [f] have hm := subject_prefix_mixed_jointMeasurable hazard hHazard.2.1 H hMeasurable i have hm' : Measurable (fun p : Sample n × ℝ => (∫ t in Icc 0 p.2, H t p.1 * hazard t * riskIndicator i t p.1 ∂volume) * H p.2 p.1) := hm.comp (measurable_snd.prodMk measurable_fst) exact (hm'.mul (hHazard.2.1.comp measurable_snd)).mul (by unfold riskIndicator have hf : Measurable (fun p : Sample n × ℝ => (p.1 i).1) := by fun_prop have hc : Measurable (fun p : Sample n × ℝ => (p.1 i).2) := by fun_prop have hs : MeasurableSet {p : Sample n × ℝ | 0 ≤ p.2 ∧ p.2 ≤ (p.1 i).1 ∧ p.2 ≤ (p.1 i).2} := by simpa only [Set.ofPred_and, Set.inter_assoc, id_eq] using (((show MeasurableSet {p : Sample n × ℝ | (0 : ℝ) ≤ p.2} from measurableSet_le measurable_const measurable_snd).inter (measurableSet_le measurable_snd hf)).inter (measurableSet_le measurable_snd hc)) exact measurable_const.ite hs measurable_const) have hsection : ∀ᵐ x ∂μ, Integrable (fun s => f (x, s)) ν := by filter_upwards [subject_hazard_path_integrable_ae failureLaw censorLaw hazard hHazard H hMeasurable i u hQuadratic] with x hx have hinterval : IntervalIntegrable (fun s => H s x * hazard s * riskIndicator i s x) volume 0 u := (intervalIntegrable_iff_integrableOn_Icc_of_le hu).2 hx let F : ℝ → ℝ := fun s => ∫ t in (0 : ℝ)..s, H t x * hazard t * riskIndicator i t x have hF : ContinuousOn F (Icc 0 u) := by simpa [F, Set.uIcc_of_le hu] using (hinterval.absolutelyContinuousOnInterval_intervalIntegral (by simp)).continuousOn have hprod : Integrable (fun s => F s * (H s x * hazard s * riskIndicator i s x)) ν := (intervalIntegrable_iff_integrableOn_Icc_of_le hu).1 (hinterval.continuousOn_mul (by simpa [Set.uIcc_of_le hu] using hF)) apply hprod.congr filter_upwards [ae_restrict_mem measurableSet_Icc] with s hs dsimp [f, F] rw [intervalIntegral.integral_of_le hs.1, ← integral_Icc_eq_integral_Ioc] ring have henergy_subject : ∀ᵐ x ∂μ, Integrable (fun s => (H s x) ^ 2 * hazard s * riskIndicator i s x) ν := by filter_upwards [he_path] with x hx have hm : Measurable (fun s => (H s x) ^ 2 * hazard s * riskIndicator i s x) := by have hrisk : Measurable (fun s : ℝ => riskIndicator i s x) := by unfold riskIndicator have hs : MeasurableSet {s : ℝ | 0 ≤ s ∧ s ≤ (x i).1 ∧ s ≤ (x i).2} := by simpa only [Set.ofPred_and, Set.inter_assoc, id_eq] using (((show MeasurableSet {s : ℝ | (0 : ℝ) ≤ s} from measurableSet_le measurable_const measurable_id).inter (measurableSet_le measurable_id measurable_const)).inter (measurableSet_le measurable_id measurable_const)) exact measurable_const.ite hs measurable_const exact (((hMeasurable.comp (measurable_id.prodMk measurable_const)).pow_const 2).mul hHazard.2.1).mul hrisk apply hx.mono' hm.aestronglyMeasurable filter_upwards [] with s rw [Real.norm_eq_abs, abs_of_nonneg (mul_nonneg (mul_nonneg (sq_nonneg _) (hHazard.2.2.1 s)) (by unfold riskIndicator split_ifs <;> norm_num))] exact mul_le_mul_of_nonneg_left (Finset.single_le_sum (f := fun j : Fin n => riskIndicator j s x) (fun j hj => by unfold riskIndicator; split_ifs <;> norm_num) (Finset.mem_univ i)) (mul_nonneg (sq_nonneg _) (hHazard.2.2.1 s)) have houter : Integrable (fun x => ∫ s, ‖f (x, s)‖ ∂ν) μ := by have hm : AEStronglyMeasurable (fun x => ∫ s, ‖f (x, s)‖ ∂ν) μ := hf_meas.norm.stronglyMeasurable.integral_prod_right'.aestronglyMeasurable apply integrable_of_le_of_le hm (Filter.Eventually.of_forall (fun x => integral_nonneg (fun s => norm_nonneg _))) ?_ (integrable_const 0) (he_outer.const_mul (∫ s in Icc 0 u, hazard s ∂volume)) filter_upwards [subject_hazard_path_integrable_ae failureLaw censorLaw hazard hHazard H hMeasurable i u hQuadratic, henergy_subject, he_path] with x hx hxe hxt have hbound := subject_prefix_mixed_abs_integral_le_energy hazard hHazard.2.2.1 H i u hu x (hHazard.2.2.2.1 u) hx hxe have henergy_le : (∫ s in Icc 0 u, (H s x) ^ 2 * hazard s * riskIndicator i s x ∂volume) ≤ ∫ s, e x s ∂ν := by apply integral_mono hxe hxt intro s exact mul_le_mul_of_nonneg_left (Finset.single_le_sum (f := fun j : Fin n => riskIndicator j s x) (fun j hj => by unfold riskIndicator; split_ifs <;> norm_num) (Finset.mem_univ i)) (mul_nonneg (sq_nonneg _) (hHazard.2.2.1 s)) have hmass : 0 ≤ ∫ s in Icc 0 u, hazard s ∂volume := integral_nonneg hHazard.2.2.1 calc (∫ s, ‖f (x, s)‖ ∂ν) = ∫ s in Icc 0 u, |(∫ t in Icc 0 s, H t x * hazard t * riskIndicator i t x ∂volume) * (H s x * hazard s * riskIndicator i s x)| ∂volume := by congr 1 funext s simp only [f, Real.norm_eq_abs] congr 1 ring _ ≤ _ := hbound.trans (mul_le_mul_of_nonneg_left henergy_le hmass) exact (integrable_prod_iff hf_meas.aestronglyMeasurable).2 ⟨hsection, houter⟩
    Causalean.Stat.RecurrentEvent.CountingProcess.subject_prefix_mixed_hazard_integrable_prod · Causalean/Stat/RecurrentEvent/CountingProcess/SubjectMoments.lean:18
  • subject_prefix_mixed_event_integrable theorem — Suppose subjects are drawn independently with failure times following a nonnegative time law and independent censor times whose law has the given censor hazard, and let the payoff process be left predictable and jointly measurable in time and sample. For a nonnegative horizon u and finite expected quadratic energy, the product, at subject i's observed censor event by u, of the accumulated hazard-weighted at-risk payoff up to the censor time and the payoff there, taken as zero when no such event occurs, is integrable over samples.
    n :
    ℕ
    failureLaw censorLaw :
    hazard :
    ℝ → ℝ
    hFailure :
    hHazard :
    HasCensorHazard censorLaw hazard
    H :
    ℝ → Sample n → ℝ
    hPredictable :
    LeftPredictable H
    hMeasurable :
    Measurable (fun p : ℝ × Sample n => H p.1 p.2)
    i :
    Fin n
    u :
    ℝ
    hu :
    0 ≤ u
    hQuadratic :
    QuadraticEnergyFinite failureLaw censorLaw hazard H u
    Integrable (fun x : Sample n => if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then (∫ t in Icc 0 (x i).2, H t x * hazard t * riskIndicator i t x ∂volume) * H (x i).2 x else 0) (sampleLaw n failureLaw censorLaw)
    Proof (Lean source)
    theorem subject_prefix_mixed_event_integrable {n : ℕ} (failureLaw censorLaw : Measure ℝ) (hazard : ℝ → ℝ) (hFailure : NonnegativeTimeLaw failureLaw) (hHazard : HasCensorHazard censorLaw hazard) (H : ℝ → Sample n → ℝ) (hPredictable : LeftPredictable H) (hMeasurable : Measurable (fun p : ℝ × Sample n => H p.1 p.2)) (i : Fin n) (u : ℝ) (hu : 0 ≤ u) (hQuadratic : QuadraticEnergyFinite failureLaw censorLaw hazard H u) : Integrable (fun x : Sample n => if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then (∫ t in Icc 0 (x i).2, H t x * hazard t * riskIndicator i t x ∂volume) * H (x i).2 x else 0) (sampleLaw n failureLaw censorLaw) := by /- Set Q(s,x) = |B_i(s,x) * H(s,x)|, where B_i is the prefix hazard integral. `subject_prefix_mixed_predictable` and `subject_prefix_mixed_jointMeasurable` give the hypotheses for `predictable_censor_compensator_lintegral`. The compensator's nonnegative joint lintegral is finite because `subject_prefix_mixed_hazard_integrable_prod` gives L¹ integrability of the signed product and the risk indicator is nonnegative. Convert the finite event lintegral to `Integrable` using `lintegral_ofReal_ne_top_iff_integrable`. Event measurability follows by composing the joint-measurability result with x ↦ (censorTime_i x,x), then restricting to the measurable event predicate. -/ classical let μ := sampleLaw n failureLaw censorLaw let ν := (volume : Measure ℝ).restrict (Icc 0 u) let P : ℝ → Sample n → ℝ := fun s x => (∫ t in Icc 0 s, H t x * hazard t * riskIndicator i t x ∂volume) * H s x let Q : ℝ → Sample n → ℝ := fun s x => |P s x| have hPpred : LeftPredictable P := subject_prefix_mixed_predictable hazard H hPredictable i have hPmeas : Measurable (fun p : ℝ × Sample n => P p.1 p.2) := subject_prefix_mixed_jointMeasurable hazard hHazard.2.1 H hMeasurable i have hQpred : LeftPredictable Q := by intro s x y hxy exact congrArg abs (hPpred s x y hxy) have hQmeas : Measurable (fun p : ℝ × Sample n => Q p.1 p.2) := by simpa only [Real.norm_eq_abs] using hPmeas.norm have hQnonneg : ∀ s x, 0 ≤ Q s x := fun s x => abs_nonneg _ have hlin := predictable_censor_compensator_lintegral failureLaw censorLaw hazard hFailure hHazard Q hQpred hQmeas hQnonneg i u have hJoint := subject_prefix_mixed_hazard_integrable_prod failureLaw censorLaw hazard hFailure hHazard H hMeasurable i u hu hQuadratic have hfinite : (∫⁻ x : Sample n, ∫⁻ s in Icc 0 u, ofReal (Q s x * hazard s * riskIndicator i s x) ∂volume ∂μ) ≠ ⊤ := by have hmeas : Measurable (fun p : Sample n × ℝ => Q p.2 p.1 * hazard p.2 * riskIndicator i p.2 p.1) := by have hrisk : Measurable (fun p : Sample n × ℝ => riskIndicator i p.2 p.1) := by unfold riskIndicator have hf : Measurable (fun p : Sample n × ℝ => (p.1 i).1) := by fun_prop have hc : Measurable (fun p : Sample n × ℝ => (p.1 i).2) := by fun_prop have hs : MeasurableSet {p : Sample n × ℝ | 0 ≤ p.2 ∧ p.2 ≤ (p.1 i).1 ∧ p.2 ≤ (p.1 i).2} := by simpa only [Set.ofPred_and, Set.inter_assoc, id_eq] using (((show MeasurableSet {p : Sample n × ℝ | (0 : ℝ) ≤ p.2} from measurableSet_le measurable_const measurable_snd).inter (measurableSet_le measurable_snd hf)).inter (measurableSet_le measurable_snd hc)) exact measurable_const.ite hs measurable_const exact ((hQmeas.comp (measurable_snd.prodMk measurable_fst)).mul (hHazard.2.1.comp measurable_snd)).mul hrisk rw [← lintegral_prod _ hmeas.ennreal_ofReal.aemeasurable] have hnorm : Integrable (fun p : Sample n × ℝ => ‖(∫ t in Icc 0 p.2, H t p.1 * hazard t * riskIndicator i t p.1 ∂volume) * H p.2 p.1 * hazard p.2 * riskIndicator i p.2 p.1‖) (μ.prod ν) := hJoint.norm have heq : (fun p : Sample n × ℝ => Q p.2 p.1 * hazard p.2 * riskIndicator i p.2 p.1) = (fun p : Sample n × ℝ => ‖(∫ t in Icc 0 p.2, H t p.1 * hazard t * riskIndicator i t p.1 ∂volume) * H p.2 p.1 * hazard p.2 * riskIndicator i p.2 p.1‖) := by funext p have hh : 0 ≤ hazard p.2 := hHazard.2.2.1 p.2 have hr : 0 ≤ riskIndicator i p.2 p.1 := by unfold riskIndicator split_ifs <;> norm_num simp only [Q, P, Real.norm_eq_abs, abs_mul, abs_of_nonneg hh, abs_of_nonneg hr] simp_rw [congrFun heq] exact (lintegral_ofReal_ne_top_iff_integrable hnorm.1 (Filter.Eventually.of_forall (fun p => norm_nonneg _))).2 hnorm have hm : Measurable (fun x : Sample n => if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then P (x i).2 x else 0) := by have hc : Measurable (fun x : Sample n => (x i).2) := by fun_prop have hf : Measurable (fun x : Sample n => (x i).1) := by fun_prop exact (hPmeas.comp (hc.prodMk measurable_id)).ite ((measurableSet_le hc measurable_const).inter (measurableSet_lt hc hf)) measurable_const have hnorm : Integrable (fun x : Sample n => |if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then P (x i).2 x else 0|) μ := by apply (lintegral_ofReal_ne_top_iff_integrable (show Measurable (fun x : Sample n => |if (x i).2 ≤ u ∧ (x i).2 < (x i).1 then P (x i).2 x else 0|) by simpa only [Real.norm_eq_abs] using hm.norm).aestronglyMeasurable (Filter.Eventually.of_forall (fun x => abs_nonneg _))).1 simp only [abs_ite, abs_zero] rw [hlin] exact hfinite exact (integrable_norm_iff hm.aestronglyMeasurable).1 (by simpa only [Real.norm_eq_abs] using hnorm)
    Causalean.Stat.RecurrentEvent.CountingProcess.subject_prefix_mixed_event_integrable · Causalean/Stat/RecurrentEvent/CountingProcess/SubjectMoments.lean:195