Supplementary analysis code

Purpose
This archive contains the R code used for the revised 24-hour landmark
analysis, ordinary bootstrap internal validation with multiple imputation
nested within resampling, sensitivity analyses, exploratory
score analysis, selection-adjusted parametric bootstrap, and reproducible
generation of Figure 2 and Supplementary Figure S3.

Patient-level data
No patient-level observations or identifiers are included. The underlying
retrospective dataset is restricted because of participant privacy and
institutional data-governance requirements. De-identified data may be
requested from the corresponding authors, subject to institutional approval.
Empty standardized input templates and a variable dictionary are supplied.

Required input files
1. analysis_data.csv
2. timing_audit.csv

Place both authorized, de-identified CSV files beside the R scripts. Their
headers must match analysis_data_template.csv and timing_audit_template.csv.

Software used by the authors
- R 4.6.0
- mice 3.19.0
- pROC 1.19.0.1
- survival 3.8-6
- splines and grid from R

Internal-validation ordering
The publication performance estimates are generated by script 03 using
ordinary bootstrap optimism correction with multiple imputation nested within
resampling. In each of 1,000 patient-level bootstrap iterations, one incomplete
bootstrap sample is drawn for model fitting, while the original incomplete
cohort is retained for evaluation. Separate MICE runs complete the bootstrap
sample and the original cohort, with five imputations and 20 iterations in each
run. No fitted imputation model, parameter estimate, donor selection, completed
value, or other output from the original-cohort MICE run is passed to
bootstrap-sample imputation or model fitting. As required by ordinary optimism
correction, the bootstrap sample and original cohort overlap in source
individuals by design. For each model and performance metric, bootstrap-sample
performance is averaged across the five bootstrap imputation indices, and
original-cohort performance is averaged separately across the five
original-cohort imputation indices. Resample-specific optimism is then
calculated as the difference between these two averages. The same bootstrap
draw and separately averaged performance estimates are used for all nested
models. Script 03 derives and plots Supplementary Figure S3, including
its confidence bands, directly from the bootstrap output.

Here, "ordinary bootstrap optimism correction" denotes the estimator that
subtracts the mean difference between bootstrap-sample and original-cohort
performance from apparent original-cohort performance. It is not an out-of-bag,
.632, or .632+ estimator.

Figure generation
Script 03 writes Supplementary Figure S3 and its exact source coordinates.
Script 04 writes the updated Figure 2 and its panel-level source data. Both
scripts export PNG, TIFF, and PDF files. The optional MAKE_FIGURES mode in script 01 generates descriptive figures but
does not contain or generate any alternative Figure S3. The publication
calibration figure is generated exclusively by script 03.

Run order
Run all analyses with:
Rscript 00_run_all.R

Alternatively, run the component scripts in this order:
1. Rscript 01_primary_and_sensitivity_analysis.R
2. Rscript 02_score_selection_adjustment.R
3. Rscript 03_validation_before_imputation_internal_validation.R
4. Rscript 04_regenerate_updated_figure2.R

The first script creates a results folder and the multiple-imputation object
required by the second script. The second script runs 1,000 null parametric-
bootstrap attempts for the selection-adjusted score test (default random seed:
116). The third script performs the publication internal validation using 50
imputations for apparent performance and 1,000 ordinary patient-level
bootstrap iterations. Within each iteration, separate MICE runs complete the
incomplete bootstrap sample and original incomplete cohort. For each model and
performance metric, performance is averaged separately across the five
bootstrap imputations and across the five original-cohort imputations before
resample-specific optimism is calculated as the difference between those two
averages.
The fourth script regenerates Figure 2 from the corrected validation output.

Runtime
The complete default analysis may take approximately one hour or longer,
depending on hardware. Reduced settings may
be used only to test executability; they do not reproduce the publication
estimates. Optional environment variables are documented at the beginning of
the scripts.

Score analysis populations
The three Youden cut-offs are estimated in the 215-patient common
complete-case sample, in which the clinical comparator and all score
components are observed. Those fixed cut-offs are then applied descriptively
to the 238 landmark patients with complete PCT, NLR, and MLR values.

Output checking
expected_key_results.csv lists the principal aggregate values expected from
the authors' analysis. Very small last-decimal differences can occur across R
or package versions, especially for multiple-imputation and bootstrap results.
