← Về thư mục
📄 / / profiles / r-and-d / raw_evidence / OpenAI4S / skills / bioskills / bio-clinical-biostatistics-subgroup-analysis / references / usage-guide.md

Subgroup Analysis - Usage Guide

Overview

Performs subgroup and heterogeneous treatment effect (HTE) analyses for clinical trials with explicit distinction between confirmatory ("assessment") subgroups eligible for label claims (EMA 2019) and discovery/exploratory subgroups. Covers Mantel-Haenszel pooling with Simpson's-paradox detection, interaction tests, RERI for additive interaction, Gail-Simon qualitative interaction test, modern data-adaptive HTE methods (STEPP, SIDES, causal forests, X/R-learners), Bayesian shrinkage (Dixon-Simon, EXNEX), and graphical multiplicity (Bretz-Maurer via gMCP).

Prerequisites

pip install statsmodels scipy numpy pandas matplotlib scikit-learn

R is recommended for modern HTE methods (most are R-only):

install.packages(c('grf', 'policytree', 'causalToolbox', 'personalized',
                   'SIDES', 'stepp', 'quint', 'partykit', 'gMCP', 'RBesT', 'brms'))

Python alternatives for HTE:

pip install econml causalml dowhy

Quick Start

Tell your AI agent what you want to do: - "Single model with treatment-by-subgroup interaction (NOT comparing per-subgroup p-values)" - "Mantel-Haenszel pooled OR + Breslow-Day + forest plot to detect Simpson's paradox" - "Causal forest in grf with honest splitting + RATE/AUTOC test (Yadlowsky 2025)" - "STEPP sliding-window analysis for continuous biomarker subgroups" - "Bayesian shrinkage via Dixon-Simon for adjusted subgroup estimates" - "Graphical multiplicity in gMCP allocating alpha across primary + key secondary + pre-specified subgroup"

Example Prompts

Interaction tests (the correct way)

"Fit a single logistic regression with treatment * age_group interaction. Test interaction p-value as the formal evidence for HTE. Do NOT compare per-subgroup p-values (statistically invalid)."

"Compute RERI for additive interaction on the treatment-by-sex effect. Delta-method or bootstrap CI for RERI."

Stratified analysis

"Run MH pooled OR + Breslow-Day across study sites. Forest plot stratum-specific ORs to detect Simpson's paradox."

Modern HTE

"Causal forest in grf for HTE on response with patient features X. Use honesty=TRUE; report calibration test result and RATE/AUTOC omnibus p (Yadlowsky 2025). Bias-correct estimates via grf's variable_importance + cross-fitting."

"STEPP sliding-window analysis for continuous biomarker (HbA1c). Use permutation supremum test for pattern flatness -- not naive pointwise CIs."

"SIDES recursive partitioning with permutation-adjusted base-vs-complement p (Lipkovich 2011) for subgroup discovery."

Bayesian shrinkage

"Apply Dixon-Simon Bayesian shrinkage to my forest of subgroup effects. Centre tau prior at HalfNormal(0, 0.25). Report posterior shrunken estimates."

"EXNEX basket trial with 5 strata; 0.5 EX / 0.5 NEX mixture per Neuenschwander 2016. Sensitivity over weights 0.1-0.9."

Multiplicity

"Pre-specified 6 subgroups in confirmatory trial. Allocate 20% of primary alpha to subgroup family (Dane et al 2019 EFSPI recommendation). Implement as gMCP graph with weighted alpha propagation."

Forest plot

"Generate forest plot of subgroup ORs (sex, age, race, severity, region) with overall pooled estimate as reference. Log scale; CI shown."

What the Agent Will Do

  1. Distinguish pre-specified ("assessment") vs discovery ("exploratory") subgroups per EMA 2019
  2. Fit single model with interaction term (NOT separate per-subgroup models with p-value comparison)
  3. For stratified designs, include strata in CMH or logistic regression
  4. For continuous biomarkers, use STEPP (sliding-window) with permutation supremum test
  5. For data-adaptive HTE, use causal forests with honest splitting + RATE/AUTOC + bias-correction
  6. For basket trials or borrowing, EXNEX or robust MAP with sensitivity over mixture weights
  7. Apply graphical multiplicity per Bretz-Maurer 2009 with pre-specified alpha allocation
  8. Forest plot stratum/subgroup-specific ORs as the primary visual

Tips