Absolute risk (Euler approximation) for a cause under piecewise-constant hazards
Source:R/pch_absolute_risk.R
pch_absolute_risk_euler.RdComputes the cumulative incidence function using the first-order Euler
(discrete) approximation:
$$F_j(t) \approx \sum S(t_{k-1}) \lambda_{j,k} \Delta t_k$$
Grouped by id, this returns the cumulative incidence at the end of each interval.
Arguments
- id
Integer vector. Sorted by
idthen time.- dt
Numeric vector of interval lengths.
- haz
Numeric matrix (n x C) of cause-specific hazards per interval.
- cause_idx
Integer. Index of the cause of interest (1-based by default).
- one_based
Logical. If
TRUE,cause_idxis 1-based. IfFALSE, 0-based.- na_is_zero
Logical. If
TRUE, treat NA/Inf hazards as zero.