Deep Learning Survival Analysis with Time-Varying Covariates: Extending PyCox to Assess COVID-19 Antiviral Treatments and Long-COVID Associations

Abstract Objective To extend the PyCox to accommodate time-varying covariates using counting process data, addressing immortal time bias in survival analysis. Materials and Methods We modified PyCox to support counting process data structures for time-varying covariates and applied it to 2,246,913 Medicare beneficiaries aged ≥65 with COVID-19 (January-September 2022; 2,785,807 longitudinal records). We compared traditional Cox regression, original PyCox, and modified PyCox in estimating associations between early antiviral treatment (nirmatrelvir or molnupiravir) and long-COVID. Performance metrics included concordance index (C-index), integrated Brier score (IBS), and integrated negative binomial log-likelihood (IBLL) and time-dependent Area Under the Receiver Operating Characteristic Curve (AUC), Brier score, and permutation importance. Results Among patients, 19.5% received nirmatrelvir, 2.6% received molnupiravir, and 14% developed long-COVID. Traditional Cox and modified PyCox produced concordant hazard ratios (HR) for nirmatrelvir (0.874 and 0.878) and molnupiravir (0.909 and 0.918); original PyCox estimated stronger associations (HR = 0.822 and 0.879). The treatment-effect difference formed a gradient: 3.5-4.0 percentage-points for time-varying models, 4.6 for time-fixed Cox, and 5.7 for time-fixed PyCox. Discrimination, calibration, and fit were comparable overall; modified PyCox showed higher time-dependent AUCs (0.536-0.609) than time-fixed PyCox (0.481-0.519) and relied on largely different top predictors. Modified and original PyCox trained in 1 minute 14 seconds and 3 minutes 18 seconds, versus 5 minutes for traditional Cox. Discussion Treatment-contrast magnitude and covariate importance varied by models, suggesting temporal covariate structure and modeling approach jointly influence treatment-effect estimates. Conclusion Extending PyCox to accommodate time-varying covariates improves computational efficiency while maintaining estimation accuracy comparable to standard time-varying methods.

Authors

Institutions

Publication Details

Journal
JAMIA Open
Published
2026-09-04
DOI
https://doi.org/10.1093/jamiaopen/ooag186
Primary Topic
Statistical Methods and Inference
Type
article
Field-Weighted Citation Impact
0.00

Funders

Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

Deep Learning Survival Analysis with Time-Varying Covariates: Extending PyCox to Assess COVID-19 Antiviral Treatments and Long-COVID Associations

Kin Wah Fung, Haotian Xian, Seo Hyon Baik, Clement J. McDonald et al.
JAMIA Open
Statistical Methods and Inference
article

Deep Learning Survival Analysis with Time-Varying Covariates: Extending PyCox to Assess COVID-19 Antiviral Treatments and Long-COVID Associations

Kin Wah Fung, Haotian Xian, Seo Hyon Baik, Clement J. McDonald, Fitsum Baye
article en

Abstract

Abstract Objective To extend the PyCox to accommodate time-varying covariates using counting process data, addressing immortal time bias in survival analysis. Materials and Methods We modified PyCox to support counting process data structures for time-varying covariates and applied it to 2,246,913 Medicare beneficiaries aged ≥65 with COVID-19 (January-September 2022; 2,785,807 longitudinal records). We compared traditional Cox regression, original PyCox, and modified PyCox in estimating associations between early antiviral treatment (nirmatrelvir or molnupiravir) and long-COVID. Performance metrics included concordance index (C-index), integrated Brier score (IBS), and integrated negative binomial log-likelihood (IBLL) and time-dependent Area Under the Receiver Operating Characteristic Curve (AUC), Brier score, and permutation importance. Results Among patients, 19.5% received nirmatrelvir, 2.6% received molnupiravir, and 14% developed long-COVID. Traditional Cox and modified PyCox produced concordant hazard ratios (HR) for nirmatrelvir (0.874 and 0.878) and molnupiravir (0.909 and 0.918); original PyCox estimated stronger associations (HR = 0.822 and 0.879). The treatment-effect difference formed a gradient: 3.5-4.0 percentage-points for time-varying models, 4.6 for time-fixed Cox, and 5.7 for time-fixed PyCox. Discrimination, calibration, and fit were comparable overall; modified PyCox showed higher time-dependent AUCs (0.536-0.609) than time-fixed PyCox (0.481-0.519) and relied on largely different top predictors. Modified and original PyCox trained in 1 minute 14 seconds and 3 minutes 18 seconds, versus 5 minutes for traditional Cox. Discussion Treatment-contrast magnitude and covariate importance varied by models, suggesting temporal covariate structure and modeling approach jointly influence treatment-effect estimates. Conclusion Extending PyCox to accommodate time-varying covariates improves computational efficiency while maintaining estimation accuracy comparable to standard time-varying methods.

JAMIA Open
United States National Library of Medicine (US), National Center for Biotechnology Information (US)
U.S. Department of Health and Human Services, National Institutes of Health
Peace, Justice and strong institutions
Openalex Percentile: Top 8%
Statistical Methods and Inference
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.