Logo van Bio Clinical Biostatistics Survival Analysis

Bio Clinical Biostatistics Survival Analysis

Organisatie
PKU-YuanGroup
bio-clinical-biostatistics-survival-analysis

Voert time-to-eventanalyses uit voor klinische onderzoeken, waaronder Cox-regressie met proportionele hazards en PH-diagnostiek, restricted mean survival time (RMST) bij niet-proportionele hazards, concurrerende risico's met Fine-Gray versus oorzaaksspecifieke Cox, gewogen log-rank en MaxCombo voor niet-proportionele hazards, recidiverende gebeurtenissen (Andersen-Gill, PWP, WLW) en interval-gecensureerde gegevens. Gebruik deze skill om time-to-event-eindpunten (OS, PFS, DOR, TTR, TTNT) te analyseren in oncologische of andere klinische onderzoeken.

Add to TypingMind

Overzicht

UitgeverPKU-YuanGroup
RepositoryOpenAI4S
Skillnaambio-clinical-biostatistics-survival-analysis
Sterren
622
Forks
72
Meegeleverde bestanden
2
LicentieMIT
Links
  • Instructies in Markdown

    Het model laadt het bestand SKILL.md alleen als dat nodig is. Dat kost dus alleen tokens als een verzoek daadwerkelijk bij de skill past.

  • Werkt met elk LLM

    AI-skills bestaan uit instructies in gewone Markdown, niet uit aanbiederspecifieke code. Daardoor werken ze met GPT, Claude, Gemini, Grok of een lokaal model.

  • Meegeleverde bestanden: 2

    Scripts, sjablonen en referentiemateriaal die het model tijdens het werken kan lezen. De bestanden kunnen alleen worden gelezen en worden nooit uitgevoerd.

  • Open source

    Gepubliceerd door PKU-YuanGroup op GitHub. Bekijk de bronbestanden voordat je de skill installeert.

Installatie

Installeer de AI-skill Bio Clinical Biostatistics Survival Analysis in TypingMind om deze met elk LLM te gebruiken, of voeg de skill toe aan een andere agent die SKILL.md kan lezen.

1

Installeren in TypingMind

TypingMind installeert een skill rechtstreeks vanuit de GitHub-map. De app leest SKILL.md, bundelt de bijbehorende bestanden en slaat het resultaat lokaal op.

  1. Open de app en ga naar Plug-ins → Skills.
  2. Kies "Installeren via GitHub".
  3. Plak de onderstaande URL van de skillmap en bevestig.
    https://github.com/PKU-YuanGroup/OpenAI4S/tree/main/skills/bioskills/bio-clinical-biostatistics-survival-analysis
  4. Schakel de skill in voor elke chat waarin je de skill wilt kunnen gebruiken.
Plug-ins → Skills → Skill toevoegen → Via GitHub-URL. Plak vervolgens de map-URL en druk op Doorgaan.
2

Installeren in een andere agent

Elke agent die het Agent Skills-formaat kan lezen, kan deze skill gebruiken — kopieer de map naar de skillmap van die agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/PKU-YuanGroup/OpenAI4S.git /tmp/OpenAI4S
mkdir -p .claude/skills
cp -r /tmp/OpenAI4S/skills/bioskills/bio-clinical-biostatistics-survival-analysis .claude/skills/bio-clinical-biostatistics-survival-analysis
Start Claude Code na het kopiëren opnieuw op, zodat de nieuwe skill wordt herkend.

Gebruik deze skill in TypingMind

Schakel Bio Clinical Biostatistics Survival Analysis in voor een chat naar keuze in TypingMind en het model doet de rest. De naam en beschrijving staan in de systeemprompt. Zodra een verzoek bij de skill past, laadt het model zelf de volledige instructies. Je hoeft de skill nooit handmatig aan te roepen. Pas als het model de skill daadwerkelijk gebruikt, kost dat tokens.

Het model laadt Bio Clinical Biostatistics Survival Analysis automatisch zodra een verzoek erbij past.

Werkt met elk AI-model

AI-skills zijn gewone Markdown-instructies in plaats van aanbiederspecifieke code. Daardoor is Bio Clinical Biostatistics Survival Analysis niet gebonden aan het model waarvoor de skill is geschreven. Installeer de skill één keer in TypingMind en gebruik deze met GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama of een lokaal model dat je zelf draait — allemaal met je eigen API-sleutels.

  • Alleen geladen wanneer nodig

    De systeemprompt bevat alleen de naam en beschrijving. De instructies worden bij het eerste bijpassende verzoek opgehaald, dus een ongebruikte skill kost niets.

  • Wissel van model tijdens een chat

    Omdat de skill uit instructies bestaat en niet uit code, blijft deze werken als je van model wisselt — het volgende model leest hetzelfde SKILL.md-bestand.

Skillinstructies

Dit is de inhoud van SKILL.md die het model laadt. Lees deze vóór de installatie — een skill bestaat uit instructies die je model zal volgen.

Version Compatibility

Reference examples tested with: lifelines 0.27+, scikit-survival 0.21+, statsmodels 0.14+, pandas 2.1+, numpy 1.26+. R packages cited (still the SOTA for survival): survival 3.8+, survRM2, cmprsk, riskRegression, mstate, flexsurv, icenReg, rpsftm.

Before using code patterns, verify installed versions match. If versions differ:

  • Python: pip show <package> then help(module.function) to check signatures
  • R: packageVersion('<pkg>') then ?function_name

If code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.

Time-to-Event Analysis for Clinical Trials

"Analyze time-to-event endpoint" -> Estimate a hazard, survival probability, cumulative incidence, or restricted mean time using a method calibrated to (a) whether proportional hazards holds, (b) whether competing events exist, (c) whether censoring is informative, and (d) which estimand the trial targets under ICH E9(R1).

The Single Most Important Modern Insight -- PH Almost Never Holds

In modern oncology with checkpoint inhibitors, targeted therapies, crossover, and depleted high-risk subjects over follow-up, proportional hazards (PH) violations are the rule, not the exception. The Cross-Pharma NPH Working Group (Lin et al 2020 Stat Biopharm Res; Magirr-Burman 2021 Stat Biopharm Res 15(2):295) documented systematic PH violations across phase III oncology trials, particularly delayed-effect patterns from checkpoint inhibitors.

The Cox HR is a time-averaged log-hazard ratio under PH violation (Xu-O'Quigley 2000), which may or may not be the estimand of interest. RMST (Royston-Parmar 2013) provides a clinically interpretable, hazard-free alternative.

Algorithmic Taxonomy

MethodEstimandInferenceStrengthFails when
Log-rank (unstratified)Test of S_A(t) = S_B(t) all tPermutation / asymptotic chi-squareStandard; preserves Type-I under PHUnderpowered under non-PH; treats all events equally
Stratified log-rankSame null within strata, pooledAsymptoticPreserves stratification factor from randomisationStratification factor must be pre-specified
Weighted log-rank G(rho, gamma)Direction-specific test under non-PHAsymptoticHigh power for delayed/early/middle effectsWeight choice must match true effect time profile; chasing weight = p-hacking
Cox PHConditional log-HRWald, LR, scoreStandard; semi-parametric; covariate adjustmentPH violation makes HR a misleading summary; check via cox.zph
Stratified CoxSame; baseline hazards differ by stratumWaldHandles non-PH by stratificationLoses inference on stratification variable; cannot interact treatment with strata
Time-varying Cox (tt())Time-dependent log-HRWaldQuantifies non-PH explicitlyInterpretability — no single "the HR"; choose g(t) carefully
Flexible parametric (Royston-Parmar)Time-varying log-HR via splinesWaldSmooth S(t), HR(t); supports extrapolationSpline choice affects results; software in R stpm2/stpm3
RMSTDifference in mean survival truncated at tauWald with delta or pseudo-obs regressionHazard-free; clinically interpretable in time unitstau choice; min follow-up across arms constrains tau
MaxComboMaximum over weighted log-rank familyAsymptotic multivariate normalRobust to range of NPH patternsCan reject in opposite directions on same data (Magirr 2022 critique)
Fine-Gray subdistribution HRConditional subdistribution HRWaldDirect CIF modelingAndersen-Keiding 2012 critique: violates causal hazard semantics
Cause-specific CoxConditional cause-specific HRWaldCausally interpretablePredicts hazards, not CIFs; need both for CIF prediction
Multi-state Cox (mstate)Transition-specific HRsWaldSubsumes competing risks; handles relapse/remissionMore complex; more parameters to estimate
Andersen-Gill (recurrent)Rate ratioRobust (cluster) WaldMost efficient under exchangeabilityAssumes exchangeable events
PWP (recurrent)Conditional event-order HRStratified WaldHandles event-order qualitative heterogeneityMore strata = more parameters; smaller per-stratum n
Interval-censored Cox (NPMLE)Cumulative hazardLikelihood ratioCorrect for periodic-assessment dataSlower; software in R icenReg

Postdoc reading list:

  • Royston-Parmar 2013 BMC Med Res Methodol 13:152 (RMST as primary)
  • Uno et al 2014 JCO 32:2380 (RMST in oncology)
  • Andersen-Keiding 2012 Stat Med 31:1074 (Fine-Gray semantic critique)
  • Putter-Schumacher-van Houwelingen 2020 Biom J 62:790 (Fine-Gray revisited; reduction factor)
  • Putter-Fiocco-Geskus 2007 Stat Med 26:2389 (competing risks tutorial)
  • Magirr-Burman 2021 Stat Biopharm Res 15(2):295 (MaxCombo critique)
  • Grambsch-Therneau 1994 Biometrika 81:515 (scaled Schoenfeld residuals)
  • Buyse-Molenberghs 1998 Biometrics 54:1014 (PFS-OS surrogacy framework)
  • Sun et al 2021 Pharm Stat 20:793 (estimands in oncology; ICH E9(R1) ICE strategies)
  • Sun 2006 The Statistical Analysis of Interval-Censored Failure Time Data (Springer)

Decision Tree by Scenario

ScenarioRecommended approachWhy
OS, drug expected to extend survival uniformly, PH plausibleStratified log-rank + Cox HR with cox.zph diagnosticStandard regulatory approach; pre-specify stratification factors from randomisation
PFS in immuno-oncology with expected delayed separationMaxCombo with pre-specified G(0,0), G(0,1), G(1,0), G(1,1); RMST as sensitivityRobust to NPH; explicit direction check (Magirr-Burman 2021)
OS with crossover to active armTreatment policy estimand (ITT) primary; RPSFT/IPCW as sensitivity for hypotheticalICH E9(R1); FDA/EMA accept both, ITT is primary
Time-to-event with assessment-schedule artifact (periodic scans)Interval-censored Cox (R icenReg::ic_par)Standard right-censoring at midpoint is biased
DOR (duration of response)KM among responders; censor at next-therapy/death/dropout per pre-specified estimandWeber 2023 Pharm Stat; responder-conditioned = doubly post-randomisation
Competing risk: drug efficacy on event A in context of high event-B mortalityCause-specific Cox for A AND for B; report both; CIF via Aalen-JohansenAndersen-Keiding 2012; Fine-Gray SHR is not causal
Prediction of CIF for clinical decisionFine-Gray for CIF estimate; cause-specific Cox for etiologyPutter-Fiocco-Geskus 2007 split
Multi-state model (alive -> relapse -> death)mstate framework with transition-specific Cox modelsSubsumes competing risks
Recurrent events (exacerbations, hospitalisations)Andersen-Gill with robust SE; cite event-order assumptionMost efficient; falls back to PWP if order matters
Single-arm OS extrapolation for HTAFlexible parametric (Royston-Parmar) + external informationSmooth tail; supports extrapolation beyond trial follow-up
Non-PH with crossing hazardsRMST with pre-specified tau; OR multi-state modelHR loses meaning under crossing

Cox PH Diagnostics -- The Therneau-Grambsch Test (and Its Pitfalls)

Goal: Detect violations of the proportional hazards assumption that would invalidate the Cox HR as a meaningful summary statistic.

Approach: Compute scaled Schoenfeld residuals (Grambsch-Therneau 1994); regress against a time-transform g(t) under H0 of zero slope; supplement the asymptotic p-value with a graphical residual plot since the test is sensitive to g(t) choice and sample-size dependent.

python
from lifelines import CoxPHFitter
from lifelines.statistics import proportional_hazard_test

cph = CoxPHFitter()
cph.fit(df, duration_col='time', event_col='event', formula='treatment + age + baseline_score')
cph.print_summary()

# Schoenfeld residuals PH test (lifelines)
results = proportional_hazard_test(cph, df, time_transform='rank')
print(results.summary)

# In R: cox.zph(coxph_fit) returns same with KM transform as default

The g(t) choice trap (Park-Hendry 2015 American Journal of Political Science): the test power depends critically on g(t). KM transform, identity, log, and rank give materially different p-values. With n > 5000 even trivial deviations reject; with n < 100 the test misses meaningful violations.

Critical interpretation rule: a global p > 0.05 does NOT mean PH holds — it means the null cannot be rejected. The graphical diagnostic is more informative — a flat smoothed line is the target. Use cox.zph as a failure detector, not a PH validator.

python
# Plot scaled Schoenfeld residuals (lifelines)
cph.check_assumptions(df, p_value_threshold=0.05, show_plots=True)

Fixes when PH violated

  1. Stratify on the violating covariate (loses inference on it)
  2. Time-dependent coefficients: coxph(Surv(t, d) ~ x + tt(x), tt=function(x,t,...) x*log(t)) in R; lifelines: formula='treatment * time'
  3. Royston-Parmar flexible parametric (R flexsurv::flexsurvspline or rstpm2::stpm2)
  4. RMST as primary; HR as secondary

Restricted Mean Survival Time (RMST) -- The Modern Alternative

Royston-Parmar 2013 + Uno 2014 case: RMST(tau) = E[min(T, tau)] = integral from 0 to tau of S(t) dt = area under KM curve up to tau. The difference RMST_A(tau) - RMST_B(tau) is a time gained in months -- clinically interpretable, requires no PH assumption, always estimable up to the minimum of the largest follow-up across arms.

python
# Python: rmst via lifelines or manual
from lifelines.utils import restricted_mean_survival_time
from lifelines import KaplanMeierFitter

kmf_A = KaplanMeierFitter().fit(df[df['arm']=='A']['time'], event_observed=df[df['arm']=='A']['event'])
kmf_B = KaplanMeierFitter().fit(df[df['arm']=='B']['time'], event_observed=df[df['arm']=='B']['event'])
tau = 36  # months; pre-specified
rmst_A = restricted_mean_survival_time(kmf_A, t=tau)
rmst_B = restricted_mean_survival_time(kmf_B, t=tau)
print(f'RMST diff: {rmst_A - rmst_B:.2f} months')

# R: survRM2::rmst2(time, status, arm, tau=36) is the standard

The tau (truncation time) choice

  • Statistical constraint: tau <= min(largest follow-up time in each arm) to avoid extrapolation (Tian et al 2020 Biometrics gives rigorous treatment)
  • Clinical constraint: tau should reflect a clinically meaningful horizon (5-year OS in adjuvant; 24-month PFS in metastatic)
  • Data-dependent tau inflates Type-I error — MUST be pre-specified in SAP. Post-hoc tau tuning to chase significance is p-hacking.

Pseudo-observation regression (Andersen-Hansen-Klein 2004)

For each subject i, compute jackknife pseudo-value θ_i(tau) = n·RMST(tau) - (n-1)·RMST_{-i}(tau). Regress pseudo-values on covariates via GEE — enables RMST regression WITH covariate adjustment, including time-varying covariates, no PH assumption.

R implementation: pseudo::pseudomean() + GEE via geepack::geeglm().

Lambert critique (postdoc reading): Paul Lambert (stpm3 author) is on record that RMST is "not unambiguously simpler than HR for clinicians." HR has 50-year pedagogy lead. RMST is cumulative (not instantaneous) and cannot detect crossing hazards beyond chosen tau. The argument for RMST is hazard-free interpretability under non-PH; the argument against is communication and tau sensitivity.

Competing Risks -- The Andersen-Keiding Framework

Fine-Gray subdistribution hazard

python
# Python: scikit-survival or lifelines (limited support); R is the SOTA
# R: library(cmprsk); crr(time, fstatus, cov, failcode=1, cencode=0)
# R: library(riskRegression); FGR(formula, data=df, cause=1)

Fine-Gray 1999 introduced subdistribution hazard lambda^FG(t) = -d/dt log[1 - F_1(t)] where F_1 is CIF for cause 1. The proportional subdistribution hazards model places covariates on this hazard. Subjects who experience competing events remain in the risk set with IPCW weighting — mathematically convenient but conceptually weird.

The Andersen-Keiding 2012 critique (Stat Med 31:1074): Fine-Gray subdistribution hazard violates the three principles for valid hazard functionals:

  1. Hazard must be a real instantaneous risk among those truly at risk -> FG keeps dead competing-event subjects "at risk"
  2. Covariate effects must be interpretable as causal -> FG coefficients confound the competing-event hazard
  3. Hazard must support landmarking (conditioning on survival to s) -> FG does not

The competing-risk confounding trap (Putter-Schumacher-van Houwelingen 2020 Biom J 62:790; the reduction factor decomposition makes it explicit): any covariate that increases the cause-specific hazard of competing event A will decrease the subdistribution hazard for event B simply because A removes subjects from the population at risk of B. A Fine-Gray "protective" effect on B may be an iatrogenic killer via A.

Practical rule (Putter-Fiocco-Geskus 2007)

  • For prediction of CIF (cumulative incidence) -> Fine-Gray is fine; report CIF curves and SHR
  • For etiology / causal effect on the event -> use cause-specific Cox (treat competing events as censoring); report cause-specific HRs for BOTH event of interest AND competing events
  • For multi-state semantics (alive -> relapse -> death) -> use multi-state framework with transition-specific Cox models

The CIF is always estimable

Aalen-Johansen estimator (multi-state generalisation of KM) gives the CIF non-parametrically. The KM estimator is biased upward in the presence of competing risks — it treats competing events as non-informative censoring and overestimates 1 - CIF.

r
# R: library(mstate); msfit(coxph_fit, newdata, trans); probtrans(msfit_obj)
# R: library(survival); survfit(Surv(time, event_factor) ~ 1) with multi-state Surv

Log-Rank Variants and MaxCombo

python
from lifelines.statistics import logrank_test, multivariate_logrank_test

# Stratified log-rank (lifelines uses `weightings=` -- note plural)
results = multivariate_logrank_test(
    df['time'], df['arm'], df['event'], weightings='peto'
)
# weightings options (lifelines 0.27+): None, 'wilcoxon', 'tarone-ware',
# 'peto', 'fleming-harrington' (also accepts kwargs for Fleming-Harrington p, q)
TestCitationWhen to use
Standard log-rank (G(0,0))Mantel 1966PH holds
WilcoxonWilcoxon 1945Down-weights late events; early-effect detection
Tarone-WareTarone-Ware 1977Compromise
Peto-PetoPeto-Peto 1972, Prentice 1978Robust to ties and censoring distribution differences between arms
Fleming-Harrington G(rho, gamma)Fleming-Harrington 1981Direction-specific: G(0,1) for late-emphasis (delayed effects), G(1,0) for early
MaxComboKarrison 2016Take maximum over family; control multiplicity via joint MVN

The MaxCombo controversy

Magirr-Burman 2021 Stat Biopharm Res 15(2):295: MaxCombo can reject the null in opposite directions on the same dataset. Formally, it rejects the strong null H_0: S_A(t) = S_B(t) for all t, but the rejection direction is determined by the dominant weight, which can flip across portions of the curve. KEYNOTE-042 demonstration: MaxCombo simultaneously favouring pembrolizumab AND chemo depending on weight choice.

Cross-Pharma NPH Working Group recommendation: MaxCombo with directionality constraints — require positive z-statistic at the late-emphasis weight before declaring superiority; report the dominant weight and its direction.

Interval Censoring -- When Standard Right-Censoring Is Wrong

PFS is REALLY interval-censored — events known only between consecutive RECIST scans. The convention is to treat it as right-censored at midpoint or first-PD-scan date. This is a long-standing methodological compromise defensible only when scan intervals are short and balanced across arms.

r
# R: library(icenReg)
# fit_ic <- ic_par(cbind(left, right) ~ treatment + age, data=df, dist='weibull', model='ph')
# ic_sp() for semi-parametric; ic_npar() for NPMLE

Sun 2006 The Statistical Analysis of Interval-Censored Failure Time Data (Springer) is the canonical reference. NPMLE via Turnbull's algorithm; Cox-like regression via Finkelstein 1986 / Pan 1999 EM algorithms.

When to switch from right-censored midpoint to interval-censored: scan intervals > 4 weeks; scan timing differs between arms (open-label trials with potential differential ascertainment); regulatory submission where 2-3% effect-size shift matters.

Recurrent Events -- AG vs PWP vs WLW

ModelRisk setBaseline hazardBest when
Andersen-Gill 1982Total time; subject at risk continuously between eventsCommon (counting process)Events exchangeable; rate model; no event-order effect
PWP gap-time (Prentice-Williams-Peterson 1981)Stratified by event number; subject enters stratum k after event k-1Stratum-specificEvent-order matters; later events qualitatively different
WLW (Wei-Lin-Weissfeld 1989)Marginal -- separate Cox per event orderPer-event-orderMultiple types of events; uses sandwich variance
python
# Python: lifelines does not have native AG; use coxph with (start, stop, event) format
# R: coxph(Surv(start, stop, event) ~ trt + cluster(id), data=long_df) for AG
# R: + strata(enum) for PWP

Box-Steffensmeier critique: WLW is often misused — fitting separate Cox to "time to 2nd event" treats it as a first-event problem rather than conditional on prior history, inflating effect estimates. PWP-gap-time is the cleanest conditional model. AG most efficient when exchangeability holds.

Modern advice (Rogers et al 2014; Cook-Lawless 2007 book): AG with robust variance as default; PWP if events qualitatively heterogeneous; avoid WLW unless events are truly distinct types.

Oncology PFS/OS Estimands -- The 2024 Reality

Per ICH E9(R1), the same PFS dataset yields different HRs depending on censoring rules. Each rule corresponds to a different intercurrent-event strategy:

Censoring ruleICE strategyEstimand
Censor at last assessment before missing visitsHypothetical (had visit not been missed)What would PFS be if visits never missed?
Censor at start of new anticancer therapyHypothetical (no subsequent therapy)What would PFS be without rescue?
Count subsequent therapy as eventComposite (subsequent therapy = treatment failure)Treatment-failure-free survival
No censoring (event = last assessment + progression)Treatment policyReal-world PFS with policy of allowing rescue

The 2024 European Journal of Cancer demonstration (PMID 38547775): two sets of censoring rules — FDA-favoured vs trialist-favoured — applied to the same PFS data shifted median PFS from 32 to 43 months in the experimental arm with no change in control. This is the estimand changing, not analytic artefact.

Fleming 2025 argument: handle subsequent therapy by treatment-policy -- continue follow-up rather than censor at the switch -- keeping progression + death as the composite endpoint to preserve ITT. Controversial because not censoring at subsequent therapy blurs interpretation as "tumor growth control."

Informative censoring -- detection and handling

The mechanism: standard right-censored Cox / KM assumes censoring is non-informative (the censoring process is unrelated to the underlying failure time after conditioning on observed covariates). When this fails, KM is biased upward in the arm with informative censoring -- patients who drop out due to lack of efficacy or toxicity are precisely the ones who would have failed early.

TROPiCS-02 informative censoring (Li et al 2023 JCO 41:1629): "evaporative cooling" of progression events. Patients on the toxic arm discontinue and are censored BEFORE the next protocol-mandated scan that would have captured progression; KM biases PFS upward in the toxic arm. Templeton 2020 Nat Rev Clin Oncol and Campigotto-Weller 2014 JCO are foundational citations.

Detection workflow:

  1. Tabulate censoring reasons by arm from CDISC DS (Disposition) or ADaM ADTTE CNSR integer values:

    • CNSR=1 (lost to follow-up): symmetric across arms = OK
    • CNSR=2 (withdrew consent): if asymmetric, investigate why
    • CNSR=3 (admin EoS): symmetric by definition
    • CNSR=4 (subsequent therapy initiated): differential is the canonical informative pattern
    • CNSR=5+ (toxicity discontinuation): differential is highly informative
  2. Compare KM curves for censoring distribution by arm. If "time-to-censoring" KM differs by arm in same direction as outcome, suspect informative censoring.

  3. Cox-Snell or Schoenfeld residuals on censoring-as-event model: if treatment is significantly associated with censoring hazard, censoring is informative.

Handling strategies (per ICH E9(R1) and Sun 2021):

StrategyWhen to useImplementation
Composite endpoint (treatment-policy)ICE has clinical meaning (subsequent therapy = treatment failure)Re-define event as "first of (progression OR subsequent therapy OR death)"; eliminates need for censoring assumption
IPCW with stabilised weights (Robins 1992)Hypothetical estimand under "no informative dropout"R ipw::ipwtm or custom: weight = inverse probability of remaining uncensored given baseline + time-varying covariates
Sensitivity: worst-case / best-case imputationBounding the true effect under informative censoringCensored patients = events at censoring date (worst case); or remain at risk (best case); report range
Multistate modelMultiple competing causes of censoringmstate for transition-specific Cox; handles death + dropout + subsequent therapy as separate states
RPSFT / structural nested failure timeCrossover-induced informative censoringR rpsftm package; FDA / EMA acceptable for OS hypothetical estimand under crossover

IPCW workflow (stabilised weights per Robins-Finkelstein 2000):

r
# Stabilised IPCW: w(t) = S_num(t) / S_denom(t)
# where S_denom predicts remaining-uncensored given baseline + time-varying covariates,
# and S_num predicts remaining-uncensored given treatment alone (numerator for stabilisation)

# Step 1: fit censoring (NOT event) hazard models
# Note: outcome variable for these models is "1 if censored, 0 if event or still at risk"
denom_cens <- coxph(Surv(time, censored) ~ treatment + age + baseline_severity, data=df)
num_cens   <- coxph(Surv(time, censored) ~ treatment, data=df)

# Step 2: compute survival probabilities (NOT hazards) for "remaining uncensored"
# basehaz + linear predictor -> S(t) per subject; the `survfit` + `summary` API gives S_i(t_i)
S_denom <- summary(survfit(denom_cens, newdata=df), times=df$time)$surv
S_num   <- summary(survfit(num_cens,   newdata=df), times=df$time)$surv

# Step 3: stabilised IPCW weight per subject at their observed time
df$ipcw <- S_num / S_denom

# Step 4: weighted Cox for the event of interest with robust SE
fit_ipcw <- coxph(Surv(time, event) ~ treatment + age + baseline_severity,
                  data=df, weights=df$ipcw, robust=TRUE)

Note: in practice use the ipw::ipwtm (or ipwExt) wrapper which handles the time-varying weights and stabilisation correctly; the pseudocode above shows the underlying machinery. Verify weight distribution: median weight near 1, no extreme values (>10 indicates near-violation of positivity).

Operational rule: for any TTE primary analysis where DS shows differential censoring reasons by arm, the regulatory expectation is (1) tabulate reasons in CSR, (2) report sensitivity under IPCW or composite, (3) discuss whether primary HR/RMST changes under sensitivity.

ADaM ADTTE -- The CNSR Convention Trap

CDISC ADTTE convention: CNSR = 0 for events, positive integers for censoring reasons (1 = lost to follow-up, 2 = withdrew consent, 3 = admin EoS, 4 = subsequent therapy, etc.). Opposite to most stat packages which use 1 = event.

python
# Convert ADTTE for Python / R
import pandas as pd

adtte = pd.read_csv('ADTTE.csv')
adtte['event'] = (adtte['CNSR'] == 0).astype(int)  # 1 = event for survival packages
adtte['time'] = adtte['AVAL']  # AVAL is in days/months per AVALU

This is a perpetual bug source. See clinical-biostatistics/cdisc-data-handling for the full ADTTE specification.

Per-Method Failure Modes

Cox PH violation undetected

  • Trigger: Significant treatment HR reported without cox.zph diagnostic
  • Mechanism: Cox HR is a time-averaged log-HR under PH violation; the "the HR" interpretation breaks
  • Symptom: Hazard plots show crossing; cox.zph rejects PH; KM curves diverge then converge
  • Fix: Report cox.zph result; switch to RMST or time-varying Cox; cite Grambsch-Therneau 1994

Fine-Gray reported as causal effect

  • Trigger: Fine-Gray SHR interpreted as "treatment effect on event of interest"
  • Mechanism: SHR confounds with competing-event hazard (Andersen-Keiding 2012)
  • Symptom: SHR interpretation contradicts cause-specific Cox results; reviewer confusion
  • Fix: Use cause-specific Cox for etiology; Fine-Gray for CIF prediction only; report both per Putter-Fiocco-Geskus 2007

KM curve biased upward under competing risks

  • Trigger: KM applied to event of interest treating competing events as non-informative censoring
  • Mechanism: KM estimates 1 - cause-specific hazard cumulative; competing events deplete denominator
  • Symptom: KM survival exceeds Aalen-Johansen 1 - CIF estimate
  • Fix: Use Aalen-Johansen estimator for CIF; never KM in competing-risk setting

MaxCombo direction flipping

  • Trigger: MaxCombo significant; direction not pre-specified
  • Mechanism: MaxCombo's family can include weights that favour opposite directions
  • Symptom: Different reports show opposite "winner" depending on weight choice
  • Fix: Pre-specify directional constraints; require positive z at late-emphasis weight before claiming superiority; cite Magirr-Burman 2021

Tau chosen post-hoc to favour significance

  • Trigger: RMST tau adjusted after seeing data
  • Mechanism: Selection bias; tau-tuning is a flavour of p-hacking
  • Symptom: Sponsor's RMST result differs from independently re-analysed with pre-specified tau
  • Fix: Pre-specify tau in SAP; cite Tian 2020 Biometrics

Right-censored midpoint for interval-censored PFS

  • Trigger: Scan intervals long or differential between arms; standard right-censored Cox applied
  • Mechanism: Midpoint imputation is biased; SE underestimates
  • Symptom: Replication with interval-censored Cox gives different point estimate and wider CI
  • Fix: R icenReg::ic_par or ic_sp; Sun 2006

CNSR convention confusion

  • Trigger: ADTTE CNSR=1 passed to R survival::Surv(time, event) expecting event=1
  • Mechanism: Censoring/event role reversed
  • Symptom: "Event count" matches censoring count from CSR; nonsensical HR
  • Fix: Always convert: event = (CNSR == 0).astype(int); cite ADaM IG v1.3

Reconciliation: When Methods Disagree

PatternLikely causeAction
Cox HR significant, RMST difference non-significantHR is time-averaged log-HR under PH violation; RMST captures cumulative effectIf PH violated, RMST is the more interpretable summary; HR may be artifact of late-event preponderance
MaxCombo rejects null but direction depends on weightMaxCombo's rejection direction is determined by dominant weight; can flip across weight choices (Magirr-Burman 2021)Pre-specify directional constraint (positive z at late-emphasis weight) before declaring superiority; do NOT post-hoc select winning weight
Fine-Gray SHR vs cause-specific Cox HR conflict on directionFine-Gray confounds with competing-event hazard; cause-specific isolates causal effect on event of interest (Andersen-Keiding 2012)For causal claims use cause-specific Cox; Fine-Gray for CIF prediction only; report both per Putter-Fiocco-Geskus 2007
Stratified log-rank p < unstratified pStratification removes between-stratum variance; correct standard error smallerStratified analysis matches randomisation; unstratified is over-conservative (SE biased upward, power loss) per Kahan-Morris 2012
KM survival curve vs Aalen-Johansen 1-CIF disagree in competing-risks settingKM treats competing events as non-informative censoring (biased upward)Use Aalen-Johansen for CIF; never KM in competing-risk setting
Schoenfeld-formula SS insufficient at trial end (events under-collected)Non-PH (immuno-oncology delayed effect) violates Schoenfeld assumption; under-estimates events 20-50%Re-power using Lakatos 1988 or simulation under expected HR(t); cite Lin 2020 NPH Working Group
Right-censored midpoint Cox HR vs interval-censored Cox HR differMidpoint imputation biased when scan intervals long or asymmetricSwitch to interval-censored Cox via icenReg when scan intervals > 4 weeks or differ by arm
ADTTE CNSR=1 produces nonsensical resultsCDISC convention reversal: CNSR=0 means event in ADaMAlways convert: event = (CNSR == 0).astype(int) before stat-package call

Quantitative Thresholds

ThresholdSourceRationale
cox.zph p > 0.05 is NOT proof of PHGrambsch-Therneau 1994; Park-Hendry 2015Failure detector, not validator
RMST tau <= min(largest follow-up per arm)Tian 2020 BiometricsAvoid extrapolation; tau pre-specified in SAP
MaxCombo with directional constraintMagirr-Burman 2021 Stat Biopharm Res 15(2):295Prevents opposite-direction rejections
Cause-specific Cox for etiology; FG for CIF predictionPutter-Fiocco-Geskus 2007Andersen-Keiding 2012 critique
Scan intervals > 4 weeks -> interval-censored analysisSun 2006Midpoint right-censoring is biased
10 events per covariate for CoxPeduzzi 1995 J Clin EpidemiolBelow this, bias and overfitting
Schoenfeld 1981 events formula assumes PHSchoenfeld 1981Under non-PH, under-estimates required events by 20-50%; cite Lakatos 1988 for non-PH SS

Common Errors

Error / symptomCauseSolution
Cox HR reported with cox.zph p < 0.001 ignoredDiagnostic skippedReport RMST or time-varying Cox; cite Therneau-Grambsch
KM curve labeled "survival from event of interest" with competing risksBias upwardAalen-Johansen CIF; never KM with competing risks
Fine-Gray HR reported as "treatment effect"Misinterpretation of SHRCite Andersen-Keiding; report cause-specific too
MaxCombo with no direction restrictionDirection-flipping riskPre-specify constraints (Magirr-Burman 2021)
ADTTE CNSR=1 used as "1=event"Convention reversalevent = (CNSR == 0).astype(int)
PFS midpoint right-censored without interval-censored sensitivityScan-schedule biasInterval-censored analysis when scan intervals long
Stratified randomisation factor not in CoxOver-conservative (SE biased upward, Type-I below nominal, power loss)Include strata via strata() or as covariate
Schoenfeld SS calculation in immuno-oncologyPH assumption violatedSimulate under expected hazard pattern (Lakatos 1988); use MaxCombo SS
tau set to longest follow-up post-hocRMST p-hackingPre-specify tau in SAP; cite Tian 2020
Recurrent-event WLW with naive "time to 2nd event"Inflated effectAG with robust SE, or PWP gap-time

Anticipated Reviewer Pushback

PushbackResponse
"PH assumption check?"cox.zph result reported with caveat that p>0.05 doesn't prove PH; graphical diagnostic in supplement
"Why RMST not HR?"PH violated; HR is misleading time-average; RMST is hazard-free in interpretable time units (Royston-Parmar 2013)
"How was tau chosen?"Pre-specified in SAP based on clinical horizon AND statistical constraint min(largest follow-up); cite Tian 2020
"Fine-Gray or cause-specific Cox?"Both reported per Putter 2007: FG for CIF prediction, cause-specific Cox for etiology; cite Andersen-Keiding 2012
"MaxCombo direction validation?"Pre-specified directional constraint; positive z at late-emphasis weight required; cite Magirr-Burman 2021
"Crossover handling?"ITT primary (treatment policy); RPSFT or IPCW as sensitivity (hypothetical); cite Robins-Tsiatis
"Informative censoring?"Censoring reasons tabulated by arm; symmetric -> no concern; differential -> sensitivity under composite or worst-case
"ADTTE CNSR convention?"Explicit conversion documented: ADaM CNSR=0 means event; converted to event=1 for downstream R/Python
"Schoenfeld SS under expected NPH?"Simulation-based SS using expected hazard pattern (Lakatos 1988); NOT Schoenfeld formula
"Multi-state vs Fine-Gray?"Multi-state when alive->relapse->death is the disease model; Fine-Gray only for CIF prediction of one cause

References

  • Andersen PK, Keiding N. 2012. Interpretability and importance of functionals in competing risks and multistate models. Stat Med 31:1074-1088.
  • Andersen PK, Hansen MG, Klein JP. 2004. Regression analysis of restricted mean survival time based on pseudo-observations. Lifetime Data Anal 10:335-350.
  • Buyse M, Molenberghs G. 1998. Criteria for the validation of surrogate endpoints in randomized experiments. Biometrics 54:1014-1029.
  • Cox DR. 1972. Regression models and life-tables. JRSS-B 34:187-220.
  • Fine JP, Gray RJ. 1999. A proportional hazards model for the subdistribution of a competing risk. JASA 94:496-509.
  • Karrison TG. 2016. Versatile tests for comparing survival curves based on weighted log-rank statistics. Stat J 16:678-690.
  • Lakatos E. 1988. Sample sizes based on the log-rank statistic in complex clinical trials. Biometrics 44:229-241.
  • Sun S, Weber HJ, Butler E, Rufibach K, Roychoudhury S. 2021. Estimands in hematologic oncology trials. Pharm Stat 20(4):793-805.
  • Magirr D, Burman CF. 2021. The strong null hypothesis and the MaxCombo test. Stat Biopharm Res 15(2):295-296. (Earlier "Cherry-picking in survival analysis" attribution was a blog post, Oct 2022.)
  • Mantel N. 1966. Evaluation of survival data and two new rank order statistics arising in its consideration. Cancer Chemotherapy Reports 50:163-170.
  • Peduzzi P et al. 1995. Importance of events per independent variable in proportional hazards analysis. J Clin Epidemiol 48:1503-1510.
  • Putter H, Fiocco M, Geskus RB. 2007. Tutorial in biostatistics: competing risks and multi-state models. Stat Med 26:2389-2430.
  • Putter H, Schumacher M, van Houwelingen HC. 2020. On the relation between the cause-specific hazard and the subdistribution rate for competing risks data: the Fine-Gray model revisited. Biom J 62:790-807.
  • Royston P, Parmar MKB. 2013. Restricted mean survival time: an alternative to the hazard ratio. BMC Med Res Methodol 13:152.
  • Schoenfeld DA. 1981. The asymptotic properties of nonparametric tests for comparing survival distributions. Biometrika 68:316-319.
  • Sun J. 2006. The Statistical Analysis of Interval-Censored Failure Time Data. Springer.
  • Grambsch PM, Therneau TM. 1994. Proportional hazards tests and diagnostics based on weighted residuals. Biometrika 81:515-526.
  • Tian L, Jin H, Uno H, Lu Y, Huang B, Anderson KM, Wei LJ. 2020. On the empirical choice of the time window for restricted mean survival time. Biometrics 76(4):1157-1166.
  • Uno H et al. 2014. Moving beyond the hazard ratio in quantifying the between-group difference in survival analysis. JCO 32:2380-2385.
  • Xu R, O'Quigley J. 2000. Estimating average regression effect under non-proportional hazards. Biostatistics 1:423-439.

Related Skills

  • clinical-biostatistics/effect-measures - HR vs RMST as effect measures; CI methods
  • clinical-biostatistics/trial-reporting - ICH E9(R1) estimand framework for time-to-event
  • clinical-biostatistics/missing-data-sensitivity - Informative censoring and tipping-point for survival
  • clinical-biostatistics/cdisc-data-handling - ADTTE structure and CNSR convention
  • clinical-biostatistics/subgroup-analysis - Subgroup HTE for survival endpoints
  • clinical-biostatistics/power-and-sample-size - Schoenfeld and Lakatos sample size for TTE
  • clinical-biostatistics/multiplicity-graphical - Co-primary survival endpoints
  • machine-learning/survival-analysis - Predictive survival models and ML extensions

Meegeleverde bestanden

Zolang de skill geladen is, leest het model deze bestanden als dat nodig is. Het model kan ze alleen lezen; ze worden nooit uitgevoerd.

Veelgestelde vragen

Wat doet de AI-skill Bio Clinical Biostatistics Survival Analysis?

Voert time-to-eventanalyses uit voor klinische onderzoeken, waaronder Cox-regressie met proportionele hazards en PH-diagnostiek, restricted mean survival time (RMST) bij niet-proportionele hazards, concurrerende risico's met Fine-Gray versus oorzaaksspecifieke Cox, gewogen log-rank en MaxCombo voor niet-proportionele hazards, recidiverende gebeurtenissen (Andersen-Gill, PWP, WLW) en interval-gecensureerde gegevens. Gebruik deze skill om time-to-event-eindpunten (OS, PFS, DOR, TTR, TTNT) te analyseren in oncologische of andere klinische onderzoeken.

Waarom Bio Clinical Biostatistics Survival Analysis gebruiken in TypingMind?

Omdat je deze skill één keer installeert en met elk model kunt gebruiken. Bio Clinical Biostatistics Survival Analysis bestaat uit gewone Markdown in plaats van aanbiederspecifieke code. Dezelfde skill werkt dus met GPT-5, Claude, Gemini, Grok of een lokaal model. Ook als je midden in een chat van model wisselt, blijft de skill werken. TypingMind werkt met je eigen API-sleutels, dus je betaalt aanbieders rechtstreeks in plaats van een abonnement per gebruikersplek af te sluiten. Je skills en chats blijven in je eigen opslag.

Hoe installeer ik Bio Clinical Biostatistics Survival Analysis in TypingMind?

Open Plug-ins → Skills → Installeren vanaf GitHub in TypingMind en plak https://github.com/PKU-YuanGroup/OpenAI4S/tree/main/skills/bioskills/bio-clinical-biostatistics-survival-analysis. TypingMind leest het bestand SKILL.md, bundelt de bijbehorende bestanden en installeert het geheel als een skill die je per chat kunt inschakelen.

Welke AI-modellen kunnen Bio Clinical Biostatistics Survival Analysis gebruiken?

Elk model dat je in TypingMind koppelt. AI-skills bestaan uit gewone Markdown-instructies in plaats van aanbiederspecifieke code. GPT, Claude, Gemini, Grok en lokale modellen kunnen deze skill dus allemaal laden wanneer een verzoek erbij past.

Hoeveel AI-modellen kan ik met Bio Clinical Biostatistics Survival Analysis gebruiken?

Zoveel als je wilt. Je kunt Bio Clinical Biostatistics Survival Analysis gebruiken met elk model dat skills ondersteunt, zoals GPT, Claude, Gemini, Grok, DeepSeek, Mistral of Llama. Allemaal in TypingMind met je eigen API-sleutels.

Is de AI-skill Bio Clinical Biostatistics Survival Analysis gratis?

Ja. Deze skill is door PKU-YuanGroup op GitHub gepubliceerd onder de licentie MIT. Je betaalt alleen je eigen AI-aanbieder voor de tokens die je gebruikt.

Wat zijn AI-skills?

Een AI-skill is een herbruikbare bundel instructies die een AI-model leert hoe het één specifieke taak moet uitvoeren. De skill volgt het open Agent Skills-formaat: het bestand SKILL.md bevat de naam en beschrijving van de skill. Daarnaast kan de skill scripts, sjablonen of referentiebestanden bevatten die het model nodig heeft. Het model leest de instructies alleen als je verzoek bij de skill past. Een geïnstalleerde skill kost dus niets zolang deze niet wordt gebruikt.

Waarin verschillen AI-skills van plug-ins of MCP-servers?

Een plug-in of MCP-server geeft een model nieuwe tools om aan te roepen: code die ergens wordt uitgevoerd en een resultaat teruggeeft. Een AI-skill geeft het model juist kennis en een werkwijze: hoe het een taak moet aanpakken, welke stappen het moet volgen en hoe goede uitvoer eruitziet. Skills bestaan uit gewone Markdown en hebben dus geen server, API-sleutel of runtime nodig. Ze werken met elk model.

Bekijk alles

Maak nu je eigen AI-werkruimte

Schrijf je in voor onze nieuwsbrief en blijf op de hoogte van nieuwe functies en toekomstige weggeefacties 👇