library("survatr")
data(nhefs_surv)
nhefs_surv[, .N, by = "seqn"][, range(N)] # all 120 periods per id[1] 120 120
sum(nhefs_surv$event) # 318 deaths[1] 318
The NHEFS (National Health and Nutrition Examination Survey Epidemiologic Follow-up Study) cohort in rectangular monthly person-period format. Each of the 1629 participants contributes exactly 120 rows (one per calendar month from January 1983 to December 1992), forming the rectangular grid required by surv_fit(). The event indicator is 1 only in the month of death for the 318 participants who died before the end of follow-up; it is 0 elsewhere.
The primary use of this dataset is to reproduce the Hernán & Robins Chapter 17 causal survival analysis: the standardised 120-month survival under smoking cessation vs. no cessation, and the corresponding risk difference (≈ 0.2 pp, essentially null).
nhefs_surv
A data.table with 195 480 rows and 13 columns:
Assembled from causaldata::nhefs (Huntington-Klein 2021) by the data-raw/nhefs_surv.R script. The NHEFS data are publicly distributed by Hernán & Robins at https://www.hsph.harvard.edu/miguel-hernan/causal-inference-book/.
Hernán MA, Robins JM (2025). Causal Inference: What If. Chapman & Hall / CRC. Chapter 17: Causal survival analysis.
Huntington-Klein N et al. (2021). causaldata: Example Datasets for Causal Inference Textbooks. R package.
surv_fit(), contrast()