Skip to contents

Native R implementation of the multiphase parametric hazard model of Blackstone, Naftel, and Turner (1986), with a focus on behavioral parity, transparent numerics, and reproducible validation against the original ‘C’/‘SAS’ HAZARD program. The package fits time-varying hazards as an additive sum of parametric phases (early, constant, and late risk streams), each carrying its own covariate effects.

The multiphase model

The total cumulative hazard decomposes additively across \(J\) phases:

$$H(t \mid \mathbf{x}) = \sum_{j=1}^{J} \mu_j(\mathbf{x}) \, \Phi_j(t)$$

where \(\mu_j(\mathbf{x}) = \exp(\alpha_j + \mathbf{x}_j^\top \beta_j)\) is the phase-specific log-linear scale (intercept plus covariate effects) and \(\Phi_j(t)\) is the temporal shape contributed by phase \(j\), with its own parameters depending on the phase type (see the phase vocabulary below). The instantaneous hazard and survival follow directly:

$$h(t \mid \mathbf{x}) = \sum_{j=1}^{J} \mu_j(\mathbf{x}) \, \varphi_j(t), \qquad S(t \mid \mathbf{x}) = \exp\!\bigl(-H(t \mid \mathbf{x})\bigr)$$

with \(\varphi_j = d\Phi_j/dt\). Each phase is specified with hzr_phase() and the model is fit by maximum likelihood with hazard().

Phase vocabulary

Phase type\(\Phi_j(t)\)DomainUse
"cdf"\(G(t)\)\([0, 1]\)Early risk that resolves over time
"hazard"\(-\log(1 - G(t))\)\([0, \infty)\)Late or aging risk that accumulates
"g3"\(G_3(t)\)\([0, \infty)\)Unbounded late risk (original C/SAS late phase)
"constant"\(t\)\([0, \infty)\)Flat background rate (no shape parameters)

Here \(G(t)\) is the generalized temporal decomposition CDF computed by hzr_decompos(), and \(G_3(t)\) is the unbounded late-phase intensity from hzr_decompos_g3(). See vignette("mf-mathematical-foundations") for the full derivation.

SAS/C HAZARD bridge

The classic three-phase HAZARD model maps directly onto hzr_phase() calls:

HAZARD phaseRoleR equivalent
G1 (early)Early resolving riskhzr_phase("cdf", ...)
G2 (constant)Flat background ratehzr_phase("constant")
G3 (late)Rising late riskhzr_phase("g3", ...)

TemporalHazard generalizes the fixed three-phase structure to \(N\) phases of any type. hzr_argument_mapping() gives the full parameter translation table between the SAS/C parameterization and the R arguments.

Main entry points

Model fitting

hazard() for building and fitting single- or multiphase models; hzr_phase() for specifying one phase; hzr_stepwise() for forward, backward, or bidirectional covariate selection.

Prediction

predict() on a fitted hazard object for survival, cumulative hazard, and per-phase decomposed hazard; summary() for coefficient tables with Wald inference.

Parametric family

hzr_decompos() for the early-phase (G1) decomposition \(G(t)\), \(g(t)\), \(h(t)\); hzr_decompos_g3() for the late-phase (G3) intensity; hzr_phase_cumhaz() and hzr_phase_hazard() for per-phase \(\Phi(t)\) and \(\varphi(t)\).

Diagnostics

hzr_kaplan(), hzr_nelson() for nonparametric references; hzr_gof() for goodness of fit; hzr_calibrate(), hzr_deciles() for calibration; hzr_bootstrap() for resampling CIs; hzr_competing_risks() for cumulative incidence.

Vignettes

vignette("getting-started")

First fit, end to end.

vignette("mf-mathematical-foundations")

The decomposition family and multiphase model, with derivations.

vignette("fitting-hazard-models")

Single-phase through multiphase fitting.

vignette("prediction-visualization")

Prediction types and decomposed-hazard plots.

vignette("inference-diagnostics")

Bootstrap CIs and diagnostics.

vignette("sas-to-r-migration")

Translating SAS/C HAZARD code.

References

Blackstone EH, Naftel DC, Turner ME Jr. The decomposition of time-varying hazard into phases, each incorporating a separate stream of concomitant information. J Am Stat Assoc. 1986;81(395):615–624. doi:10.1080/01621459.1986.10478314

Rajeswaran J, Blackstone EH, Ehrlinger J, Li L, Ishwaran H, Parides MK. Probability of atrial fibrillation after ablation: Using a parametric nonlinear temporal decomposition mixed effects model. Stat Methods Med Res. 2018;27(1):126–141. doi:10.1177/0962280215623583

Author

Maintainer: John Ehrlinger john.ehrlinger@gmail.com [copyright holder]

Authors: