Dynamic Magnesium Replacement Strategies and 28-Day All-Cause Mortality in Non-Cardiac Critically Ill Patients With Hypomagnesemia: A Target Trial Emulation Using the MIMIC-IV Database (2008-2019)
Conditions: Hypomagnesemia
Sponsor: Fujian Provincial Hospital

STUDY PROTOCOL AND STATISTICAL 
ANALYSIS PLAN 
Official Title: 
Dynamic Magnesium Replacement Strategies and 28-Day Mortality in Non-Cardiac Critically 
Ill Patients: A Target Trial Emulation Study 
Date: December 24, 2025 
Principal Investigator: Han Chen, M.D., Ph.D. 
Study Type: Observational (Retrospective Cohort) 
SECTION 1: STUDY PROTOCOL 
1. Study Identification 
Brief Title: 
Magnesium Replacement Strategies in Non-Cardiac ICU Patients 
Official Title: 
Dynamic Magnesium Replacement Strategies and 28-Day Mortality in Non-Cardiac Critically 
Ill Patients: A Nonrandomized Clinical Trial using Target Trial Emulation 
Study Design: 
Observational, Retrospective, Cohort Study. 
2. Study Status 
Overall Status: Completed (Retrospective analysis of existing data). 
Study Start Date: September 2025 (Analysis start). 
Primary Completion Date: December 2025. 
Study Completion Date: December 2025. 

3. Study Description 
Brief Summary: 
This study evaluates the association between different dynamic magnesium replacement 
strategies and 28-day all-cause mortality in non-cardiac critically ill patients with 
hypomagnesemia. Using data from the MIMIC-IV database, the study employs a target trial 
emulation framework (G-formula) to simulate and compare three strategies: 'Never Treat', 
'Always Treat', and 'Dynamic Treat' (treat only when hypomagnesemic). 
Detailed Description: 
Magnesium supplementation is common in the ICU, but evidence for its mortality benefit in 
non-cardiac patients is lacking. This study aims to fill the gap by emulating a randomized 
controlled trial using observational data. We utilize the Medical Information Mart for 
Intensive Care IV (MIMIC-IV) database. We define 'Time Zero' as the first occurrence of 
hypomagnesemia (<1.7 mg/dL) within 72 hours of ICU admission. We apply the parametric 
G-formula to adjust for time-varying confounding affected by prior treatment, a method 
superior to conventional regression for dynamic treatment regimes. The study aims to 
inform clinical guidelines regarding the necessity and safety of routine magnesium 
repletion. 
4. Study Design 
Observational Model: Cohort. 
Time Perspective: Retrospective. 
Target Follow-Up Duration: 28 Days. 
Biospecimen Retention: None. 
5. Groups / Cohorts 
Since this is a target trial emulation, the "Groups" are hypothetical strategies defined by the 
analysis as follows: 
Group 1: Never Treat Strategy 
Description: A simulated strategy where patients receive no magnesium supplementation 
throughout the 28-day follow-up, regardless of serum magnesium levels. 

Group 2: Always Treat Strategy 
Description: A simulated strategy where patients receive daily magnesium supplementation 
throughout the 28-day follow-up. 
Group 3: Dynamic Treat Strategy 
Description: A simulated strategy where magnesium supplementation is administered on a 
given day only if the daily serum magnesium level falls below 1.7 mg/dL. 
Reference: Natural Clinical Course (Observed data). 
6. Eligibility Criteria 
Study Population: Adult patients admitted to the ICU in the MIMIC-IV database (2008–
2019). 
Inclusion Criteria: 
1. Age ≥ 18 years. 
2. Admitted to the Intensive Care Unit (ICU). 
3. Developed hypomagnesemia (Serum Magnesium < 1.7 mg/dL) within the first 72 hours 
of ICU admission. 
Exclusion Criteria: 
1. Admitted due to cardiac or cardiosurgical causes (e.g., Cardiac Surgery Recovery Unit, 
CCU, CVICU). 
2. Underwent cardiac surgery during hospitalization (identified by ICD-9/10 procedure 
codes). 
3. Primary discharge diagnosis of major cardiac conditions (e.g., myocardial infarction, 
heart failure, arrhythmias). 
7. Outcome Measures 
Primary Outcome Measure: 
1. 28-Day All-Cause Mortality 
Description: Cumulative incidence of death from any cause within 28 days from inclusion 
(Time Zero). 
Time Frame: 28 days. 

Secondary Outcome Measures: 
1. Risk Difference (RD) 
Description: The absolute difference in mortality risk between the emulated strategies 
(Never/Always/Dynamic) and the natural clinical course or between strategies. 
Time Frame: 28 days. 
2. Number Needed to Treat (NNT) 
Description: Calculated to estimate the number of patients needed to be managed under a 
specific strategy to avert one death. 
Time Frame: 28 days. 
SECTION 2: STATISTICAL ANALYSIS PLAN (SAP) 
1. Analysis Dataset 
Source: MIMIC-IV database (version 3.1). 
Data Structure: Longitudinal dataset with a daily time-grid (days 0 to 27) relative to Time 
Zero (T0). 
Missing Data Handling: Last Observation Carried Forward (LOCF) will be used for time-
varying covariates. 
2. Variables 
Exposure (Treatment): Magnesium replacement therapy (binary variable per day: 
administered yes/no). 
Baseline Covariates: Age, Gender, Charlson Comorbidity Index (CCI). 
Time-Varying Covariates (Daily): 
    Laboratory: Serum magnesium, Hemoglobin, Creatinine, Arterial pH. 
    Vitals/Scores: Mean Blood Pressure (MBP), SOFA score. 
    Therapeutics: Vasopressor use (binary). 
Outcome: Death (binary). 
Competing Event: Live discharge from ICU. 
3. Statistical Methodology: The G-Formula 
To estimate the causal effect of dynamic magnesium strategies while accounting for time-
varying confounding affected by prior treatment (feedback loops), the parametric G-
formula will be employed. 

 
Step 1: Parametric Modeling 
Pooled parametric regression models will be fitted for: 
- The outcome (Death). 
- The competing event (Live discharge). 
- Each time-varying covariate (Mg, Hb, Cr, pH, MBP, SOFA, Vasopressors). 
Model Specifications: Models will include lagged values, cumulative averages, and non-
linear quadratic terms for continuous variables to capture complex dependencies. An 
interaction term between Magnesium Treatment and SOFA score will be included. 
 
Step 2: Monte Carlo Simulation 
A random sample of 5,000 subjects (bootstrapped) will be used for simulation. 
We will simulate the 28-day trajectory of the cohort under the three specific interventions 
(Never Treat, Always Treat, Dynamic Treat) by setting the treatment variable according to 
the rule of each strategy and predicting subsequent covariates and outcomes based on the 
fitted models. 
 
Step 3: Effect Estimation 
Cumulative Risk: Calculated for mortality at Day 28 for each strategy. 
Comparisons: Risk Difference (RD) and Risk Ratio (RR) will be calculated comparing 
'Always Treat' and 'Dynamic Treat' against 'Never Treat' (Reference). 
Inference: 95% Confidence Intervals (CIs) will be derived using non-parametric 
bootstrapping with 1,000 resamples. 
4. Sensitivity Analyses 
To verify the robustness of the G-formula models, the following analyses will be performed: 
1. Simplified Models: Re-running the analysis using linear models for all covariates 
(excluding quadratic terms). 
2. No Interaction Models: Re-running the analysis excluding the treatment-by-SOFA score 
interaction term. 
3. E-value Calculation: To assess the potential impact of unmeasured confounding on the 
observed Risk Ratio. 

5. Subgroup Analyses 
Treatment effects will be evaluated across the following baseline subgroups: 
1. Hypomagnesemia Severity: Severe vs. Mild (dichotomized by median). 
2. Renal Function: Creatinine ≥1.2 vs. < 1.2 mg/dL. 
3. Hemodynamic Status: Vasopressor use vs. None. 
4. SOFA Score: ≥8 vs. <8. 
5. Age: ≥ 65 vs. <65 years. 
Interaction p-values between subgroups will be estimated via bootstrap-based covariance 
correction. 
6. Software 
All analyses will be performed using R (version 4.3.1) and the 'gfoRmula' package. A two-
sided p-value < 0.05 will be considered statistically significant.