# Statistical Analysis Plan (SAP) — Early benzodiazepine exposure and short-term hepatic encephalopathy treatment initiation in critically ill patients with cirrhosis (target trial emulation with clone-censor-weight)

**Study question**: Among critically ill patients with cirrhosis, does benzodiazepine initiation (any route) within 24 h of ICU admission increase the risk of new hepatic encephalopathy (HE) treatment initiation between 24 h and 7 days, and 28-day mortality?

**SAP version**: v1.0 | **Frozen**: 2026-10-18 (effective upon freezing) | **Target journal**: TBD at time of freezing; subsequently determined as BMC Gastroenterology.
**Data source**: MIMIC-IV v3.1 (PhysioNet credentialed access; calendar eras computed via `anchor_year_group` because dates are shifted per patient).

> **Honesty statement**: During the feasibility-probe stage (2026-10-18, before this SAP was frozen), **crude outcome rates were already observed** (HE treatment initiation 36.2% vs 23.7%; 28-day mortality 30.6% vs 21.0%). No effect model was fitted at that stage. Two cohort-definition changes (intravenous-only → any route; addition of ward-based new-user exclusions) occurred **after** the crude rates were seen and are documented with their timeline in the deviation log (D-01/D-02). After freezing, the primary-analysis definition was not changed.

---

## 1. Target trial protocol

| Component | Target trial (ideal RCT) | Emulation in routine data |
|---|---|---|
| Eligibility | Adults with cirrhosis requiring ICU care; new users of HE treatment | Adults ≥18; narrow ICD-10 K70.2/K70.3/K70.4/K71.7/K74 (primary) / K70–K76 (sensitivity); ICU LOS >24 h; new-user ×2 (any-channel benzodiazepine before ICU = excluded; lactulose/rifaximin within first 24 h = excluded) |
| Treatment strategies | A: initiate benzodiazepine sedation within 24 h grace period; B: no initiation during the same period (alternative sedatives permitted) | Trigger = ICU admission; action = midazolam/lorazepam/diazepam (inputevents 221668/221385/221623 + pharmacy/eMAR same names); grace period = 24 h (sensitivity 12/36 h); no prohibited co-interventions |
| Assignment | Randomisation | Cloning (each stay copied into both arms) |
| Time zero | Study enrolment | ICU admission (icustays.intime); eligibility/assignment/follow-up aligned |
| Follow-up | 28 days | 28 d from admission; post-discharge death via dod (date precision, ±1 d boundary cases reported); outcome window [24 h, 168 h] |
| Outcomes | Primary: HE treatment initiation; secondary: mortality | Primary = new lactulose or rifaximin initiation 24 h–7 d (pharmacy starttime; corroborated by eMAR 97.4%); secondary = 28 d/7 d all-cause mortality, ICU LOS, 7 d RMST/RMTL, Aalen-Johansen cumulative incidence (competing events = death, alive discharge) |
| Causal contrast | Per-protocol effect | Yes (intent is not recorded in ICU data; same rationale as Qin & Zou 2026) |
| Identification assumptions | Exchangeability/positivity/consistency | Exchangeability: IPCW + covariate set (§6); positivity: exposure rate 28.4% (340/1197), censoring curves + ESS reported; consistency: strategies are executable drug initiations |
| Analysis | Per-protocol weighted analysis | CCW + per-arm IPCW logistic censoring models + weighted logistic/Cox + patient-level bootstrap 1000 replicates |

## 2. Data audit and cohort (G1, completed)
- Code locking: benzodiazepines inputevents 221668/221385/221623 (verified in d_items); oral channel pharmacy/eMAR names `midazolam|lorazepam|diazepam`; HE drugs `lactulose|rifaximin` (pharmacy 63,456+11,762 rows; inputevents zero entries). **Zero-row entries**: lactulose/rifaximin in inputevents. **Code corrections recorded**: albumin=50862, ammonia=50866, serum sodium=50983 (memory-based misuse of 50943/50983/50824 corrected after verification in d_labitems).
- Funnel (frozen, `probe_benzo_cirrhosis_freeze.py`): 94,458 → adults + narrow codes 3,755 → LOS>24 h 3,044 → exclude pre-ICU benzodiazepine (any channel) 746+4 (IV) → exclude HE treatment within 24 h → **final 1,197 (340 vs 857)**; all assertions passed.
- Units: temperature °F→°C conversion coded; dob/dod date-precision declared.
- Disclosure: withdrawal-regimen benzodiazepines (chlordiazepoxide etc.) in 0–24 h for 43 stays are not part of the exposure definition.

## 3. Covariates and grid
- This design uses a one-shot grace period (not hourly triggering); no hourly grid. Censoring-model covariates use the **first 24 h window** (exposure starts within the window; within-window covariate values are used only if measured before the dose time; first-24 h RASS with lag rules not applicable to a point exposure — difference from hourly designs stated).
- Missingness: per-variable missing rates reported; complete cases + multiple-imputation sensitivity (imputation fitted once on the full cohort).

## 4. Model freezing
- Not applicable (exposure is a recorded administration; no model/score trigger). G4 not triggered.

## 5. Strategies and thresholds
- Strategy A: any-route benzodiazepine within 24 h of intime (any of the three agents); Strategy B: no initiation within 24 h.
- No threshold scaling issues (exposure is a binary administration fact).

## 6. CCW and weights (G2)
- Censoring: arm-B clones censored at actual benzodiazepine initiation; arm-A clones without initiation censored at the grace-period boundary; **death is never a censoring event in survival analyses**.
- Censoring models: **per-arm** logistic (different censoring mechanisms by arm); covariates = §3 list (age/sex/race/Charlson and components/MELD three components/lactate/WBC/Hb/platelets/Na/K/HR/SBP/RR/SpO₂/mechanical ventilation/vasopressors/RRT/alcohol-related vs not/prior HE ICD/SBP and variceal bleeding ICD/urine output). **SOFA/APSIII/GCS/CAM-ICU excluded** (measured over first 24 h, partly after exposure; GCS may itself be altered by sedation; reasons stated in Methods). RASS enters sensitivity versions (agitation confounding pathway).
- Weights: stabilised w = P(C=0|A)/P(C=0|X,A); truncation = **per-arm** 99th percentile of uncensored weights (sensitivity 95/97/none); convergence = max_iter 5000 with digit-wise recheck.
- Diagnostics: per-arm censoring-model AUROC, weight quantiles/extremes/ESS (definition = (Σw)²/Σw², unit = clone-stay, sole definition throughout).

## 7. Primary analysis
- Weighted risk difference (primary estimand) + weighted logistic OR; survival endpoints weighted KM/log-rank/Cox HR; Aalen-Johansen (competing risks).
- Bootstrap: patient-level 1000 replicates (multiple stays per patient are not independent); each replicate re-fits the full chain (censoring models + truncation); percentile CIs.
- Reporting: weighted risks (both arms), RD, OR/HR + 95% CI, p; number of stays following each strategy, censoring rates, ESS, maximum untruncated weight.

## 8. Identifiability diagnostics (mandatory, G2 evidence)
1. Truncation-percentile sensitivity curve (95/97/99/0.5–99.5/none): estimate crosses zero or moves monotonically → report non-identifiable;
2. 1/w_raw distribution of uncensored clones (<1% flag);
3. Deaths carried away by censoring (28 d mortality of uncensored vs full cohort);
4. Per-arm censoring-model AUROC + covariate-augmentation experiments (change on adding RASS);
5. Leave-one-covariate-out sensitivity (focus: RASS, mechanical ventilation, MELD);
6. Positivity: per-arm exposure rates, pre/post-weighting SMD (Love plot).

## 9. Negative controls (G5)
- **Primary negative-control outcome**: new **proton pump inhibitor** initiation 24 h–7 d (no biologic pathway from benzodiazepines; driven by the same "sicker patients receive more medications" process — a positive result would indicate residual confounding). PPI itemids/pharmacy names verified before freezing.
- Secondary negative control: new statin initiation 24 h–7 d (low baseline use, expected few events, supplementary).
- Criterion: the weighted RD 95% CI of each control includes 0.

## 10. Sensitivity analyses (pre-declared)
Grace periods 12/36 h | IV-only exposure (arm n=187) | broad ICD K70–K76 | outcome-definition matrix: lactulose AND rifaximin, lactulose only, rifaximin only, ±24 h co-initiation | truncation 95/97/99/none | machine-learning censoring models (RF/GBM) | first-stay-only | excluding withdrawal-regimen benzodiazepine co-use (43 stays) | excluding prior-HE ICD | RASS stratification (<−2 vs ≥−2) and RASS-augmented censoring models | eICU external replication (optional extension: same code in both databases).

## 11. Multiplicity
- Primary analysis = 1 hypothesis (RD for the primary outcome at the 24 h grace period); two-sided p<0.05.
- Secondary outcomes and all sensitivity/subgroup analyses are exploratory; no per-test significance claims; subgroup forest plot labelled exploratory; subgroup interaction p<0.01.

## 12. Reporting standards
STROBE + TARGET (TTE reporting); MIMIC official 6 reporting items; checklists submitted with the manuscript; code submitted (data use agreement obligation).

## 13. Gates (G1–G5)

| Gate | Criterion | Evidence file |
|---|---|---|
| G1 | Funnel closes; codes verified; zero-row entries archived | `probe_benzo_cirrhosis_freeze.py` output + code table (formalised as `cohort_flow.json`) |
| G2 | ESS/extremes/convergence/per-arm truncation/identifiability diagnostics | `ccw_diag.json` |
| G3 | Whole manuscript 0 untraceable numbers | `paper_factory/numeric_guard.py` |
| G4 | Not applicable (no model trigger) | — |
| G5 | Negative-control CIs include 0 | `negative_control.json` |

## Pre-freeze to-dos (did not block freezing; blocked only formal P1 extraction)
1. PPI/statin itemids and pharmacy row counts verified (negative-control operationalisation);
2. Per-covariate itemid table (with units) + physiological-filter ranges and excluded counts;
3. Prior HE/SBP/bleeding ICD code tables verified;
4. Target journal's official guidelines archived (completed before P10).
