Abstract
Objectives
This study aimed to systematically evaluate whether glycemic variability (GV) could provide independent incremental prognostic value for in-hospital death among patients with community-acquired pneumonia (CAP), beyond conventional clinical variables including the SOFA score.
Methods
Data were retrieved from the Medical Information Mart for Intensive Care IV (MIMIC-IV) database, with a multicenter intensive care unit (ICU) database used as the external validation set. The coefficient of variation was employed to quantify GV. Feature selection was performed using the Boruta algorithm, and 9 machine learning (ML) models were constructed. The area under the receiver operating characteristic curve (AUC), Brier score, Deviance and other metrics were used to evaluate model performance, and SHapley Additive exPlanations (SHAP) analysis was conducted to reveal feature contributions. The predictive performance of the two models was further compared using the change in the area under the receiver operating characteristic curve (ΔAUC), Net Reclassification Index (NRI), Integrated Discrimination Improvement (IDI), and Decision Curve Analysis (DCA), to assess the incremental contribution of GV to model performance.
Results
A total of 5256 patients were included, of whom 1175 (22.36%) experienced in-hospital death. After Boruta feature selection, 15 key features were retained. In the internal validation set, among the 9 ML models, the LR model performed optimally, with the highest AUC of 0.7851 (95% confidence interval [CI]: 0.7587–0.8115), the lowest Brier score (0.138), and the lowest Deviance (0.861). SHAP analysis indicated that Sequential Organ Failure Assessment (SOFA) score, Charlson Comorbidity Index, age, respiratory rate (RR) and weight were the top 5 core predictive factors. The AUC of the LR model without GV was 0.7623, with a ΔAUC of -0.0002; both NRI and IDI were not applicable (NA). The calibration curves and DCA curves of the two models were similar.
Conclusion
In the model incorporating conventional clinical variables, GV did not yield independent incremental predictive value, highlighting the necessity of rigorous evaluation for additional biomarkers prior to clinical implementation.
Clinical trial number
Not applicable.
Supplementary Information
The online version contains supplementary material available at 10.1186/s12890-026-04443-4.
Keywords: Glycemic variability, Community-acquired pneumonia, Machine learning
Background
Community-acquired pneumonia (CAP) refers to infectious inflammation of the lung parenchyma incurred outside the hospital setting [1]. As a highly prevalent infectious respiratory disease worldwide, CAP accounts for approximately 1.4 million emergency department visits, 740,000 hospitalizations, and 41,000 deaths annually in the United States, imposing a substantial healthcare burden [2]. The pathogenesis of CAP is complex, with significant heterogeneity in disease progression driven by the interaction between pathogen diversity and host immune status [3]. Timely and accurate assessment of in-hospital death risk in CAP patients is therefore crucial for optimizing treatment strategies and allocating medical resources rationally. However, conventional assessment tools are limited by restricted applicability and inadequate predictive accuracy, failing to meet the demands of individualized diagnosis and treatment. Thus, developing more efficient prognostic prediction models holds important clinical value [4, 5].
Glycemic Variability (GV), a dynamic indicator reflecting the degree of blood glucose fluctuations [6], has garnered increasing attention in prognostic assessment of critically ill patients in recent years. In populations with sepsis, acute kidney injury, and aortic diseases, higher GV has been significantly associated with short-term death [7–9]. Acute glycemic fluctuations markedly trigger excessive oxidative stress, resulting in mitochondrial dysfunction [10], degradation of the vascular endothelial glycocalyx and increased vascular permeability [11]. Meanwhile, GV activates the nuclear factor-κB (NF-κB) signaling pathway and promotes the release of numerous pro-inflammatory cytokines such as tumor necrosis factor-α (TNF-α) and interleukin-6 (IL-6), thereby inducing systemic inflammatory disturbance [12]. Sepsis further exacerbates these pathological changes. Under septic conditions, endotoxins and excessive inflammatory mediators induce peripheral insulin resistance [13, 14] and pancreatic β-cell dysfunction, which substantially aggravate glycemic fluctuations in critically ill patients. In addition, sepsis-related microcirculatory disturbance and endothelial injury [15], amplify GV-mediated oxidative stress and inflammatory cascades, eventually aggravating organ damage and raising the risk of mortality.
Although the mechanistic relationship between GV and adverse clinical outcomes in critically ill patients has been well established, and sepsis can potentiate its pathological effects, previous prognostic models for CAP have incorporated GV [16] or adopted machine learning (ML) approaches [17]. Nevertheless, few studies have systematically investigated whether GV can provide independent incremental predictive value after adjustment for conventional clinical variables. Accordingly, this study constructed an in-hospital mortality prediction model. Accordingly, this study constructed an in-hospital mortality prediction model based on clinical data of CAP patients. We further compared the predictive performance of models with and without GV, so as to clarify the actual incremental prognostic value of GV in CAP.
Methods
Data sources
Data for this study were retrieved from the Medical Information Mart for Intensive Care IV (MIMIC-IV) database, which contains demographic characteristics, vital signs, laboratory results, medication records, medical imaging data, clinical procedures, bedside vital sign measurements, laboratory test outcomes, various interventions, drugs, imaging reports, and death indicators. Patients in the MIMIC-IV database were randomly divided into a training set and an internal validation set at a 7:3 ratio. Additionally, the e-ICU database was used as an independent external validation set.
Inclusion and exclusion criteria
Inclusion criteria: [1] Adult patients (≥ 18 years old) with their first admission to the Intensive Care Unit (ICU) in the MIMIC-IV database; [2] Primary diagnosis of CAP.
Exclusion criteria: [1] Insufficient blood glucose data (fewer than 3 measurements during ICU hospitalization); [2] Multiple ICU admissions (two or more separate ICU stays); [3] Missing key variable values; [4] Variables with missing values exceeding 35%.
CAP cases were identified from the diagnoses_icd table in the MIMIC-IV and eICU databases using ICD-9 and ICD-10 codes. The included ICD-9 codes are 486, 482.2, 482.84, 480.9, 481, 482.83, 482.31, 482.41, 079.6, 483.0, 483.1 and 011.60. The included ICD-10 codes are J18.9, J12.9, J14, A48.1, J13, J15.6, J15.4, J15.21, B97.4, J15.7, J16.0 and A15.0 [18].
Data extraction and processing
The study variables included sex (female, male), age, weight, hypertension (yes, no), Sequential Organ Failure Assessment (SOFA) score, Charlson Comorbidity Index, temperature, respiratory rate (RR), white blood cell (WBC), red blood cell count, blood urea nitrogen (BUN), partial thromboplastin time (PTT), potassium, sodium, hemoglobin (Hb), insulin use and GV.
GV was quantified using the coefficient of variation (CV), calculated as the ratio of the standard deviation to the mean of repeated measurements, referring to the method described by Chen et al. [19]. The time window for calculating GV in this study covered the entire ICU stay.
To reduce bias caused by missing data, variables with missing values exceeding 35% were excluded during data collection. For variables with missing values less than 35%, multiple imputation was performed to handle missing data for subsequent analyses. Detailed imputation results are presented in Supplementary Fig. 1. The distribution of imputed values was highly consistent with that of the original observed data, indicating that multiple imputation did not introduce significant bias into the data. In addition, multiple imputations were also performed in the external validation set.
Study outcome
The primary outcome of this study was in-hospital death, with patients categorized into the alive group and the in-hospital death group.
ML feature selection, modeling, evaluation, and interpretability
The Boruta algorithm was used to assess the importance of candidate variables, and a double validation strategy was employed to further confirm the robustness of the results, ensuring the reliability and interpretability of the included features in model construction. Boruta is a all-relevant feature selection algorithm based on random forest. It introduces shadow features as references to determine whether the importance of real features is significantly higher than that of random noise variables, so as to identify all relevant variables [20]. In this study, in-hospital death was defined as the outcome variable, and all other variables were included in the candidate feature set. The Boruta model was implemented based on the random forest algorithm. The number of decision trees (ntree) was set to 500, and the significance level was set at p = 0.05. All analyses were performed with a fixed random seed (set.seed = 123) to ensure result reproducibility. After the initial screening, variables marked as tentative were further evaluated using the TentativeRoughFix algorithm to reduce the impact of uncertain features on model stability. Finally, all confirmed variables were retained as the final feature set for subsequent model construction.
Features were categorized into three groups according to their importance: Confirmed, Rejected and Tentative. Only Confirmed variables were included in the final analytical model. This algorithm can process both continuous and categorical variables and is suitable for exploratory analysis of high-dimensional biomedical data [21]. It can robustly screen all variables associated with the study outcome. Sufficient sample size, pre-processed missing values and adequate computing resources are required for its application.
Nine ML algorithms were utilized for model development: Logistic Regression (LR), eXtreme Gradient Boosting (XGBoost), Light Gradient Boosting Machine (LightGBM), Ridge Regression (RR), Decision Tree (DT), K-Nearest Neighbors (KNN), Random Forest (RF), Multi-Layer Perceptron (MLP), and Support Vector Machine (SVM).
The predictive performance of the models was comprehensively evaluated using Area Under the Receiver Operating Characteristic curve (AUC), Brier score, Deviance, accuracy, sensitivity, specificity, positive predictive value (PPV), negative predictive value (NPV), F1-score, calibration curve, and Decision Curve Analysis (DCA).
The interpretability of the models was visualized using SHapley Additive exPlanations (SHAP) plots.
Model performance (with vs. without the inclusion of GV) was compared using the change in the area under the receiver operating characteristic curve (ΔAUC), Net Reclassification Index (NRI), Integrated Discrimination Improvement (IDI), calibration curve, and DCA.
Complete hyperparameter settings of the models
This study included a total of nine predictive models. A single-layer 5-fold stratified cross-validation was employed for hyperparameter tuning, and the training set was kept completely independent. The hyperparameter settings and optimization methods for each model are as follows: For the DT model, the hyperparameters included tree depth (tree_depth), minimum node size (min_n), and complexity parameter (CP, ranging from 10⁻⁶ to 10⁻³), with Bayesian optimization used for tuning. The RF model had hyperparameters mtry [2–10], trees (100–1000), and min_n (7–55), also tuned via Bayesian optimization. The XGBoost model involved hyperparameters such as mtry, min_n, tree_depth, learning rate (10⁻³ to 10⁻¹), loss_reduction, and sample_size, and used random grid search (20 parameter combinations). The LightGBM model included tree_depth, trees, learn_rate, mtry, min_n, and loss_reduction, also tuned using random grid search (20 parameter combinations). The SVM model had hyperparameters cost and rbf_sigma, tuned via random grid search. The MLP model used hidden_units, penalty, and epochs, with Bayesian optimization. The KNN model used neighbors and the weight function, also tuned via Bayesian optimization. LR involved no hyperparameter optimization and directly included all candidate variables. The RR model tuned only the regularization strength parameter penalty, with the mixing parameter mixture fixed at 0, and employed both grid search and Bayesian optimization for comparative analysis. All models applied the “one-standard-error rule (1-SE rule)” during hyperparameter selection to prioritize simpler model structures.
Statistical analysis
R Studio version 4.3.3 was used for data cleaning, analysis, and visualization. Normally distributed quantitative data were expressed as mean ± standard deviation, and intergroup comparisons were performed using analysis of variance. Non-normally distributed quantitative data were presented as median (P25-P75), and intergroup comparisons were conducted using the Kruskal-Wallis test. Qualitative data were expressed as counts (percentages), and intergroup comparisons were made using the chi-square test or Fisher’s exact test. The variance inflation factor (VIF) was applied to assess multicollinearity among variables. A two-tailed P value < 0.05 was considered statistically significant.
Results
Baseline characteristics of patients
A total of 5256 participants were enrolled in this study, among whom 1175 experienced in-hospital death (Fig. 1; Table 1). The mean age of the in-hospital death group was 72.39 ± 13.99 years, with a male predominance. In the alive group, the mean age was 64.15 ± 16.88 years, and females accounted for 42.3%. Compared with the alive group, the in-hospital death group had significantly higher SOFA score (9.22 ± 4.56 vs. 6.44 ± 3.89, P < 0.001), Charlson Comorbidity Index (6.68 ± 2.88 vs. 4.85 ± 2.93, P < 0.001) and a higher insulin use rate (38.3% VS 32.5%, P < 0.001). Additionally, significant differences were observed between the two groups in terms of age, weight, temperature, RR, WBC, red blood cell count, BUN, PTT, potassium, and Hb (all P < 0.05).
Fig. 1.
Flow diagram of patient inclusion and exclusion criteria
MIMIC-IV: Medical Information Mart for Intensive Care IVICU: Intensive Care Unit
Table 1.
Patients’ baseline characteristics
| level | Alive | In-hospital deaths | P | |
|---|---|---|---|---|
| n | 4081 | 1175 | ||
| Sex (%) | Female | 1725 (42.3) | 514 (43.7) | 0.385 |
| Male | 2356 (57.7) | 661 (56.3) | ||
| Age (mean (SD)), years | 64.15 (16.88) | 72.39 (13.99) | < 0.001 | |
| Weight (mean (SD)), kg | 83.16 (25.60) | 77.31 (22.95) | < 0.001 | |
| Hypertension (%) | Yes | 2464 (60.4) | 702 (59.7) | 0.721 |
| No | 1617 (39.6) | 473 (40.3) | ||
| Insulin use, n (%) | Yes | 1328 (32.5) | 450 (38.3) | < 0.001 |
| No | 2753 (67.5) | 725 (61.7) | ||
| SOFA score (mean (SD)) | 6.44 (3.89) | 9.22 (4.56) | < 0.001 | |
| Charlson Comorbidity Index (mean (SD)) | 4.85 (2.93) | 6.68 (2.88) | < 0.001 | |
| Temperature (mean (SD)), °C | 36.89 (0.89) | 36.74 (0.95) | < 0.001 | |
| RR (mean (SD)), min | 21.61 (6.51) | 22.71 (6.42) | < 0.001 | |
| WBC (mean (SD)), K/uL | 12.73 (10.10) | 14.20 (10.66) | < 0.001 | |
| Red blood cell count (mean (SD)), m/uL | 3.69 (0.79) | 3.55 (0.81) | < 0.001 | |
| BUN (mean (SD)), mg/dL | 27.39 (22.49) | 37.68 (28.12) | < 0.001 | |
| PTT (mean (SD)), second | 37.69 (21.60) | 41.41 (25.81) | < 0.001 | |
| Potassium (mean (SD)), mEq/L | 4.18 (0.76) | 4.26 (0.80) | 0.001 | |
| Sodium (mean (SD)), mEq/L | 137.97 (5.71) | 138.26 (7.12) | 0.151 | |
| Hb (mean (SD)), g/dL | 11.05 (2.25) | 10.62 (2.31) | < 0.001 | |
| GV (mean (SD)), % | 0.26 (0.58) | 0.28 (0.37) | 0.473 |
SOFA Sequential Organ Failure Assessment, RR Respiratory Rate, WBC White Blood Cell, BUN Blood Urea Nitrogen, APTT Activated Partial Thromboplastin Time, Hb Hemoglobin, GV glycemic variability
Feature selection
The VIF values of all variables were less than 5, indicating no obvious multicollinearity (Supplementary Table 1). As shown in Fig. 2, the following variables were further included in the model: temperature, weight, GV, insulin use, potassium, PTT, respiratory rate, sodium, Hb, WBC, red blood cell count, BUN, age, Charlson Comorbidity Index, and SOFA score.
Fig. 2.
Feature selection
Model development and validation
Nine ML algorithms were used to develop prediction models. As shown in Fig. 3, in the training set, among 9 ML models, the RF model achieved the best performance, with an AUC of 0.9142 [95% confidence interval (CI): 0.9045–0.9238]. The DT and LightGBM models followed, with AUCs of 0.8098 (95% CI: 0.7912–0.8284) and 0.7987 (95% CI: 0.7813–0.8161), respectively. In the internal validation set, among the 9 ML models, the LR model performed optimally, with the highest AUC of 0.7851 (95% confidence interval [CI]: 0.7587–0.8115) (Fig. 4A), the lowest Brier score (0.138), and the lowest Deviance (0.861). In addition, the LR model also showed favorable performance in key metrics including accuracy (0.719), sensitivity (0.693), specificity (0.726), positive predictive value (0.415), negative predictive value (0.894), and F1-score (0.519) (Table 2). The calibration curves indicated that the LR, RF, and XGBoost models had good calibration (Fig. 5). DCA showed that the LR, XGBoost, and RF models achieved higher net benefit within the threshold probability range of 0–75%, outperforming other models as well as the “treat all” and “treat none” strategies (Fig. 4B). Based on the above metrics, the LR model was ultimately identified as the optimal prediction model.
Fig. 3.
Receiver operating characteristic curves of the training set. DT: Decision Tree; KNN: K-Nearest Neighbors; LightGBM: Light Gradient Boosting Machine; RF: Random Forest; XGBoost: Extreme Gradient Boosting; SVM: Support Vector Machine; MLP: Multi-Layer Perceptron
Fig. 4.
Model performance validation (A) Receiver operating characteristic curves of the internal validation set; (B) Decision curve analysis curves of the internal validation set
Table 2.
The predictive performance of the models was compared in the internal validation set
| Model | Accuracy | Kappa | Sensitivity | Specificity | PPV | NPV | Brier | Deviance |
|---|---|---|---|---|---|---|---|---|
| Logistic | 0.719 | 0.338 | 0.693 | 0.726 | 0.415 | 0.894 | 0.138 | 0.861 |
| DT | 0.751 | 0.338 | 0.571 | 0.801 | 0.446 | 0.870 | 0.154 | 0.956 |
| Ridge | 0.697 | 0.315 | 0.716 | 0.692 | 0.394 | 0.897 | 0.146 | 0.910 |
| KNN | 0.667 | 0.259 | 0.675 | 0.665 | 0.361 | 0.880 | 0.151 | 1.011 |
| LightGBM | 0.682 | 0.279 | 0.678 | 0.683 | 0.374 | 0.883 | 0.157 | 0.968 |
| RF | 0.683 | 0.286 | 0.690 | 0.681 | 0.377 | 0.887 | 0.148 | 0.981 |
| XGBoost | 0.696 | 0.304 | 0.693 | 0.696 | 0.390 | 0.890 | 0.141 | 0.875 |
| SVM | 0.695 | 0.312 | 0.716 | 0.689 | 0.392 | 0.897 | 0.168 | 1.032 |
| MLP | 0.695 | 0.320 | 0.736 | 0.683 | 0.394 | 0.902 | 0.169 | 1.049 |
Fig. 5.
Calibration Curve in the internal validation set
Model interpretability
SHAP plots revealed that the top five factors in terms of feature importance were SOFA score, Charlson Comorbidity Index, age, RR and weight (Fig. 6). Among these, weight was negatively associated with in-hospital death, while SOFA score, Charlson Comorbidity Index, age and RR were positively associated with in-hospital death.
Fig. 6.
SHapley Additive exPlanations plot in internal validation set
External validation of the model
To further evaluate the generalization ability and clinical transferability of the final model, data from the eICU were used as the external validation dataset, maintaining the same feature variable system and preprocessing logic as in the training phase. As illustrated in Fig. 7A, the LR model achieved an AUC of 0.7621 (95% CI: 0.7275–0.7967). The SHAP results (Fig. 7B) of the external validation set were consistent with those of the internal validation set. The top five factors in terms of feature importance were SOFA score, Charlson Comorbidity Index, age, RR and weight. Among these, weight was negatively associated with in-hospital death, while SOFA score, Charlson Comorbidity Index, age and RR were positively associated with in-hospital death.
Fig. 7.
Receiver operating characteristic curves and SHapley Additive exPlanations plot of external validation (A) Receiver operating characteristic curves of the external validation set; (B) SHapley Additive exPlanations plot of the external validation set
Model comparison
We further compared the performance of the LR model with and without the inclusion of GV using the eICU database. As shown in Table 3, the AUC of the LR model without GV was 0.7623, with a ΔAUC of -0.0002; both NRI and IDI were not applicable (NA). The calibration curves and DCA curves of the two models were similar (Figs. 8 and 9). Consistent findings were also observed in the SHAP analysis (Fig. 10). Additionally, we also developed a prediction model using only the SOFA score, which yielded an AUC of 0.7041 (95% CI: 0.6669–0.7413) (Supplementary Fig. 2).
Table 3.
Performance Comparison of Logistic Regression Models with and without Glycemic Variability
| AUC with GV | AUC without GV | ΔAUC | NRI | IDI |
|---|---|---|---|---|
| 0.7621 | 0.7623 | -0.0002 | NA | NA |
Fig. 8.
Calibration Curve and DCA of the LR Model with GV Inclusion in the external validation (A) Calibration Curve; (B) Decision curve analysis curves
Fig. 9.
Calibration Curve and DCA of the LR Model without GV Inclusion in the external validation (A) Calibration Curve; (B) Decision curve analysis curves
Fig. 10.
SHAP Plot of the LR Model Without GV Inclusion
A simplified model
To facilitate better clinical application of the model, a simplified model was constructed by incorporating SOFA score, Charlson Comorbidity Index, age, RR and weight based on the external validation set, SHAP analysis results, and clinical practicality. As shown in Fig. 11, the AUC of the simplified model was 0.7592 (95%CI: 0.7250–0.7935).
Fig. 11.
A simplified model
Discussion
This study developed and validated prediction models for in-hospital death risk among patients with CAP using nine ML algorithms based on the MIMIC-IV and eICU databases. The main findings were as follows. First, among the nine ML models, the LR model achieved the best overall performance, with satisfactory discrimination (AUC = 0.7851 in the internal validation set and AUC = 0.7621 in the external validation set) and calibration. Second, SHAP analysis identified the SOFA score, Charlson Comorbidity Index, age, RR and weight as the top five key predictors of in-hospital death. Third, the core finding of this study was that the incorporation of GV into the LR model did not yield a clinically meaningful improvement in predictive performance, with a ΔAUC of merely − 0.0002. Additionally, NRI and IDI were not applicable. These results indicated that when conventional clinical variables, especially disease severity scores and comorbidities, were fully included in the model, GV may not provide independent incremental predictive value.
In our study, the RF model achieved an AUC as high as 0.9142 in the training set, while the LR model, which performed optimally in the internal validation set, had an AUC of 0.7851. Inconsistent performance between training and validation sets is a common yet critical phenomenon in ML model development [22], reflecting the inherent generalization ability of the model. Complex models may overfit on the training set, leading to decreased performance on independent validation sets. The LR model, due to its simple structure, ease of interpretation, and clinical deployability, often demonstrates robust performance in real-world applications. In this study, because only a small number of variables were included, the LR model was more suitable and exhibited higher robustness. This result emphasizes that in the development of clinical prediction models, we should not only pursue high discriminative ability but also pay attention to model stability, interpretability, and external validation.
SHAP analysis revealed that the top five factors in terms of feature importance were SOFA score, Charlson Comorbidity Index, age, RR and weight. Furthermore, weight was negatively associated with in-hospital death, while SOFA score, Charlson Comorbidity Index, age and RR were positively associated with in-hospital death. The SOFA score, a standardized assessment tool for organ failure, directly reflects the severity of organ damage in CAP patients. Higher SOFA scores indicate a wider range and greater severity of multiple organ dysfunction, correlating positively with death risk [23, 24]. The Charlson Comorbidity Index reflects the burden of patients’ chronic underlying diseases, and a higher CCI indicates greater disease severity and chronic comorbidity burden. A study conducted in the Thai population demonstrated that elevated CCI was associated with increased in-hospital mortality among non-elderly patients with pneumonia [25]. Elderly patients, characterized by declined immune function, multiple comorbidities, and poor compensatory capacity against infection, are prone to rapid progression to severe CAP following infection, thereby increasing death risk [26]. Increased RR directly reflects pneumonia severity and respiratory distress, and serves as a core component of conventional pneumonia severity scoring systems such as CURB-65. Body weight was negatively correlated with mortality risk. Low body weight is closely related to frailty or malnutrition [27], thereby elevating the risk of in-hospital death in patients with CAP. These factors provide clear targets for clinicians to identify high-risk CAP patients. For elderly patients with decreased weight, elevated SOFA score, elevated Charlson Comorbidity Index, and elevated RR should be implemented to improve prognosis.
The clinical translation value of a model is highly dependent on its reproducibility across different populations and data sources. We used an external dataset from the eICU database to validate the LR model, achieving an AUC of 0.7621. Although this result was slightly lower than that in the internal validation set, it still demonstrated good discriminative ability, confirming the model’s generalizability. More importantly, the SHAP analysis results on the external validation set were highly consistent with those from the internal validation set, with SOFA score, CCI, age, RR, and weight again being the five most important features. This stability in feature importance ranking enhances the reliability of the model’s biological mechanisms, indicating that these core risk factors have universal predictive value across different healthcare settings.
The incorporation of GV into the LR model did not yield a clinically meaningful improvement in predictive performance. Several potential reasons may explain why GV failed to deliver additional predictive value. First, the pathological effects of GV may be largely masked by disease severity reflected by the SOFA score, whose standalone AUC reached 0.7041. For critically ill patients with shock or requiring mechanical ventilation, systemic organ failure and inflammatory storms serve as the dominant causes of mortality, while the impact of glycemic fluctuations is relatively marginal. Second, glycemic variability calculated as the CV may not fully capture its complexity and clinical implications. For instance, the frequency and duration of hypoglycemic and hyperglycemic episodes, as well as the direction and rate of glycemic drift, can influence the association between GV and mortality, whereas a single index of average fluctuation lacks sufficient sensitivity.
We developed and validated a parsimonious model incorporating five core variables: SOFA score, Charlson Comorbidity Index, age, RR and weight. The model yielded an external validation AUC of 0.7592. All variables in this model are readily accessible and easy to calculate in clinical settings, without the need for sophisticated laboratory or imaging data, enabling clinicians to rapidly identify high-risk CAP patients at the bedside. Nevertheless, the key clinical implication of this study is that when the aforementioned core clinical variables are already available, allocating extra resources such as more frequent point-of-care blood glucose monitoring to calculate GV may contribute little to improving the prediction of death risk in CAP patients. Future studies should focus on exploring novel biomarkers or dynamic indicators that can provide incremental value independent of the existing clinical assessment framework.
However, this study has several limitations: (1) The inherent limitations of the retrospective study design prevent the complete elimination of the influence of unmeasured confounding factors. (2) Given that all data were extracted from US intensive care unit databases, the generalizability of our findings may be restricted by differences in healthcare systems, ethnic populations and disease spectra across regions. Future studies may conduct prospective research to validate the model’s predictive performance and clinical impact in clinical workflows.
Conclusion
In conclusion, although GV is pathophysiologically associated with poor outcomes in patients with CAP, it fails to yield independent incremental predictive value in models for predicting in-hospital death after conventional clinical variables such as the SOFA score were fully incorporated. This finding suggests that when developing prognostic models in the future, researchers should not blindly include all known risk factors, but instead carefully evaluate their actual additional information contribution to existing models. A parsimonious model consisting of the SOFA score, Charlson Comorbidity Index, age, RR and body weight can achieve efficient, convenient and reliable risk stratification for in-hospital mortality among CAP patients.
Supplementary Information
Supplementary Material 2. Supplementary Figure 1 Multiple imputation diagnostic plots (A) Convergence diagnosis; (B) Distribution before and after data imputation. Multiple imputation by chained equations (MICE) was adopted in this study to handle missing data. For candidate feature variables, a data-driven algorithm was first used to screen predictive factors, with the minimum correlation coefficient set to 0.15 and the minimum proportion of common observations set to 20%. Certain variables that required no processing were manually excluded to optimize the prediction matrix. Subsequently, the number of imputed datasets was set to (m = 5) and the maximum number of iterations to 20 to ensure algorithm convergence. Corresponding underlying algorithms were matched according to variable types, and a random seed (text{seed} = 123) was fixed to guarantee reproducible results. After imputation, the first complete imputed dataset was extracted as the derived dataset for subsequent model construction. (A) Trajectories of the mean (left column) and standard deviation (right column) of hemoglobin (upper panel) and GV (lower panel) over iterations during multiple imputation. The five lines with distinct colors represent five independent imputation chains. All chains exhibit stable fluctuations without apparent trends, suggesting that the imputation process has converged. (B) Kernel density distribution plots comparing observed and imputed data for GV (left) and hemoglobin (right). The solid blue line indicates the distribution curve of the original observed data, and the five red lines stand for the distribution curves generated from five independent imputations. The distribution patterns of imputed data are highly consistent with those of the original data, verifying that multiple imputation effectively preserves the distribution characteristics of the variables.
Supplementary Material 3. Supplementary Figure 2 The predictive performance of the Sequential Organ Failure Assessment (SOFA) model
Acknowledgements
We are appreciative of the MIMIC-IV and e-ICU participants and staff.
Abbreviations
- AUC
receiver operating characteristic curve
- BUN
blood urea nitrogen
- CAP
community-acquired pneumonia
- CI
confidence interval
- CV
coefficient of variation
- DCA
decision curve analysis
- DBP
diastolic blood pressure
- DT
Decision Tree
- GV
Glycemic variability
- Hb
hemoglobin
- ICU
intensive care unit
- KNN
K-Nearest Neighbors
- LR
Logistic Regression
- LightGBM
Light Gradient Boosting Machine
- MIMIC-IV
Medical Information Mart for Intensive Care IV
- MLP
Multi-Layer Perceptron
- ML
machine learning
- PTT
partial thromboplastin time
- RR
respiratory rate
- RR
Ridge Regression
- SHAP
SHapley Additive exPlanations
- SVM
Support Vector Machine
- SOFA
Sequential Organ Failure Assessment
- WBC
white blood cell
- XGBoost
eXtreme Gradient Boosting
Authors’ contributions
JZ contributed to writing the original draft, reviewing and editing the manuscript, data curation, methodology design, and fund acquisition; KC was involved in writing the original draft and performing formal analysis; YZ participated in reviewing and editing the manuscript, data curation, and visualization; YG contributed to reviewing and editing the manuscript, supervision, and software application; HG was responsible for reviewing and editing the manuscript, methodology design, and supervision; HS contributed to reviewing and editing the manuscript, methodology design, and project administration.All authors read and approved the final manuscript.
Funding
This work was supported by the Clinical Research Special Project of Shanghai Municipal Health Commission (grant number 20224Y0260).
Data availability
The datasets generated and/or analysed during the current study are available in the MIMIC (https://physionet.org/content/mimiciv/3.1/) and e-ICU (https://eicu-crd.mit.edu/) repositories.
Declarations
Ethics approval and consent to participate
This study complies with the ethical principles set forth in the Declaration of Helsinki. MIMIC database: The collection of patient information in the MIMIC-IV database has been reviewed and approved by the Institutional Review Board of Beth Israel Deaconess Medical Center, who granted a waiver of informed consent and approved the data sharing initiative. e-ICU database: The study is exempt from institutional review board approval due to the retrospective design, lack of direct patient intervention, and the security schema, for which the re-identification risk was certified as meeting safe harbor standards by an independent privacy expert (Privacert, Cambridge, MA) (Health Insurance Portability and Accountability Act Certification no. 1031219-2).
Consent for publication
Not applicable.
Competing interests
The authors declare no competing interests.
Footnotes
Publisher’s note
Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Jiaojiao Zhou and Kaiyu Cai contributed equally to this work.
Contributor Information
Yanchun Gong, Email: gyc10543@rjh.com.cn.
Haiyan Ge, Email: haiyan_ge@fudan.edu.cn.
Hua Sheng, Email: 13501728309@139.com.
References
- 1.Shen L, Wang L, Liu C, Shi S, Takahashi T, Wang T. Community-acquired pneumonia: Trends in and research on drug resistance and advances in new antibiotics. Biosci Trends. 2021;15(5):266–75. [DOI] [PubMed] [Google Scholar]
- 2.Vaughn VM, Dickson RP, Horowitz JK, Flanders SA. Community-Acquired Pneumonia: A Review. JAMA. 2024;332(15):1282–95. [DOI] [PubMed] [Google Scholar]
- 3.Vieira AFM, Amorim BM, de Moraes IS, Teodoro CNAA, de Aquino IP, Maciel ER, et al. Pneumonia adquirida na comunidade: aspectos etiopatogênicos, métodos diagnósticos e condutas terapêuticas. Brazilian J Health Rev. 2023;6(3):12836–48. [Google Scholar]
- 4.Oliveira ESPG, Cerqueira Batista Filho LA, Ismael PF, Victoria VES, Alexandre TM, Larissa SM. Community-acquired pneumonia: Epidemiology, diagnosis, prognostic severity scales, and new therapeutic options. Medwave. 2023;23(11):e2719. [DOI] [PubMed] [Google Scholar]
- 5.Mohan A, Bhargav KM. Predicting outcomes in patients with community-acquired pneumonia using weighted track & trigger early warning systems: Lessons learnt & insights for future use. Indian J Med Res. 2020;152(4):332–4. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 6.Nam K, Lee S. The indicators of glucose variability. J Anesth. 2021;35(4):600–1. [DOI] [PubMed] [Google Scholar]
- 7.Tang S, Zhang Z, Cheng Y, Zhang L, Wang Q, Wang C. Glycemic variability and mortality in patients with aortic diseases: A multicenter retrospective cohort study. PLoS ONE. 2025;20(6):e0325006. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 8.Guo Y, Qiu Y, Xue T, Zhou Y, Yan P, Liu S, et al. Association between glycemic variability and short-term mortality in patients with acute kidney injury: a retrospective cohort study of the MIMIC-IV database. Sci Rep. 2024;14(1):5945. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 9.Hou H, Guo Z, Wang X, Han L, Wang H, Chen B. Association of Glycemic Variability with Mortality among Septic Patients with Coronary Artery Disease: A Multicenter Cohort Study. J Intensive Care Med. 2025;41(7):591–9. [DOI] [PubMed]
- 10.Chen J, Huang W, Liang N. Blood glucose fluctuation and in-hospital mortality among patients with acute myocardial infarction: eICU collaborative research database. PLoS ONE. 2024;19(4):e0300323. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 11.Yang H, Wang H, Jiang Y. Exploring the impact of glycemic variability on clinical outcomes in critically ill cerebral infarction patients. Diabetol Metab Syndr. 2025;17(1):100. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 12.Sun S, Sun Z, Huang Q, Sun J. High glucose fluctuation levels modulate monocyte cytokine expression via oxidative stress mechanism. Sci Rep. 2026;16(1):11714. [DOI] [PMC free article] [PubMed]
- 13.Chasmar MS. Relationship between abnormal maternal inflammation and insulin resistance during pregnancy 2015.
- 14.Böni-Schnetzler M, Donath MY. Increased IL-1β activation, the culprit not only for defective insulin secretion but also for insulin resistance? Cell Res. 2011;21(7):995–7. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 15.Raia L, Zafrani L. Endothelial Activation and Microcirculatory Disorders in Sepsis. Front Med. 2022;9:907992. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 16.Xu Z, Guo K, Chu W, Lou J, Chen C. Performance of Machine Learning Algorithms for Predicting Adverse Outcomes in Community-Acquired Pneumonia. Front Bioeng Biotechnol. 2022;10:903426. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 17.Cilloniz C, Ward L, Mogensen ML, Pericàs JM, Méndez R, Gabarrús A, et al. Machine-Learning Model for Mortality Prediction in Patients With Community-Acquired Pneumonia: Development and Validation Study. Chest. 2023;163(1):77–88. [DOI] [PubMed] [Google Scholar]
- 18.Xu C, Liu H, Zhang H, Zeng J, Li Q, Yi Y, et al. Predictive value of arterial blood lactate to serum albumin ratio for in-hospital mortality of patients with community-acquired pneumonia admitted to the Intensive Care Unit. Postgrad Med. 2023;135(3):273–82. [DOI] [PubMed] [Google Scholar]
- 19.Liu Y, Fu H, Wang Y, Sun J, Zhang R, Zhong Y, et al. U-shaped association between the glycemic variability and prognosis in hemorrhagic stroke patients: a retrospective cohort study from the MIMIC-IV database. Front Endocrinol. 2025;16:1546164. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 20.Zhang N, Chen M, Yang F, Yang C, Yang P, Gao Y, et al. Forest Height Mapping Using Feature Selection and Machine Learning by Integrating Multi-Source Satellite Data in Baoding City, North China. Remote Sens. 2022;14(18):4434. [Google Scholar]
- 21.Huang Z, Gong D, Tang C, Wang J, Zhang C, Dang K, et al. A risk prediction model for neovascular glaucoma secondary to proliferative diabetic retinopathy based on Boruta feature selection and random forest. Front Cell Dev Biol. 2025;13:1604832. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 22.Du G, Lv H, Liang Y, Zhang J, Huang Q, Xie G, et al. Population-based colorectal cancer risk prediction using a SHAP-enhanced LightGBM model. Front Oncol. 2025;15:1575844. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 23.Hancı P, Temel E, Bilir F, Kaya BS. Lactate to albumin ratio as a determinant of intensive care unit admission and mortality in hospitalized patients with community-acquired pneumonia. BMC Pulm Med. 2025;25(1):224. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 24.Asai N, Watanabe H, Shiota A, Kato H, Sakanashi D, Hagihara M, et al. Efficacy and accuracy of qSOFA and SOFA scores as prognostic tools for community-acquired and healthcare-associated pneumonia. Int J Infect Dis. 2019;84:89–96. [DOI] [PubMed] [Google Scholar]
- 25.Chongthanadon B, Thirawattanasoot N, Ruangsomboon O. Clinical factors associated with in-hospital mortality in elderly versus non-elderly pneumonia patients in the emergency department. BMC Pulm Med. 2023;23(1):330. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 26.Li S, Li L, Wang S, Wu H. Clinical characteristics and risk factors of hospital mortality in elderly patients with community-acquired pneumonia. Front Med. 2025;12:1512288. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 27.Okada A, Yamaguchi S, Jo T, Yokota I, Ono S, Ikeda Kurakawa K, et al. Impact of body mass index on in-hospital mortality in older patients hospitalized for bacterial pneumonia with non-dialysis-dependent chronic kidney disease. BMC Geriatr. 2022;22(1):950. [DOI] [PMC free article] [PubMed] [Google Scholar]
Associated Data
This section collects any data citations, data availability statements, or supplementary materials included in this article.
Supplementary Materials
Supplementary Material 2. Supplementary Figure 1 Multiple imputation diagnostic plots (A) Convergence diagnosis; (B) Distribution before and after data imputation. Multiple imputation by chained equations (MICE) was adopted in this study to handle missing data. For candidate feature variables, a data-driven algorithm was first used to screen predictive factors, with the minimum correlation coefficient set to 0.15 and the minimum proportion of common observations set to 20%. Certain variables that required no processing were manually excluded to optimize the prediction matrix. Subsequently, the number of imputed datasets was set to (m = 5) and the maximum number of iterations to 20 to ensure algorithm convergence. Corresponding underlying algorithms were matched according to variable types, and a random seed (text{seed} = 123) was fixed to guarantee reproducible results. After imputation, the first complete imputed dataset was extracted as the derived dataset for subsequent model construction. (A) Trajectories of the mean (left column) and standard deviation (right column) of hemoglobin (upper panel) and GV (lower panel) over iterations during multiple imputation. The five lines with distinct colors represent five independent imputation chains. All chains exhibit stable fluctuations without apparent trends, suggesting that the imputation process has converged. (B) Kernel density distribution plots comparing observed and imputed data for GV (left) and hemoglobin (right). The solid blue line indicates the distribution curve of the original observed data, and the five red lines stand for the distribution curves generated from five independent imputations. The distribution patterns of imputed data are highly consistent with those of the original data, verifying that multiple imputation effectively preserves the distribution characteristics of the variables.
Supplementary Material 3. Supplementary Figure 2 The predictive performance of the Sequential Organ Failure Assessment (SOFA) model
Data Availability Statement
The datasets generated and/or analysed during the current study are available in the MIMIC (https://physionet.org/content/mimiciv/3.1/) and e-ICU (https://eicu-crd.mit.edu/) repositories.











