Package: TemporalHazard 1.2.0

TemporalHazard: Temporal Parametric Hazard Modeling

Provides native R implementations of the multiphase parametric hazard model of Blackstone, Naftel, and Turner (1986) <doi:10.1080/01621459.1986.10478314> with a focus on behavioral parity, transparent numerics, and reproducible validation against reference outputs from the original 'C'/'SAS' HAZARD program, originally developed at the University of Alabama at Birmingham (UAB). The 'SAS'/'C' code and this R package are currently developed and maintained at The Cleveland Clinic Foundation, and the R code was wholly developed at The Cleveland Clinic Foundation. The generalized temporal decomposition family extends to longitudinal mixed-effects settings (Rajeswaran et al. 2018 <doi:10.1177/0962280215623583>). The package is intentionally implemented in pure R first; performance-critical paths may later be accelerated with 'Rcpp' without changing the public interface.

Authors:John Ehrlinger [aut, cre, cph]

TemporalHazard_1.2.0.tar.gz
TemporalHazard_1.2.0.zip(r-4.7)TemporalHazard_1.2.0.zip(r-4.6)TemporalHazard_1.2.0.zip(r-4.5)
TemporalHazard_1.2.0.tgz(r-4.6-any)TemporalHazard_1.2.0.tgz(r-4.5-any)
TemporalHazard_1.2.0.tar.gz(r-4.7-any)TemporalHazard_1.2.0.tar.gz(r-4.6-any)
TemporalHazard_1.2.0.tgz(r-4.6-emscripten)
manual.pdf |manual.html
DESCRIPTION |NEWS
card.svg |card.png
TemporalHazard/json (API)

# Install 'TemporalHazard' in R:
install.packages('TemporalHazard', repos = c('https://ehrlinger.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/ehrlinger/temporal_hazard/issues

Pkgdown/docs site:https://ehrlinger.github.io

Datasets:
  • avc - AVC: Atrioventricular Canal Repair
  • cabgkul - CABGKUL: Primary Isolated Coronary Artery Bypass Grafting
  • omc - OMC: Open Mitral Commissurotomy
  • tga - TGA: Transposition of the Great Arteries
  • valves - Valves: Primary Heart Valve Replacement

On CRAN:

Conda:

quarto

5.64 score 1 stars 12 scripts 291 downloads 20 exports 3 dependencies

Last updated from:faa2447684. Checks:9 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-x86_64OK253
source / vignettesOK301
linux-release-x86_64OK165
macos-release-arm64OK416
macos-oldrel-arm64OK222
windows-develOK274
windows-releaseOK302
windows-oldrelOK284
wasm-releaseOK140

Exports:hazardhzr_argument_mappinghzr_bootstraphzr_calibratehzr_clamp_probhzr_competing_riskshzr_decileshzr_decomposhzr_decompos_g3hzr_gofhzr_kaplanhzr_log1mexphzr_log1pexphzr_nelsonhzr_phasehzr_phase_cumhazhzr_phase_hazardhzr_stepwiseis_hzr_phasestepwise_trace

Dependencies:latticeMatrixsurvival

Fitting Hazard Models
Intercept-only model: CABG survival (KU Leuven) | Multivariable model: AVC repair | Multiphase model: additive hazard decomposition | Multi-endpoint models: heart valve replacement | Interval and left censoring | Status codes | Mixed censoring example | Interval-censored vs naive right-censored | Convergence troubleshooting | Reading the KM cumulative hazard for starting values | When to fix shape parameters | Signs of overparameterization | Optimizer options | Phase types reference

Last update: 2026-06-10
Started: 2026-04-13

Inference & Diagnostics
Exploratory covariate screening | Quantile calibration with hzr_calibrate() | Nonparametric baselines | Bootstrap confidence intervals | Goodness-of-fit overlay | Decile-of-risk calibration | Sensitivity analysis | Analysis workflow summary

Last update: 2026-06-10
Started: 2026-04-13

Mathematical Foundations of TemporalHazard
Generalized Temporal Decomposition | The parametric family | SAS/C parameter bridge | The six valid cases | Derivation sketch | Additive Multiphase Hazard Model | Model specification | SAS/C bridge | Derived quantities | Constructing phases in R | Additive composition example | Maximum Likelihood Estimation | Log-likelihood under mixed censoring | Internal parameterization | Optimization strategy | Covariates and Phase-Specific Formulas | Global covariates | Phase-specific covariates | Time-varying coefficients | Multiphase vs. time-varying coefficients | Identifiability and Practical Considerations | Parameter identifiability | Numerical stability | Summary of Key Functions | References

Last update: 2026-06-10
Started: 2026-04-11

Complete Clinical Analysis Walkthrough
Data preparation | Step 1: Nonparametric baseline | Step 2: Shape fitting --- simple to complex | 2a. Single-phase Weibull | 2b. Two-phase model (early CDF + constant) | 2c. Decomposed hazard | Step 3: Variable screening | 3a. Univariable logistic screening | 3b. Functional form assessment | Step 4: Multivariable model | 4a. Manual specification | 4b. Automated stepwise selection | Step 5: Prediction | 5a. Baseline survival curve | 5b. Sensitivity analysis --- risk factor comparison | Step 6: Validation --- decile-of-risk calibration | Conservation of events check | Why not Cox regression? | Summary

Last update: 2026-05-27
Started: 2026-04-14

Getting Started with TemporalHazard
A first Weibull fit | Prediction workflow | Visualizing predicted survival | Multiphase models | Why multiple phases? | Decomposed hazard visualization | Multiphase survival with Kaplan-Meier overlay | Phase types | Numerical helpers

Last update: 2026-05-27
Started: 2026-04-06

Migrating from SAS HAZARD to TemporalHazard
Overview | Statement-by-statement mapping | PROC HAZARD DATA= | TIME | EVENT | PARMS | EARLY and CONSTANT covariate blocks | SELECTION | SAS macro equivalents | Full worked example: AVC death after repair | SAS (original) | R equivalent (current runnable translation pattern) | Data preparation differences | Output object | Prediction | Known limitations vs. SAS HAZARD | Stepwise variable selection (SELECTION statement) | Per-phase time-varying windows | Output datasets (OUTEST=, OUTVCOV=) | Density / quantile prediction types | Previously listed gaps that have since been closed | Rcpp acceleration note | References

Last update: 2026-05-27
Started: 2026-04-06

Prediction & Visualization
Kaplan-Meier baseline | Prediction types | Parametric survival with KM overlay | Confidence limits on predictions | Decomposed multiphase hazard | Multiphase survival with KM overlay | Patient-specific risk profiles | Multi-endpoint visualization: valves

Last update: 2026-05-27
Started: 2026-04-13

Package Architecture
Overview | Source file organization | Function call graph | Key internal functions | Theta vector layout | Phase specification | Decomposition engine | Multi-start optimization | Golden fixture system | Fixture format | Current fixtures | Regenerating fixtures | Testing strategy | Multiphase parity tests | Dataset catalog | Loading datasets | Dataset details | AVC (atrioventricular canal repair) | CABG/KUL (coronary artery bypass grafting) | OMC (open mitral commissurotomy) | TGA (transposition of great arteries) | Valves (primary valve replacement) | SAS/C parameter mapping | Early phase (G1) mapping | Late phase (G3) mapping | Version history | References

Last update: 2026-05-27
Started: 2026-04-11

Readme and manuals

Help Manual

Help pageTopics
AVC: Atrioventricular Canal Repairavc
CABGKUL: Primary Isolated Coronary Artery Bypass Grafting (KU Leuven)cabgkul
Extract coefficients from hazard modelcoef.hazard
Build and optionally fit a hazard modelhazard
Legacy HAZARD to TemporalHazard argument mappinghzr_argument_mapping
Bootstrap resampling for hazard model coefficientshzr_bootstrap print.hzr_bootstrap
Calibrate a continuous variable against an outcomehzr_calibrate
Clamp probabilities away from 0 and 1hzr_clamp_prob
Competing risks cumulative incidencehzr_competing_risks print.hzr_competing_risks
Decile-of-risk calibrationhzr_deciles
Generalized temporal decompositionhzr_decompos
Late-phase (G3) temporal decompositionhzr_decompos_g3
Goodness-of-fit: observed vs. predicted eventshzr_gof
Kaplan-Meier survival with exact logit confidence limitshzr_kaplan
Numerically stable log(1 - exp(-x)) for x > 0hzr_log1mexp
Numerically stable log(1 + exp(x))hzr_log1pexp
Wayne Nelson cumulative hazard estimator with lognormal confidence limitshzr_nelson print.hzr_nelson
Specify a single hazard phasehzr_phase print.hzr_phase
Cumulative hazard contribution from a single phasehzr_phase_cumhaz
Instantaneous hazard contribution from a single phasehzr_phase_hazard
Stepwise covariate selection for a parametric hazard modelas.data.frame.hzr_stepwise hzr_stepwise print.hzr_stepwise print.summary.hzr_stepwise summary.hzr_stepwise
Test if an object is an hzr_phaseis_hzr_phase
OMC: Open Mitral Commissurotomyomc
Predict from a hazard model objectpredict.hazard
Print method for hzr_calibrateprint.hzr_calibrate
Print method for hzr_decilesprint.hzr_deciles
Print method for hzr_gofprint.hzr_gof
Print method for hzr_kaplanprint.hzr_kaplan
Extract the captured console trace from an 'hzr_stepwise' fitstepwise_trace
Summarize a hazard modelsummary.hazard
TGA: Transposition of the Great Arteriestga
Valves: Primary Heart Valve Replacementvalves
Extract variance-covariance matrix from hazard modelvcov.hazard