Skip to content

survival: implement initial parametric AFT model family #95

Description

@TheHiddenObserver

Context

statgpu currently provides semiparametric Cox models but no maintained parametric accelerated-failure-time family. AFT models are the next bounded survival extension after the Cox Phase-1 baseline and complement, rather than replace, proportional-hazards analysis.

Roadmap: PR #89. Nonparametric Kaplan-Meier/Nelson-Aalen work is tracked in #94.

Goal

Implement an initial three-backend AFT framework with Weibull, log-normal, and log-logistic distributions, explicit parameterization, model-based inference, formula support, and survival prediction functions.

Design requirements

Before implementation, document:

  • the location/scale and acceleration-factor parameterization;
  • coefficient sign convention;
  • distribution-specific scale/shape mappings;
  • whether a common AFTRegression interface or distribution-specific classes are public;
  • intercept and ancillary/scale parameter treatment;
  • result and summary object shape;
  • sample-weight semantics;
  • censoring and entry support;
  • optimizer and convergence contract;
  • relationship to the existing loss/solver framework.

Do not claim alignment with R survreg or lifelines without an explicit mapping of their coefficient, scale, and shape conventions.

Initial statistical scope

Distributions:

  • Weibull;
  • log-normal;
  • log-logistic.

Data:

  • right-censored (time, event) observations;
  • positive finite durations;
  • optional analytic sample weights only if their likelihood interpretation is fixed and externally validated;
  • delayed entry/start-stop may be deferred unless fully supported by the selected likelihood.

Outputs:

  • coefficients and ancillary parameters;
  • log-likelihood;
  • convergence diagnostics;
  • model-based covariance, standard errors, test statistics, p-values, and confidence intervals;
  • AIC/BIC with a documented parameter count;
  • survival, CDF, hazard, cumulative hazard, and quantile predictions;
  • conditional median/quantile survival where defined.

Backend contract

  • NumPy CPU;
  • CuPy CUDA;
  • Torch CUDA;
  • backend-native likelihood, gradient, Hessian or Hessian-vector products, and prediction;
  • explicit device requests must not silently fall back;
  • dtype and numerical-stability rules must be tested;
  • known domain failures during line search may be handled narrowly, while unrelated runtime/device/OOM errors remain fatal.

Formula contract

  • formula/dataframe and array paths must produce aligned design matrices;
  • intercept behavior must be explicit;
  • categorical terms, interactions, transforms, missing-data row alignment, and prediction column ordering must follow current formula rules;
  • ancillary/scale formulas are out of scope unless separately designed.

External alignment

Use matched comparisons against:

  • R survival::survreg;
  • lifelines Weibull/LogNormal/LogLogistic AFT fitters;
  • direct likelihood or simulation checks for parameter mappings.

Compare:

  • coefficients after parameter mapping;
  • scale/shape parameters;
  • log-likelihood;
  • covariance/standard errors;
  • predicted survival and quantiles;
  • AIC/BIC where definitions align.

Non-goals

  • no generalized gamma or spline-based flexible parametric survival in the first issue;
  • no frailty/random effects;
  • no Fine-Gray or multi-state model;
  • no time-varying coefficients;
  • no survival forest/boosting;
  • no nonconvex penalties in the first phase.

Required validation

  • exact likelihood/gradient checks on small synthetic data;
  • finite-difference or automatic-differentiation gradient/Hessian checks where appropriate;
  • uncensored equivalence to the corresponding log-duration regression where applicable;
  • censored simulation recovery;
  • degenerate and invalid-input tests;
  • formula/array parity;
  • NumPy/CuPy/Torch parity;
  • external alignment with explicit convention mappings;
  • physical CuPy and Torch GPU validation;
  • EN/CN model documentation and examples;
  • benchmark artifact for any performance claim.

Acceptance criteria

  • The common AFT parameterization and public API are documented before final implementation.
  • Weibull, log-normal, and log-logistic right-censored likelihoods are implemented.
  • Fit, summary, likelihood diagnostics, AIC/BIC, and prediction functions are available.
  • Model-based covariance and inference pass strict alignment or documented tolerance gates.
  • Formula and array APIs agree after row/column alignment.
  • NumPy, CuPy, and Torch paths pass parity tests without silent fallback.
  • R/lifelines parameter mappings are explicit and externally validated.
  • Complete CPU, compatibility, and physical-GPU gates pass.
  • English and Chinese documentation are synchronized.

PR decomposition

Prefer staged PRs:

  1. common likelihood/result framework plus one distribution;
  2. remaining two distributions and external alignment;
  3. formula/prediction/documentation and benchmark completion if not already included.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions