Skip to main content
Metabolism Open logoLink to Metabolism Open
. 2026 Apr 17;30:100467. doi: 10.1016/j.metop.2026.100467

Association of the Dietary Index for Gut Microbiota with site-specific Osteoporosis: Insights from machine learning applied to a national population

Lishen Zhou 1, Junshen Liu 1, Hong Xu 1, Guanrong Sun 1, Yuliang Lou 1, Jianyue Wang 1,⁎
PMCID: PMC13122201  PMID: 42058580

Abstract

Background

The association between the Dietary Index for Gut Microbiota (DI-GM) and site-specific osteoporosis risk remains unclear.

Methods

This study analyzed data from five NHANES cycles (2005–2010, 2013–2014, 2017–2018). Multivariate logistic regression and subgroup analyses were conducted to evaluate the relationship between DI-GM and osteoporosis at specific skeletal sites. Restricted cubic spline (RCS) and threshold effect analyses were used to explore nonlinear associations. Six machine learning models were developed, with SHAP and LIME algorithms applied to enhance interpretability.

Results

After adjusting for potential confounders, higher DI-GM scores were significantly associated with a lower risk of osteoporosis at the total femur (adjusted OR = 0.89; 95% CI: 0.80–0.98; p = 0.022). RCS analysis revealed a nonlinear relationship at the femoral neck (p for nonlinearity = 0.028; p for overall trend = 0.005), with a threshold at DI-GM = 3. Below this threshold, DI-GM was positively associated with osteoporosis risk (adjusted OR = 1.455; 95% CI: 1.002–2.221; p = 0.064), while above it, the association was inverse (adjusted OR = 0.904; 95% CI: 0.847–0.963; p = 0.002). Among all models, the random forest algorithm exhibited the best predictive performance for total femur osteoporosis. SHAP analysis identified whole grains (0.0117), coffee (0.0084), red meat (0.0079), and soybeans (0.0051) as the most influential dietary components, all inversely associated with osteoporosis risk.

Conclusion

Higher DI-GM scores are associated with reduced osteoporosis risk, particularly at the total femur. The random forest model showed the highest predictive accuracy, and SHAP analysis highlighted whole grains and coffee as key protective contributors.

Keywords: Bone health, Diet quality, Gut microbiota, Machine learning, Osteoporosis

Highlights

  • •

    DI-GM linked to lower osteoporosis risk at total femur in large NHANES cohort.

  • •

    Nonlinear threshold effect of DI-GM on femoral neck osteoporosis identified.

  • •

    Random Forest model excellently predicts osteoporosis using dietary components.

  • •

    Whole grains, coffee, red meat, soybeans are key protective dietary factors.

  • •

    Combines Boruta feature selection with SHAP for interpretable machine learning.

1. Introduction

Osteoporosis is a systemic skeletal disorder characterized by decreased bone mineral density (BMD) and deterioration of bone microarchitecture leading to an increased susceptibility to fractures [1]. It represents a major public health challenge due to its high prevalence, associated disability, and rising healthcare costs, particularly in aging populations [2]. Globally, millions are affected, with incidence expected to grow as populations age [3]. In the United States, approximately 10 million adults aged ≥50 have osteoporosis, a number projected to surpass 14 million by 2025 [4]. Common bone fractures occur at the hip, spine and wrist, causing significant morbidity and direct healthcare costs of $17.9 billion per year in the United States and £4 billion per year in the United Kingdom [5].

Osteoporosis has a complex etiology with many contributing factors, including genetic, hormonal and environmental [6]. Although calcium and vitamin D have been the traditionally preferred focus of attention, emerging evidence suggests that the gut microbiota is also important to bone metabolism [7,8]. Gut microflora comprising hundreds of thousands of diverse microorganisms potentiate the uptake of nutrients, immune response and modification of metabolites that could potentially affect skeletal health [9]. Microbial dysbiosis has been implicated in various chronic diseases, including metabolic syndrome and osteoporosis [10].

To assess the dietary influence on gut microbiota and its health consequences, the Dietary Index for Gut Microbiota (DI-GM) was developed [11]. This index scores diet based on its effects on microbial diversity and composition; it includes foods beneficial for gut health (whole grains, fermented dairy, dietary fiber, legumes, soy, and green tea) and deducts value for foods that disrupt the microbial ecosystem (like red/processed meat, refined grains, and high-fat diets) [11]. Higher DI-GM scores have been associated with improved cardiometabolic outcomes, potentially due to the anti-inflammatory and antioxidant properties of microbiota-supportive foods [12,13]. For example, fermented foods and fiber promote the production of short-chain fatty acids (SCFAs), which enhance calcium absorption and reduce systemic inflammation [14]. Although the idea of a gut–bone axis is gaining momentum, correlates linking DI-GM with skeletal parameters are lacking. Proposed mechanisms include SCFA driven nutrient uptake, immune regulation and putative hormonal impacts via estrogen and parathyroid hormone regulation of DI-GM [[15], [16], [17], [18]]. However, there are very few data on the association between microbiota-supportive dietary patterns and the risk of osteoporosis.

This study aims to address this knowledge gap by examining the association between DI-GM and site-specific osteoporosis risk using nationally representative NHANES data. Specifically, we investigated whether adherence to a microbiota-supportive diet, as quantified by DI-GM, is associated with a reduced risk of osteoporosis across different skeletal sites.

2. Methods

2.1. Study population

Data were derived from the NHANES cycles 2005–2010, 2013–2014, and 2017–2018, encompassing a total of 50,463 participants. After applying exclusion criteria, 38,018 individuals were excluded due to missing BMD data (n = 25,494), inability to calculate DI-GM (n = 6797), age under 20 years (n = 3597), or missing demographic/clinical information (n = 2130). The final analytical sample consisted of 12,445 participants (Fig. 1).

Fig. 1.

Fig. 1

Flowchart of participant inclusion and study design.

2.2. Assessment of the gut microbiota dietary index (DI-GM)

Dietary intake information, including trace elements, vitamins, and carbohydrates, was collected through two non-consecutive 24-h dietary recalls. The first recall was conducted in person at the Mobile Examination Center (MEC), while the second was completed by telephone several days later. Both recalls employed the Automated Multiple-Pass Method (AMPM) and were administered by trained interviewers. The DI-GM included 14 dietary components categorized as either beneficial (e.g., fermented dairy, legumes, whole grains, dietary fiber, berries, avocado, broccoli, coffee, green tea) or detrimental (e.g., red and processed meat, refined grains, high-fat diets [≥40% energy from fat]). For each beneficial component, a score of 1 was assigned if intake met or exceeded the sex-specific median; otherwise, a score of 0 was assigned. Scoring was reversed for detrimental components. Total DI-GM scores ranged from 0 to 14, with higher scores indicating a diet more favorable to gut microbiota.

2.3. Osteoporosis assessment

Osteoporosis was defined based on the World Health Organization (WHO) criteria: BMD ≥2.5 standard deviations below the young adult mean for the same sex and ethnicity. BMD was measured at five anatomical sites: total femur, femoral neck, trochanter, intertrochanter, and Ward's triangle. A diagnosis of osteoporosis was made if any of these sites met the threshold.

2.4. Covariates

The analysis adjusted for a comprehensive set of covariates, including age, sex, race/ethnicity, education level, family income-to-poverty ratio, BMI, smoking status, alcohol consumption, hypertension, and diabetes. Hypertension was defined by self-report or current use of antihypertensive medication. Diabetes was defined by self-report, fasting plasma glucose ≥7.0 mmol/L, or a 2-h oral glucose tolerance test (OGTT) ≥11.1 mmol/L. Prediabetes was defined as fasting glucose of 6.1–6.9 mmol/L or 2-h OGTT of 7.8–11.1 mmol/L. Smoking status was categorized as never smokers, former smokers (quit >1 year), and current smokers. Alcohol consumption was categorized as non-drinkers (<12 lifetime drinks) and current drinkers. BMI was calculated as weight (kg) divided by height squared (m2).

2.5. Feature processing and machine learning feature selection

A total of 25 features (17 continuous and 8 categorical) representing DI-GM components were included. The prevalence of osteoporosis at the total femur was 2.24%, yielding a severe class imbalance ratio of approximately 1:44. To address this, the Synthetic Minority Over-sampling Technique (SMOTE) was applied using k-nearest neighbors exclusively within each training fold of the 10-fold cross-validation (after data splitting and prior to feature selection and standardization) to generate synthetic minority-class samples without introducing data leakage. All features were standardized prior to model development. Feature selection was performed using the Boruta algorithm, which identifies relevant features by comparing them against randomized shadow features. After 500 iterations, only features labeled as “confirmed" were retained for inclusion in the final model.

2.6. Statistical analyses

All analyses followed NHANES analytical guidelines, incorporating sampling weights to ensure national representativeness—each participant represented approximately 8544 individuals in the U.S. population. Continuous variables were expressed as means ± standard deviations, while categorical variables were reported as weighted percentages and counts. Between-group comparisons were conducted using chi-square tests for categorical variables and Student's t-tests for continuous variables. The association between DI-GM and osteoporosis was assessed using logistic regression models with progressive adjustment for demographic, lifestyle, and cardiovascular risk factors. Restricted cubic spline (RCS) and threshold effect analyses were employed to assess nonlinear associations and identify potential inflection points. Subgroup and interaction analyses were also performed to explore effect modification. All statistical analyses were conducted using IBM SPSS Statistics (v24.0) and R (v4.3.0), with a two-sided p-value <0.05 considered statistically significant.

2.7. Machine learning modeling

Six machine learning algorithms were implemented using the MLR3 framework: Random Forest, LightGBM, k-Nearest Neighbors (K-NN), Naive Bayes, Support Vector Machine (SVM), and XGBoost. Model performance was evaluated using six metrics: Accuracy, F-beta, Area Under the Receiver Operating Characteristic Curve (AUC-ROC), Sensitivity, Specificity, and Area Under the Precision-Recall Curve (AUC-PR). AUC-ROC was designated as the primary metric for performance evaluation. Model robustness was ensured through ten-fold cross-validation. Differences in model performance were statistically compared using ANOVA and Kruskal–Wallis tests.

Model interpretability was enhanced using SHAP (SHapley Additive exPlanations) and LIME (Local Interpretable Model-Agnostic Explanations). SHAP values quantified the contribution of each feature to model predictions based on cooperative game theory, while LIME provided local, interpretable approximations of complex model behavior.

To further evaluate generalizability and rule out overfitting or data leakage, temporal validation was conducted by training all models on data from NHANES cycles 2005–2010 and 2013–2014 and testing on the independent 2017–2018 cycle.

3. Results

3.1. Participant characteristics across DI-GM quartiles

Table 1 summarizes the baseline characteristics of 12,445 NHANES participants from the 2005–2010, 2013–2014, and 2017–2018 cycles. After applying survey weights, the sample represents approximately 106 million U.S. adults. The mean age was 51.48 years (SD = 15.92), and the cohort included 6046 (50.77%) women and 6399 (49.23%) men. A higher DI-GM score was associated with a lower prevalence of osteoporosis across the total femur, femoral neck, and trochanter regions.

Table 1.

Baseline characteristics of study participants.

Characteristic N Overall
N = 106,333,252
Q1
N = 36,167,495
Q2
N = 23,638,860
Q3
N = 21,409,215
Q4
N = 25,117,683
p-value
Sexb, n (%) 12,445 <0.001
 FeMale 6046 (50.77%) 2119 (45.86%) 1392 (51.91%) 1176 (52.60%) 1359 (55.19%)
 Male 6399 (49.23%) 2650 (54.14%) 1431 (48.09%) 1151 (47.40%) 1167 (44.81%)
Age (year)a, Mean ± SD 12,445 51.48 ± 15.92 50.09 ± 16.38 51.43 ± 15.95 51.51 ± 15.93 53.50 ± 14.99 <0.001
Race/ethnicityb, n (%) 12,445 <0.001
 Mexican 1891 (7.06%) 802 (8.41%) 480 (8.25%) 328 (6.30%) 281 (4.65%)
 Other Hispanic 1210 (4.84%) 490 (6.00%) 267 (4.47%) 209 (3.95%) 244 (4.25%)
 Non-Hispanic White 6041 (71.97%) 2079 (66.25%) 1325 (71.00%) 1215 (74.98%) 1422 (78.57%)
 Non-Hispanic Black 2375 (9.88%) 1115 (13.72%) 540 (9.84%) 403 (8.58%) 317 (5.51%)
 Other Race 928 (6.25%) 283 (5.62%) 211 (6.44%) 172 (6.19%) 262 (7.02%)
Educationb, n (%) 12,445 <0.001
 Less Than 9th 1233 (4.67%) 578 (6.09%) 288 (4.82%) 210 (4.28%) 157 (2.82%)
 9-11th 1811 (10.70%) 852 (13.89%) 414 (10.76%) 312 (9.60%) 233 (6.99%)
 High School 2958 (24.08%) 1301 (29.43%) 661 (25.18%) 518 (22.32%) 478 (16.81%)
 Some College 3581 (30.68%) 1301 (30.78%) 833 (31.01%) 709 (32.19%) 738 (28.94%)
 College Graduate 2862 (29.87%) 737 (19.80%) 627 (28.23%) 578 (31.61%) 920 (44.44%)
Family income to poverty ratioa, Mean ± SD 12,445 3.16 ± 1.64 2.84 ± 1.65 3.15 ± 1.64 3.27 ± 1.64 3.54 ± 1.55 <0.001
BMIa, Mean ± SD 12,445 28.42 ± 5.83 28.84 ± 5.91 28.61 ± 5.91 28.21 ± 5.69 27.82 ± 5.71 <0.001
Diabetesb, n (%) 12,445 0.044
 No 9159 (79.31%) 3421 (77.79%) 2077 (79.06%) 1747 (80.00%) 1914 (81.15%)
 Yes 1913 (11.41%) 807 (12.94%) 430 (11.65%) 332 (9.90%) 344 (10.29%)
 Borderline 1373 (9.28%) 541 (9.28%) 316 (9.29%) 248 (10.10%) 268 (8.56%)
Hypertensionb, n (%) 12,445 0.064
 No 7640 (65.94%) 2901 (64.00%) 1722 (65.21%) 1445 (66.67%) 1572 (68.79%)
 Yes 4805 (34.06%) 1868 (36.00%) 1101 (34.79%) 882 (33.33%) 954 (31.21%)
Smoking statusb, n (%) 12,445 <0.001
 No 9866 (80.44%) 3571 (76.15%) 2214 (79.96%) 1916 (81.51%) 2165 (86.17%)
 Yes 2579 (19.56%) 1198 (23.85%) 609 (20.04%) 411 (18.49%) 361 (13.83%)
Drinking statusb, n (%) 12,445 0.050
 No 1559 (9.78%) 591 (10.13%) 385 (11.42%) 293 (9.18%) 290 (8.23%)
 Yes 10,886 (90.22%) 4178 (89.87%) 2438 (88.58%) 2034 (90.82%) 2236 (91.77%)
Cardiovascular diseaseb, n (%) 12,445 0.110
 No 10,945 (90.22%) 4129 (89.04%) 2508 (91.09%) 2076 (90.54%) 2232 (90.82%)
 Yes 1500 (9.78%) 640 (10.96%) 315 (8.91%) 251 (9.46%) 294 (9.18%)
Total femurb, n (%) 12,445 0.299
 No 12,120 (97.76%) 4642 (97.80%) 2742 (97.23%) 2272 (97.74%) 2464 (98.22%)
 Yes 325 (2.24%) 127 (2.20%) 81 (2.77%) 55 (2.26%) 62 (1.78%)
Femoral neckb, n (%) 12,445 0.892
 No 11,898 (95.98%) 4563 (96.18%) 2699 (95.74%) 2225 (95.79%) 2411 (96.10%)
 Yes 547 (4.02%) 206 (3.82%) 124 (4.26%) 102 (4.21%) 115 (3.90%)
Trochanterb, n (%) 12,445 0.921
 No 12,292 (99.03%) 4707 (98.96%) 2788 (99.13%) 2302 (98.97%) 2495 (99.10%)
 Yes 153 (0.97%) 62 (1.04%) 35 (0.87%) 25 (1.03%) 31 (0.90%)
Intertrochanterb, n (%) 12,445 0.779
 No 12,097 (97.58%) 4640 (97.85%) 2742 (97.44%) 2265 (97.49%) 2450 (97.41%)
 Yes 348 (2.42%) 129 (2.15%) 81 (2.56%) 62 (2.51%) 76 (2.59%)
Ward triangleb, n (%) 12,445 0.219
 No 10,523 (86.11%) 4061 (86.42%) 2392 (86.67%) 1965 (87.03%) 2105 (84.35%)
 Yes 1922 (13.89%) 708 (13.58%) 431 (13.33%) 362 (12.97%) 421 (15.65%)
Avocadoa, Mean ± SD 12,445 9.59 ± 49.81 3.33 ± 23.57 6.28 ± 36.72 13.68 ± 62.98 18.23 ± 70.02 <0.001
Broccolia, Mean ± SD 12,445 66.22 ± 165.83 29.17 ± 105.27 51.01 ± 144.74 77.17 ± 191.40 124.53 ± 209.43 <0.001
Chickpeaa, Mean ± SD 12,445 4.01 ± 35.00 0.60 ± 7.43 1.87 ± 26.86 3.39 ± 26.47 11.47 ± 61.27 <0.001
Coffeea, Mean ± SD 12,445 436.84 ± 663.65 335.09 ± 710.89 409.26 ± 549.01 469.80 ± 694.33 581.22 ± 636.66 <0.001
Cranberrya, Mean ± SD 12,445 46.95 ± 156.14 28.76 ± 128.78 46.76 ± 156.97 57.22 ± 171.48 64.54 ± 173.89 <0.001
Fermented dairya, Mean ± SD 12,445 337.75 ± 315.44 263.18 ± 286.24 331.16 ± 325.52 380.63 ± 333.08 414.78 ± 305.81 <0.001
Fibera, Mean ± SD 12,445 16.79 ± 10.01 13.02 ± 8.22 15.95 ± 9.37 18.06 ± 9.95 21.92 ± 10.55 <0.001
Green teaa, Mean ± SD 12,445 269.57 ± 576.62 158.80 ± 428.54 252.04 ± 556.88 297.85 ± 605.88 421.49 ± 705.02 <0.001
soybeana, Mean ± SD 12,445 92.94 ± 171.00 38.54 ± 102.17 67.48 ± 137.71 102.84 ± 173.22 186.77 ± 227.18 <0.001
Whole gransa, Mean ± SD 12,445 1.74 ± 2.22 0.84 ± 1.49 1.42 ± 1.90 2.05 ± 2.18 3.09 ± 2.65 <0.001
Fata, Mean ± SD 12,445 81.92 ± 45.30 85.96 ± 47.95 79.83 ± 45.99 80.15 ± 43.18 79.57 ± 41.99 0.002
Refined grainsa, Mean ± SD 12,445 10.64 ± 6.50 11.22 ± 6.49 10.87 ± 6.83 10.51 ± 6.60 9.69 ± 5.99 <0.001
Processed meata, Mean ± SD 12,445 1.02 ± 1.88 1.71 ± 2.33 0.90 ± 1.75 0.69 ± 1.40 0.44 ± 1.16 <0.001
Red meata, Mean ± SD 12,445 2.40 ± 3.02 3.58 ± 3.38 2.38 ± 2.94 1.83 ± 2.74 1.22 ± 2.01 <0.001
a

One-way ANOVA.

b

Chi-square test, SD: standard deviation.

3.2. Association between DI-GM and site-specific osteoporosis risk

Table 2 displays the associations between DI-GM and osteoporosis risk at specific skeletal sites. In unadjusted models, DI-GM was inversely associated with osteoporosis at the total femur (OR = 0.96, 95% CI: 0.89–1.05, p = 0.386) and trochanter (OR = 0.95, 95% CI: 0.86–1.05, p = 0.304). Weak, non-significant positive associations were observed at the femoral neck (OR = 1.03, p = 0.401), intertrochanter (OR = 1.06, p = 0.327), and Ward's triangle (OR = 1.04, p = 0.083). After adjusting for demographic, socioeconomic, and clinical variables, a statistically significant inverse association remained between DI-GM and total femur osteoporosis (adjusted OR = 0.89, 95% CI: 0.80–0.98, p = 0.022). Each one-unit increase in DI-GM was associated with an 11% reduction in total femur osteoporosis risk. Associations at other skeletal sites remained non-significant.

Table 2.

Associations between DI-GM and osteoporosis across skeletal sites.

Exposure Variable Model 1
Model 2
Model 3
Model 4
OR (95% CI) P-value OR (95% CI) P-value OR (95% CI) P-value OR (95% CI) P-value
Total femur
DI-GM 0.96 (0.89 ∼ 1.05) 0.386 0.92 (0.84 ∼ 1.00) 0.060 0.89 (0.80 ∼ 0.98) 0.020∗ 0.89 (0.80 ∼ 0.98) 0.022∗
DI-GM group
 Q1 1.00 (Reference) - 1.00 (Reference) - 1.00 (Reference) - 1.00 (Reference) -
 Q2 0.97 (0.61 ∼ 1.55) 0.904 0.95 (0.62 ∼ 1.46) 0.810 0.82 (0.50 ∼ 1.33) 0.406 0.87 (0.52 ∼ 1.46) 0.593
 Q3 1.25 (0.84 ∼ 1.87) 0.269 1.18 (0.75 ∼ 1.85) 0.471 1.07 (0.64 ∼ 1.79) 0.807 1.08 (0.65 ∼ 1.78) 0.765
 Q4 0.89 (0.59 ∼ 1.35) 0.589 0.77 (0.49 ∼ 1.20) 0.244 0.65 (0.39 ∼ 1.08) 0.095 0.63 (0.38 ∼ 1.07) 0.084
P for trend 0.94 (0.82 ∼ 1.07) 0.319 0.88 (0.76 ∼ 1.02) 0.079 0.84 (0.72 ∼ 0.99) 0.035∗ 0.84 (0.72 ∼ 0.99) 0.036∗
Femoral neck
 DI-GM 1.03 (0.96 ∼ 1.11) 0.401 0.98 (0.90 ∼ 1.06) 0.614 0.96 (0.87 ∼ 1.06) 0.370 0.95 (0.87 ∼ 1.05) 0.323
DI-GM group
 Q1 1.00 (Reference) - 1.00 (Reference) - 1.00 (Reference) - 1.00 (Reference) -
 Q2 1.28 (0.80 ∼ 2.05) 0.294 1.30 (0.84 ∼ 2.02) 0.230 1.22 (0.78 ∼ 1.91) 0.382 1.21 (0.77 ∼ 1.90) 0.407
 Q3 1.29 (0.93 ∼ 1.81) 0.128 1.22 (0.83 ∼ 1.78) 0.298 1.15 (0.79 ∼ 1.68) 0.454 1.15 (0.79 ∼ 1.68) 0.448
 Q4 1.22 (0.84 ∼ 1.78) 0.287 1.06 (0.71 ∼ 1.57) 0.781 0.94 (0.63 ∼ 1.41) 0.771 0.94 (0.63 ∼ 1.40) 0.739
P for trend 1.01 (0.91 ∼ 1.12) 0.864 0.94 (0.83 ∼ 1.07) 0.330 0.91 (0.79 ∼ 1.05) 0.192 0.91 (0.79 ∼ 1.05) 0.182
Intertrochanter
 DI-GM 1.06 (0.94 ∼ 1.19) 0.327 1.01 (0.89 ∼ 1.14) 0.886 0.99 (0.85 ∼ 1.14) 0.837 0.99 (0.86 ∼ 1.14) 0.844
DI-GM group
 Q1 1.00 (Reference) - 1.00 (Reference) - 1.00 (Reference) - 1.00 (Reference) -
 Q2 0.87 (0.51 ∼ 1.47) 0.592 0.84 (0.51 ∼ 1.38) 0.483 0.74 (0.43 ∼ 1.25) 0.253 0.73 (0.43 ∼ 1.23) 0.231
 Q3 1.11 (0.72 ∼ 1.70) 0.626 1.02 (0.64 ∼ 1.63) 0.926 0.92 (0.56 ∼ 1.51) 0.745 0.93 (0.57 ∼ 1.52) 0.757
 Q4 1.11 (0.71 ∼ 1.74) 0.650 0.95 (0.59 ∼ 1.53) 0.825 0.82 (0.47 ∼ 1.40) 0.450 0.81 (0.47 ∼ 1.39) 0.432
P for trend 1.06 (0.92 ∼ 1.23) 0.411 1.00 (0.86 ∼ 1.17) 0.999 0.97 (0.82 ∼ 1.15) 0.724 0.97 (0.81 ∼ 1.15) 0.717
Trochanter
 DI-GM 0.95 (0.86 ∼ 1.05) 0.304 0.93 (0.84 ∼ 1.03) 0.138 0.90 (0.80 ∼ 1.01) 0.065 0.90 (0.80 ∼ 1.01) 0.076
DI-GM group
 Q1 1.00 (Reference) - 1.00 (Reference) - 1.00 (Reference) - 1.00 (Reference) -
 Q2 0.83 (0.37 ∼ 1.84) 0.639 0.83 (0.37 ∼ 1.84) 0.635 0.73 (0.32 ∼ 1.67) 0.452 0.73 (0.32 ∼ 1.66) 0.441
 Q3 0.75 (0.38 ∼ 1.46) 0.391 0.72 (0.34 ∼ 1.51) 0.375 0.64 (0.29 ∼ 1.39) 0.253 0.63 (0.29 ∼ 1.39) 0.246
 Q4 0.83 (0.49 ∼ 1.41) 0.490 0.79 (0.45 ∼ 1.37) 0.389 0.67 (0.38 ∼ 1.21) 0.179 0.67 (0.37 ∼ 1.20) 0.173
P for trend 0.97 (0.80 ∼ 1.17) 0.726 0.95 (0.78 ∼ 1.15) 0.565 0.91 (0.74 ∼ 1.11) 0.356 0.91 (0.74 ∼ 1.12) 0.358
Ward triangle
 DI-GM 1.04 (0.99 ∼ 1.09) 0.083 1.00 (0.95 ∼ 1.06) 0.891 0.99 (0.93 ∼ 1.05) 0.694 0.98 (0.93 ∼ 1.04) 0.490
DI-GM group
 Q1 1.00 (Reference) - 1.00 (Reference) - 1.00 (Reference) - 1.00 (Reference) -
 Q2 1.08 (0.82 ∼ 1.41) 0.596 1.13 (0.83 ∼ 1.54) 0.429 1.08 (0.79 ∼ 1.48) 0.621 1.07 (0.78 ∼ 1.47) 0.680
 Q3 1.02 (0.82 ∼ 1.27) 0.854 1.01 (0.77 ∼ 1.34) 0.937 0.97 (0.73 ∼ 1.29) 0.828 0.97 (0.73 ∼ 1.30) 0.852
 Q4 1.12 (0.90 ∼ 1.39) 0.313 1.02 (0.80 ∼ 1.31) 0.840 0.95 (0.74 ∼ 1.22) 0.685 0.94 (0.73 ∼ 1.22) 0.652
P for trend 1.05 (0.98 ∼ 1.12) 0.198 0.99 (0.92 ∼ 1.08) 0.882 0.98 (0.90 ∼ 1.06) 0.553 0.98 (0.90 ∼ 1.06) 0.555

Model 1: Crude.

Model 2: Adjust: Age, Sex, Race/ethnicity, Education, Family income to poverty ratio.

Model 3: Adjust: Age, Sex, Race/ethnicity, Education, Family income to poverty ratio, BMI, Hypertension, Diabetes, Drinking status, Smoking status.

Model 4: Adjust: Age, Sex, Race/ethnicity, Education, Family income to poverty ratio, BMI, Hypertension, Diabetes, Drinking status, Smoking status, Cardiovascular disease.

Significance: ∗p < 0.05, ∗∗p < 0.01, ∗∗∗p < 0.001.

3.3. Linear and nonlinear relationships between DI-GM and osteoporosis risk

RCS analysis was used to explore potential dose–response relationships. In unadjusted models, a linear relationship was observed between DI-GM and osteoporosis risk across all sites (nonlinearity p-values >0.05) (Fig. 2). After adjusting for confounders, a nonlinear association emerged at the femoral neck (p for nonlinearity = 0.028; p for overall trend = 0.005), while other sites retained linear patterns (Fig. 3). A threshold effect was identified at a DI-GM value of 3. Below this threshold, osteoporosis risk increased (adjusted OR = 1.455, 95% CI: 1.002–2.221, p = 0.064); above it, risk decreased (adjusted OR = 0.904, 95% CI: 0.847–0.963, p = 0.002), indicating approximately a 1% risk reduction per unit increase in DI-GM (Table 3).

Fig. 2.

Fig. 2

Restricted cubic spline analysis of the association between DI-GM and osteoporosis at various skeletal sites without covariate adjustment. (A) Femoral neck; (B) Intertrochanter; (C) Ward's triangle; (D) Total femur; (E) Trochanter.

Fig. 3.

Fig. 3

Restricted cubic spline analysis of the association between DI-GM and osteoporosis at various skeletal sites after covariate adjustment. (A) Femoral neck; (B) Intertrochanter; (C) Ward's triangle; (D) Total femur; (E) Trochanter.

Table 3.

Threshold effect analysis of DI-GM on osteoporosis at the femoral neck.

Parameter Effect Size (95% CI), P-value
Model 1 Fitting model by standard linear regression 0.936 (0.884-0.99)0.02
Model 2 Fitting model by two-piecewise linear regression
Inflection point 3
<3 1.455 (1.002-2.221)0.064
>3 0.904 (0.847-0.963)0.002
P for likelihood ratio test 0.017
Model 1: Standard linear regression with DI-GM as a continuous predictor.
Model 2: Two-piecewise linear regression with DI-GM split at the inflection point.
Significance: P < 0.05 indicates statistical significance.

3.4. Subgroup analysis

Subgroup analyses were conducted to examine potential effect modification. The inverse association between DI-GM and femoral neck osteoporosis was significant among participants with hypertension (adjusted OR = 0.76, 95% CI: 0.59–0.978, p = 0.031) and those without cardiovascular disease (adjusted OR = 0.91, 95% CI: 0.84–0.99, p = 0.039) (Fig. 4, Table 4). Among obese individuals, DI-GM was positively associated with intertrochanter osteoporosis (adjusted OR = 1.33, 95% CI: 1.07–1.66, p = 0.011), while a protective effect was seen in non-hypertensive participants (adjusted OR = 0.78, 95% CI: 0.62–0.99, p = 0.044) (Fig. 5, Table 5). For total femur osteoporosis, DI-GM showed significant inverse associations in participants aged ≥50 (OR = 0.87, p = 0.015), women (OR = 0.85, p = 0.003), non-diabetics (OR = 0.86, p = 0.015), drinkers (OR = 0.80, p = 0.008), individuals with low BMI (OR = 0.84, p = 0.005), and those without cardiovascular disease (OR = 0.88, p = 0.038) (Fig. 6, Table 6). For trochanter osteoporosis, protective associations were found in drinkers (OR = 0.81, p = 0.046) and participants with low BMI (OR = 0.85, p = 0.015) (Fig. 7, Table 7). No significant associations were found for Ward's triangle in any subgroup (Fig. 8, Table 8).

Fig. 4.

Fig. 4

Forest plot of subgroup analysis for the association between DI-GM and osteoporosis at the femoral neck.

Table 4.

Subgroup analysis of the association between DI-GM and osteoporosis at the femoral neck.

Variables n (%) OR (95%CI) P P for interaction
Age 0.662
 ≤50 5135 (45.0%) 0.74 (0.50 ∼ 1.10) 0.133
 > 50 7310 (55.0%) 0.97 (0.87 ∼ 1.07) 0.477
Sex 0.116
 FeMale 6399 (49.2%) 0.92 (0.82 ∼ 1.04) 0.171
 Male 6046 (50.8%) 1.06 (0.92 ∼ 1.23) 0.413
Race/ethnicity 0.238
 Mexican 1891 (7.1%) 0.91 (0.83 ∼ 0.99) 0.023∗
 Other Hispanic 1210 (4.8%) 1.13 (0.83 ∼ 1.54) 0.446
 Non-Hispanic White 6041 (72.0%) 1.09 (0.89 ∼ 1.33) 0.406
 Non-Hispanic Black 2375 (9.9%) 0.91 (0.82 ∼ 1.00) 0.055
 Other Race 928 (6.2%) 1.02 (0.86 ∼ 1.20) 0.831
Education 0.707
 Less Than 9th 1233 (4.7%) 0.93 (0.79 ∼ 1.09) 0.367
 9-11th 1811 (10.7%) 0.96 (0.85 ∼ 1.07) 0.439
 High School 2958 (24.1%) 0.94 (0.87 ∼ 1.02) 0.119
 Some College 3581 (30.7%) 1.01 (0.81 ∼ 1.24) 0.960
 College Graduate 2862 (29.9%) 1.07 (0.79 ∼ 1.46) 0.662
Hypertension 0.126
 No 7640 (65.9%) 1.04 (0.85 ∼ 1.27) 0.710
 Yes 4805 (34.1%) 0.76 (0.59 ∼ 0.97) 0.031∗
Diabetes 0.270
 No 9159 (79.3%) 0.96 (0.86 ∼ 1.07) 0.430
 Yes 1913 (11.4%) 0.88 (0.69 ∼ 1.14) 0.322
 Borderline 1373 (9.3%) 0.97 (0.72 ∼ 1.31) 0.831
Smoke 0.622
 No 9866 (80.4%) 1.06 (0.85 ∼ 1.31) 0.610
 Yes 2579 (19.6%) 0.85 (0.70 ∼ 1.03) 0.096
Drink 0.678
 No 1559 (9.8%) 1.01 (0.87 ∼ 1.17) 0.884
 Yes 10,886 (90.2%) 0.93 (0.86 ∼ 1.01) 0.067
BMI 0.228
 ≤27.87 6228 (50.7%) 0.95 (0.85 ∼ 1.06) 0.373
 > 27.87 6217 (49.3%) 0.96 (0.79 ∼ 1.17) 0.690
Cardiovascular disease 0.181
 No 10,945 (90.2%) 0.91 (0.84 ∼ 0.99) 0.039∗
 Yes 1500 (9.8%) 1.11 (0.87 ∼ 1.40) 0.389

OR: Odds Ratio, CI: Confidence Interval.

Fig. 5.

Fig. 5

Forest plot of subgroup analysis for the association between DI-GM and osteoporosis at the intertrochanter.

Table 5.

Subgroup analysis of the association between DI-GM and osteoporosis at the intertrochanter.

Variables n (%) OR (95%CI) P P for interaction
Age 0.298
 ≤50 5135 (45.0%) 1.03 (0.76 ∼ 1.40) 0.847
 > 50 7310 (55.0%) 0.98 (0.84 ∼ 1.14) 0.767
Sex 0.998
 FeMale 6399 (49.2%) 0.98 (0.83 ∼ 1.15) 0.772
 Male 6046 (50.8%) 0.94 (0.82 ∼ 1.08) 0.376
Race/ethnicity 0.031∗
 Mexican 1891 (7.1%) 0.91 (0.82 ∼ 1.02) 0.101
 Other Hispanic 1210 (4.8%) 1.22 (0.82 ∼ 1.83) 0.313
 Non-Hispanic White 6041 (72.0%) 1.05 (0.83 ∼ 1.31) 0.695
 Non-Hispanic Black 2375 (9.9%) 0.95 (0.84 ∼ 1.07) 0.404
 Other Race 928 (6.2%) 1.03 (0.80 ∼ 1.32) 0.802
Education 0.019∗
 Less Than 9th 1233 (4.7%) 1.00 (0.83 ∼ 1.20) 0.981
 9-11th 1811 (10.7%) 0.97 (0.82 ∼ 1.15) 0.739
 High School 2958 (24.1%) 0.96 (0.86 ∼ 1.08) 0.497
 Some College 3581 (30.7%) 1.06 (0.79 ∼ 1.42) 0.711
 College Graduate 2862 (29.9%) 1.24 (0.94 ∼ 1.65) 0.123
Hypertension 0.389
 No 7640 (65.9%) 0.83 (0.62 ∼ 1.10) 0.178
 Yes 4805 (34.1%) 0.94 (0.74 ∼ 1.20) 0.630
Diabetes 0.246
 No 9159 (79.3%) 0.97 (0.81 ∼ 1.16) 0.712
 Yes 1913 (11.4%) 1.10 (0.84 ∼ 1.44) 0.466
 Borderline 1373 (9.3%) 1.13 (0.83 ∼ 1.55) 0.434
Smoke 0.037∗
 No 9866 (80.4%) 1.28 (0.96 ∼ 1.70) 0.088
 Yes 2579 (19.6%) 0.89 (0.73 ∼ 1.08) 0.233
Drink 0.914
 No 1559 (9.8%) 0.87 (0.70 ∼ 1.06) 0.166
 Yes 10,886 (90.2%) 0.83 (0.70 ∼ 0.99) 0.043∗
BMI 0.334
 ≤27.87 6228 (50.7%) 0.95 (0.80 ∼ 1.12) 0.529
 > 27.87 6217 (49.3%) 1.33 (1.07 ∼ 1.66) 0.011∗
Cardiovascular disease 0.288
 No 10,945 (90.2%) 0.94 (0.84 ∼ 1.05) 0.269
 Yes 1500 (9.8%) 1.16 (0.83 ∼ 1.62) 0.375

OR: Odds Ratio, CI: Confidence Interval.

Fig. 6.

Fig. 6

Forest plot of subgroup analysis for the association between DI-GM and osteoporosis at the total femur.

Table 6.

Subgroup analysis of the association between DI-GM and osteoporosis at the total femur.

Variables n (%) OR (95%CI) P P for interaction
Age 0.283
 ≤50 5135 (45.0%) 1.06 (0.72 ∼ 1.55) 0.762
 > 50 7310 (55.0%) 0.87 (0.78 ∼ 0.97) 0.015∗
Sex 0.016∗
 FeMale 6399 (49.2%) 0.85 (0.76 ∼ 0.94) 0.003∗∗
 Male 6046 (50.8%) 1.09 (0.89 ∼ 1.34) 0.398
Race/ethnicity 0.502
 Mexican 1891 (7.1%) 0.86 (0.77 ∼ 0.97) 0.017∗
 Other Hispanic 1210 (4.8%) 0.91 (0.74 ∼ 1.12) 0.375
 Non-Hispanic White 6041 (72.0%) 0.95 (0.77 ∼ 1.18) 0.639
 Non-Hispanic Black 2375 (9.9%) 0.91 (0.78 ∼ 1.06) 0.212
 Other Race 928 (6.2%) 0.86 (0.75 ∼ 0.97) 0.017∗
Education 0.245
 Less Than 9th 1233 (4.7%) 0.88 (0.74 ∼ 1.04) 0.122
 9-11th 1811 (10.7%) 0.88 (0.79 ∼ 0.99) 0.030∗
 High School 2958 (24.1%) 0.91 (0.81 ∼ 1.02) 0.087
 Some College 3581 (30.7%) 0.86 (0.72 ∼ 1.03) 0.102
 College Graduate 2862 (29.9%) 1.10 (0.80 ∼ 1.52) 0.551
Hypertension 0.624
 No 7640 (65.9%) 0.91 (0.65 ∼ 1.27) 0.559
 Yes 4805 (34.1%) 0.84 (0.64 ∼ 1.10) 0.207
Diabetes 0.753
 No 9159 (79.3%) 0.86 (0.76 ∼ 0.97) 0.015∗
 Yes 1913 (11.4%) 1.08 (0.78 ∼ 1.50) 0.638
 Borderline 1373 (9.3%) 1.06 (0.79 ∼ 1.43) 0.682
Smoke 0.005∗∗
 No 9866 (80.4%) 0.96 (0.80 ∼ 1.16) 0.656
 Yes 2579 (19.6%) 0.88 (0.70 ∼ 1.11) 0.285
Drink 0.654
 No 1559 (9.8%) 0.87 (0.70 ∼ 1.08) 0.200
 Yes 10,886 (90.2%) 0.80 (0.69 ∼ 0.94) 0.008∗∗
BMI 0.295
 ≤27.87 6228 (50.7%) 0.84 (0.75 ∼ 0.94) 0.005∗∗
 > 27.87 6217 (49.3%) 1.22 (0.94 ∼ 1.59) 0.124
Cardiovascular disease 0.503
 No 10,945 (90.2%) 0.88 (0.78 ∼ 0.99) 0.038∗
 Yes 1500 (9.8%) 0.92 (0.79 ∼ 1.08) 0.296

OR: Odds Ratio, CI: Confidence Interval.

Fig. 7.

Fig. 7

Forest plot of subgroup analysis for the association between DI-GM and osteoporosis at the trochanter.

Table 7.

Subgroup analysis of the association between DI-GM and osteoporosis at the trochanter.

Variables n (%) OR (95%CI) P P for interaction
Age 0.459
 ≤50 5135 (45.0%) 0.97 (0.56 ∼ 1.70) 0.921
 > 50 7310 (55.0%) 0.90 (0.79 ∼ 1.02) 0.099
Sex 0.081
 FeMale 6399 (49.2%) 0.88 (0.78 ∼ 1.01) 0.063
 Male 6046 (50.8%) 1.01 (0.76 ∼ 1.34) 0.937
Race/ethnicity 0.965
 Mexican 1891 (7.1%) 0.83 (0.70 ∼ 0.98) 0.030∗
 Other Hispanic 1210 (4.8%) 1.15 (0.90 ∼ 1.46) 0.253
 Non-Hispanic White 6041 (72.0%) 0.87 (0.63 ∼ 1.21) 0.389
 Non-Hispanic Black 2375 (9.9%) 0.85 (0.71 ∼ 1.00) 0.055
 Other Race 928 (6.2%) 0.97 (0.79 ∼ 1.18) 0.747
Education 0.816
 Less Than 9th 1233 (4.7%) 0.92 (0.69 ∼ 1.21) 0.524
 9-11th 1811 (10.7%) 0.89 (0.79 ∼ 1.01) 0.072
 High School 2958 (24.1%) 0.92 (0.81 ∼ 1.05) 0.211
 Some College 3581 (30.7%) 0.88 (0.72 ∼ 1.07) 0.196
 College Graduate 2862 (29.9%) 1.06 (0.67 ∼ 1.67) 0.793
Hypertension 0.441
 No 7640 (65.9%) 1.21 (0.79 ∼ 1.84) 0.364
 Yes 4805 (34.1%) 0.95 (0.58 ∼ 1.58) 0.850
Diabetes 0.034∗
 No 9159 (79.3%) 0.88 (0.77 ∼ 1.02) 0.081
 Yes 1913 (11.4%) 0.88 (0.63 ∼ 1.24) 0.466
 Borderline 1373 (9.3%) 0.92 (0.46 ∼ 1.86) 0.819
Smoke 0.025∗
 No 9866 (80.4%) 0.85 (0.67 ∼ 1.07) 0.167
 Yes 2579 (19.6%) 1.02 (0.75 ∼ 1.39) 0.896
Drink 0.872
 No 1559 (9.8%) 1.03 (0.80 ∼ 1.33) 0.804
 Yes 10,886 (90.2%) 0.81 (0.66 ∼ 0.99) 0.046∗
BMI 0.675
 ≤27.87 6228 (50.7%) 0.85 (0.75 ∼ 0.97) 0.015∗
>27.87 6217 (49.3%) 1.26 (0.89 ∼ 1.77) 0.192
 Cardiovascular disease 0.055
 No 10,945 (90.2%) 0.85 (0.72 ∼ 1.00) 0.057
 Yes 1500 (9.8%) 1.09 (0.89 ∼ 1.32) 0.399

OR: Odds Ratio, CI: Confidence Interval.

Fig. 8.

Fig. 8

Forest plot of subgroup analysis for the association between DI-GM and osteoporosis at Ward's triangle.

Table 8.

Subgroup analysis of the association between DI-GM and osteoporosis at Ward's triangle.

Variables n (%) OR (95%CI) P P for interaction
Age 0.879
 ≤50 5135 (45.0%) 0.97 (0.85 ∼ 1.11) 0.661
 > 50 7310 (55.0%) 0.99 (0.93 ∼ 1.05) 0.638
Sex 0.780
 FeMale 6399 (49.2%) 0.99 (0.91 ∼ 1.07) 0.770
 Male 6046 (50.8%) 0.98 (0.92 ∼ 1.06) 0.655
Race/ethnicity 0.344
 Mexican 1891 (7.1%) 1.00 (0.94 ∼ 1.06) 0.898
 Other Hispanic 1210 (4.8%) 0.96 (0.83 ∼ 1.13) 0.645
 Non-Hispanic White 6041 (72.0%) 0.94 (0.82 ∼ 1.08) 0.392
 Non-Hispanic Black 2375 (9.9%) 0.99 (0.91 ∼ 1.08) 0.905
 Other Race 928 (6.2%) 0.98 (0.91 ∼ 1.06) 0.637
Education 0.107
 Less Than 9th 1233 (4.7%) 0.98 (0.85 ∼ 1.13) 0.741
 9-11th 1811 (10.7%) 0.99 (0.93 ∼ 1.05) 0.697
 High School 2958 (24.1%) 1.01 (0.95 ∼ 1.07) 0.705
 Some College 3581 (30.7%) 0.97 (0.88 ∼ 1.07) 0.540
 College Graduate 2862 (29.9%) 1.08 (0.95 ∼ 1.23) 0.244
Hypertension 0.955
 No 7640 (65.9%) 0.97 (0.87 ∼ 1.09) 0.632
 Yes 4805 (34.1%) 0.84 (0.71 ∼ 1.01) 0.065
Diabetes 0.715
 No 9159 (79.3%) 0.99 (0.93 ∼ 1.05) 0.732
 Yes 1913 (11.4%) 1.06 (0.96 ∼ 1.16) 0.223
 Borderline 1373 (9.3%) 0.98 (0.83 ∼ 1.17) 0.856
Smoke 0.173
 No 9866 (80.4%) 1.04 (0.96 ∼ 1.12) 0.297
 Yes 2579 (19.6%) 0.96 (0.88 ∼ 1.06) 0.451
Drink 0.895
 No 1559 (9.8%) 0.94 (0.85 ∼ 1.04) 0.256
 Yes 10,886 (90.2%) 0.97 (0.87 ∼ 1.07) 0.501
BMI 0.591
 ≤27.87 6228 (50.7%) 0.97 (0.91 ∼ 1.04) 0.357
 > 27.87 6217 (49.3%) 1.09 (0.95 ∼ 1.25) 0.196
Cardiovascular disease 0.161
 No 10,945 (90.2%) 0.97 (0.92 ∼ 1.02) 0.270
 Yes 1500 (9.8%) 1.06 (0.94 ∼ 1.19) 0.331

OR: Odds Ratio, CI: Confidence Interval.

3.5. Feature selection for predictive modeling

To construct a predictive model for total femur osteoporosis, all components of the DI-GM were evaluated. Using the Boruta algorithm, all features were confirmed as important predictors and retained for model development (Fig. 9).

Fig. 9.

Fig. 9

Feature variable selection using the BORUTA algorithm.

3.6. Model development and performance evaluation

Six machine learning models—Random Forest, LightGBM, K-NN, Naive Bayes, SVM, and XGBoost—were developed. Model performance was assessed using AUC-ROC (Fig. 10), AUC-PR (Fig. 11), accuracy (Fig. 12A), F-Beta (Fig. 12B), sensitivity (Fig. 12C), and specificity (Fig. 12D) (Table 9). Random Forest achieved the best overall performance, with an accuracy of 0.981, F-Beta of 0.988, AUC-ROC of 0.997, sensitivity of 0.995, specificity of 0.937, and AUC-PR of 0.999. XGBoost and LightGBM also demonstrated high performance. K-NN and SVM had moderate accuracy, while Naive Bayes performed the least well (AUC-ROC 0.865, AUC-PR 0.943). Performance differences across models were statistically significant (P < 0.001).

Fig. 10.

Fig. 10

Receiver operating characteristic (ROC) curves and corresponding area under the curve (AUC) values for six machine learning models.

Fig. 11.

Fig. 11

Recall curves and corresponding area under the curve (AUC) values for six machine learning models.

Fig. 12.

Fig. 12

Performance metrics of six machine learning models. (A) Accuracy; (B) F-beta score; (C) Sensitivity; (D) Specificity.

Table 9.

Comparative performance of six machine learning models.

Model Accuracy F Beta Area under the ROC curve Sensitivity Specificity Area under the PR curve
Random Forest 0.981 0.988 0.997 0.995 0.937 0.999
Light GBM 0.979 0.986 0.995 0.992 0.936 0.998
K-KNN 0.950 0.966 0.992 0.935 0.999 0.998
Naive Bayes 0.691 0.760 0.865 0.636 0.877 0.943
SVM 0.952 0.969 0.988 0.971 0.888 0.997
XGBoost 0.981 0.988 0.996 0.993 0.942 0.999
P <.001a <.001a <.001b <.001a <.001a <.001a
a

ANOVA test.

b

Kruskal-Wallis.

Temporal validation on the 2017–2018 cycle confirmed robust performance of the Random Forest model (accuracy = 0.874, AUC-ROC = 0.934, AUC-PR = 0.936), indicating no substantial overfitting and supporting the model's reliability (Supplementary Fig. 1).

3.7. Feature interpretability via SHAP and LIME

SHAP analysis was applied to interpret feature contributions in the Random Forest model (Fig. 13). Sex had the highest positive SHAP value (0.0901), indicating its dominant influence. Other negative contributors to osteoporosis risk included whole grains (SHAP = 0.0117), coffee (0.0084), red meat (0.0079), and soybeans (0.0051). Individual prediction dynamics were visualized using SHAP force and waterfall plots (Fig. 14, Fig. 15), revealing a 0.986 predicted probability of non-osteoporosis. LIME analysis offered additional insights at the individual level (Fig. 16). Key protective dietary features included coffee (0.14–2.95), fat intake (0.205–0.29), refined grains (0.210–0.34), red meat (0.115–0.92), avocado (−0.2–2.27), and broccoli (−0.39–0.166), collectively yielding a prediction probability of 0.99 for non-osteoporosis status.

Fig. 13.

Fig. 13

SHAP summary plot illustrating feature importance in the random forest model.

Fig. 14.

Fig. 14

Force plot providing case-level interpretation for the random forest model.

Fig. 15.

Fig. 15

Waterfall plot providing case-level interpretation for the random forest model.

Fig. 16.

Fig. 16

Case-level interpretation of the random forest model using the LIME algorithm.

4. Discussion

This study utilized NHANES data and multiple machine learning models to investigate the relationship between the DI-GM index—an indicator of gut microbiota-supportive dietary intake—and the risk of osteoporosis at various skeletal sites. After adjusting for relevant covariates, a significant inverse association was observed between DI-GM and the risk of osteoporosis at the total femur. RCS analysis further revealed a nonlinear association at the femoral neck, with a threshold effect identified at DI-GM = 3. Among the predictive models evaluated, the random forest algorithm exhibited the highest performance. SHAP analysis identified whole grains, coffee, red meat, and soybeans as major contributors to reduced osteoporosis risk at the total femur.

The inverse association between DI-GM and total femur osteoporosis reinforces the growing body of evidence supporting the gut–bone axis. This conceptual framework posits that the gut microbiota influences bone metabolism through mechanisms such as enhanced nutrient absorption, immune modulation, and the production of short-chain fatty acids (SCFAs) [19]. Diets that promote microbial diversity—such as the Mediterranean diet—have been linked to increased BMD and reduced fracture risk [20]. For instance, one systematic review reported a 21% reduction in hip fracture risk among individuals adhering to this dietary pattern [21]. The DI-GM index emphasizes microbiota-supportive foods, including whole grains, fermented dairy products, and dietary fiber, all of which are known to boost SCFA production, facilitate calcium absorption, and reduce inflammation [22].

Among these dietary components, whole grains emerged as a key protective factor in our analysis. This finding is consistent with previous studies, such as one conducted among Korean adults, which showed that dietary patterns rich in whole grains, dairy, and fruits were associated with a significantly lower risk of low BMD (OR = 0.38 in men, OR = 0.45 in women) [23]. Similarly, soy products—which are high in isoflavones with estrogen-like activity—have demonstrated efficacy in reducing postmenopausal bone loss. A meta-analysis confirmed that soy intake significantly improves BMD [24]. These findings align with our results, suggesting that both whole grains and soy may contribute to bone health through nutritional and microbiota-mediated pathways.

The role of coffee in bone health remains a topic of debate. However, our observation of a protective association aligns with some recent evidence. A prospective cohort study using UK Biobank data found an inverse association between coffee intake and osteoporosis, particularly among men, and demonstrated a dose-dependent effect [25]. This may be attributable to coffee's polyphenolic compounds, which have antioxidant properties that potentially mitigate bone degradation [26]. Nevertheless, conflicting findings exist. Some studies report that high caffeine intake increases urinary calcium excretion, particularly in individuals with insufficient calcium intake, potentially offsetting any benefits [27]. These divergent findings highlight the need to consider dietary context and nutrient balance when evaluating coffee's impact on bone health.

Interestingly, red meat, often associated with increased acid load and bone resorption due to its high animal protein content [28], showed a protective association in our analysis. This result is consistent with research in Chinese postmenopausal women, where frequent meat consumption was positively associated with BMD (β = 0.12, p < 0.001) [29]. The protective effect observed in our study may reflect the influence of overall dietary patterns captured by the DI-GM index. In diets where red meat is consumed alongside sufficient calcium and other beneficial nutrients, its potential negative effects may be mitigated.

At the femoral neck, DI-GM scores below 3 were weakly associated with increased osteoporosis risk, suggesting a possible threshold effect. Diets falling below this threshold may be insufficient in essential nutrients or prebiotics necessary for maintaining microbial balance, potentially leading to dysbiosis and increased bone loss [30]. However, the marginal statistical significance (p = 0.064) warrants cautious interpretation, as this result could be due to random variation or unmeasured confounding.

The observed threshold at DI-GM = 3 likely represents the minimum level of microbiota-supportive nutrients required to achieve adequate production of SCFAs (particularly butyrate), which inhibit osteoclastogenesis and enhance calcium absorption and bone formation [31]. Below this critical level, insufficient prebiotic intake may result in microbial dysbiosis, reduced SCFA levels, increased gut permeability, and systemic inflammation that promotes bone resorption [32]. This pattern is consistent with evidence that a minimum microbial diversity/SCFA threshold is necessary for skeletal protection [33]. The positive association below DI-GM = 3 (adjusted OR = 1.455, p = 0.064) should be interpreted as a suggestive trend rather than a statistically confirmed risk elevation, potentially reflecting limited statistical power or residual confounding; prospective studies are required for confirmation.

The observed protective role of red meat, despite existing evidence linking high protein intake to increased calcium excretion [34], may be partially explained by adequate calcium intake among NHANES participants [35]. This supports the idea that sufficient protein can be beneficial when calcium intake is adequate [36]. The DI-GM framework may better reflect these complex nutrient interactions, highlighting the importance of considering overall dietary quality rather than isolated food components.

Overall, these findings strengthen the gut–bone axis hypothesis. The nonlinear relationship at the femoral neck underscores the possibility of a threshold effect, suggesting that diets must reach a certain level of gut microbiota supportiveness to confer skeletal benefits. These insights could inform the development of dietary guidelines aimed at reducing osteoporosis risk through gut-targeted interventions.

The integration of machine learning—particularly the random forest model combined with SHAP analysis—enhanced the precision of identifying key dietary predictors. This approach offers the potential to augment traditional screening tools, such as the Osteoporosis Self-Assessment Tool for Asians (OSTA), by incorporating microbiota-related dietary variables [37,38]. While our results are largely consistent with existing literature, they also highlight the intricate interplay between diet and bone health, pointing to the need for further investigation into mechanisms such as nutrient thresholds and site-specific skeletal responses.

Nonetheless, several limitations must be acknowledged. First, the cross-sectional design of NHANES limits causal inference, as temporal relationships cannot be established [39]. Second, dietary intake was assessed using 24-h recall, which is subject to recall bias and may affect the accuracy of DI-GM estimation [40]. Third, reverse causality cannot be excluded—individuals with osteoporosis may modify their diets after diagnosis, influencing the observed associations. Additionally, findings may not be generalizable beyond U.S. populations due to cultural differences in diet and gut microbiota composition [41]. Lastly, although the random forest model demonstrated robust predictive power, machine learning models require external validation in independent cohorts to confirm their utility [42]. Although temporal validation within NHANES demonstrated maintained performance, fully external validation in independent cohorts remains necessary to confirm generalizability.

5. Conclusion

DI-GM score above 3 may lower the risk of osteoporosis at the femoral neck. Whole grains, coffee, red meat, and soybeans were identified as protective dietary factors, supporting the gut–bone axis hypothesis. Future longitudinal and interventional studies are necessary to confirm causality and clarify the mechanisms through which microbiota-targeted dietary strategies may prevent osteoporosis.

CRediT authorship contribution statement

Lishen Zhou: Funding acquisition, Formal analysis, Data curation, Conceptualization. Junshen Liu: Methodology, Investigation. Hong Xu: Project administration, Funding acquisition. Guanrong Sun: Software, Resources. Yuliang Lou: Visualization, Validation. Jianyue Wang: Writing – review & editing.

Ethics approval and consent to participate

This investigation was approved by the National Center for Health Statistics Ethics Review Board. Informed consent was obtained from all subjects involved in the NHANES.

Data availability statement

Publicly available datasets were analyzed in this study. The data can be found here: https://www.cdc.gov/nchs/nhanes/.

Funding

Omitted.

Funding

This work was supported by the Hangzhou Project Foundation for Agriculture and Social Development [grant number 20241029Y119]; and the Zhejiang Province Traditional Chinese Medicine Science and Technology Project [grant number 2024ZR152].

Conflicts of interest

All authors declare that there are no conflicts of interest.

Footnotes

Appendix A

Supplementary data to this article can be found online at https://doi.org/10.1016/j.metop.2026.100467.

Contributor Information

Lishen Zhou, Email: zhoulishen1992@163.com.

Junshen Liu, Email: junsheng82@126.com.

Hong Xu, Email: xiaoranxuhong@163.com.

Guanrong Sun, Email: sgrong123@163.com.

Yuliang Lou, Email: 360465602@qq.com.

Jianyue Wang, Email: 19011265620@qq.com.

Appendix A. Supplementary data

The following is the Supplementary data to this article.

graphic file with name mmcfigs1.jpg

Supplementary Figure 1. Time series validation. (A) Performance heatmaps of different models for the 2005-2006 + 2013-2014 period; (B) Performance heatmaps of different models for the 2017-2018 period; (C) ROC curves and areas under the curves of different models for the 2005-2006 + 2013-2014 period; (D) ROC curves and areas under the curves of different models for the 2017-2018 period; (E) PR curves and areas under the curves of different models for the 2005-2006 + 2013-2014 period; (F) PR curves and areas under the curves of different models for the 2017-2018 period.

References

  • 1.Compston J.E., McClung M.R., Leslie W.D. Osteoporosis. Lancet. 2019;393(10169):364–376. doi: 10.1016/S0140-6736(18)32112-3. [DOI] [PubMed] [Google Scholar]
  • 2.Salari N., Darvishi N., Bartina Y., et al. Global prevalence of osteoporosis among the world older adults: a comprehensive systematic review and meta-analysis. J Orthop Surg Res. 2021;16(1):669. doi: 10.1186/s13018-021-02821-8. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 3.Hoong C.W.S., Saul D., Khosla S., Sfeir J.G. Advances in the management of osteoporosis. BMJ (Clinical research ed) 2025;390 doi: 10.1136/bmj-2024-081250. [DOI] [PubMed] [Google Scholar]
  • 4.Barnsley J., Buckland G., Chan P.E., et al. Pathophysiology and treatment of osteoporosis: challenges for clinical practice in older people. Aging Clin Exp Res. 2021;33(4):759–773. doi: 10.1007/s40520-021-01817-y. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 5.Lane N.E. Epidemiology, etiology, and diagnosis of osteoporosis. Am J Obstet Gynecol. 2006;194(2 Suppl):S3–S11. doi: 10.1016/j.ajog.2005.08.047. [DOI] [PubMed] [Google Scholar]
  • 6.Lyu Z., Hu Y., Guo Y., Liu D. Modulation of bone remodeling by the gut microbiota: a new therapy for osteoporosis. Bone Res. 2023;11(1):31. doi: 10.1038/s41413-023-00264-x. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 7.Rizzoli R., Biver E., Brennan-Speranza T.C. Nutritional intake and bone health. Lancet Diabetes Endocrinol. 2021;9(9):606–621. doi: 10.1016/S2213-8587(21)00119-4. [DOI] [PubMed] [Google Scholar]
  • 8.Valdes A.M., Walter J., Segal E., Spector T.D. Role of the gut microbiota in nutrition and health. BMJ (Clinical research ed) 2018;361 doi: 10.1136/bmj.k2179. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 9.Lai Y., Fang C., Jiang Y., et al. Novel opportunity of treatment for psycho-cardiologic disease by gut microbiome. Frontiers in cardiovascular medicine. 2025;12 doi: 10.3389/fcvm.2025.1604962. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 10.Gu C., Du H., Li N., et al. The gut-bone axis in osteoporosis: a multifaceted interaction with implications for bone health. Front Endocrinol. 2025;16 doi: 10.3389/fendo.2025.1569152. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 11.Kase B.E., Liese A.D., Zhang J., et al. The development and evaluation of a literature-based dietary index for Gut Microbiota. Nutrients. 2024;16(7) doi: 10.3390/nu16071045. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 12.Singh R.K., Chang H.W., Yan D., et al. Influence of diet on the gut microbiome and implications for human health. J Transl Med. 2017;15(1):73. doi: 10.1186/s12967-017-1175-y. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 13.Bolte L.A., Vich Vila A., Imhann F., et al. Long-term dietary patterns are associated with pro-inflammatory and anti-inflammatory features of the gut microbiome. Gut. 2021;70(7):1287–1298. doi: 10.1136/gutjnl-2020-322670. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 14.Akyil S., Winkler S., Meyer D., et al. Association between dairy intake and multiple health outcomes: a scoping review of systematic reviews and meta-analyses. Eur J Clin Nutr. 2025 doi: 10.1038/s41430-025-01639-5. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 15.Zaiss M.M., Jones R.M., Schett G., Pacifici R. The gut-bone axis: how bacterial metabolites bridge the distance. J Clin Investig. 2019;129(8):3018–3028. doi: 10.1172/JCI128521. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 16.Zhang Y.W., Song P.R., Wang S.C., et al. Diets intervene osteoporosis via gut-bone axis. Gut Microbes. 2024;16(1) doi: 10.1080/19490976.2023.2295432. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 17.Lucas S., Omata Y., Hofmann J., et al. Short-chain fatty acids regulate systemic bone mass and protect from pathological bone loss. Nat Commun. 2018;9(1):55. doi: 10.1038/s41467-017-02490-4. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 18.Ohlsson C., Sjögren K. Effects of the gut microbiota on bone mass. Trends Endocrinol Metabol: TEM (Trends Endocrinol Metab) 2015;26(2):69–74. doi: 10.1016/j.tem.2014.11.004. [DOI] [PubMed] [Google Scholar]
  • 19.He J., Xu S., Zhang B., et al. Gut microbiota and metabolite alterations associated with reduced bone mineral density or bone metabolic indexes in postmenopausal osteoporosis. Aging. 2020;12(9):8583–8604. doi: 10.18632/aging.103168. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 20.Andreo-López M.C., Contreras-Bolívar V., García-Fontana B., et al. The influence of the mediterranean dietary pattern on osteoporosis and Sarcopenia. Nutrients. 2023;15(14) doi: 10.3390/nu15143224. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 21.Noori M., Jayedi A., Khan T.A., et al. Mediterranean dietary pattern and bone mineral density: a systematic review and dose-response meta-analysis of observational studies. Eur J Clin Nutr. 2022;76(12):1657–1664. doi: 10.1038/s41430-022-01093-7. [DOI] [PubMed] [Google Scholar]
  • 22.Xu Q., Li D., Chen J., et al. Crosstalk between the gut microbiota and postmenopausal osteoporosis: mechanisms and applications. Int Immunopharmacol. 2022;110 doi: 10.1016/j.intimp.2022.108998. [DOI] [PubMed] [Google Scholar]
  • 23.Shin S., Sung J., Joung H. A fruit, milk and whole grain dietary pattern is positively associated with bone mineral density in Korean healthy adults. Eur J Clin Nutr. 2015;69(4):442–448. doi: 10.1038/ejcn.2014.231. [DOI] [PubMed] [Google Scholar]
  • 24.Hooshiar S.H., Tobeiha M., Jafarnejad S. Soy isoflavones and bone health: focus on the RANKL/RANK/OPG pathway. BioMed Res Int. 2022;2022 doi: 10.1155/2022/8862278. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 25.Zhang S., Wu S., Xia B., et al. Association of coffee and tea consumption with osteoporosis risk: a prospective study from the UK biobank. Bone. 2024;186 doi: 10.1016/j.bone.2024.117135. [DOI] [PubMed] [Google Scholar]
  • 26.Malmir H., Ejtahed H.S., Soroush A.R., et al. Probiotics as a new regulator for bone health: a systematic review and meta-analysis. Evid Based Complement Alternat Med : eCAM. 2021;2021 doi: 10.1155/2021/3582989. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 27.Berman N.K., Honig S., Cronstein B.N., Pillinger M.H. The effects of caffeine on bone mineral density and fracture risk. Osteoporos Int : a journal established as result of cooperation between the European Foundation for Osteoporosis and the National Osteoporosis Foundation of the USA. 2022;33(6):1235–1241. doi: 10.1007/s00198-021-05972-w. [DOI] [PubMed] [Google Scholar]
  • 28.Mangano K.M., Walsh S.J., Kenny A.M., et al. Dietary acid load is associated with lower bone mineral density in men with low intake of dietary calcium. J Bone Miner Res : the official journal of the American Society for Bone and Mineral Research. 2014;29(2):500–506. doi: 10.1002/jbmr.2053. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 29.Qing G.Z., Lu Y., Yi T., et al. The relationship of frequency of meat consumption and osteoporosis in Chinese postmenopausal women. Int J Clin Exp Med. 2015;8(11):21130–21137. [PMC free article] [PubMed] [Google Scholar]
  • 30.Chen Y.C., Greenbaum J., Shen H., Deng H.W. Association between Gut Microbiota and bone health: potential mechanisms and prospective. J Clin Endocrinol Metabol. 2017;102(10):3635–3646. doi: 10.1210/jc.2017-00513. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 31.Feng B., Lu J., Han Y., et al. The role of short-chain fatty acids in the regulation of osteoporosis: new perspectives from gut microbiota to bone health: a review. Medicine (Baltim) 2024;103(34) doi: 10.1097/MD.0000000000039471. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 32.Chu X., Xing H., Chao M., et al. Gut Microbiota modulation in osteoporosis: probiotics, prebiotics, and natural compounds. Metabolites. 2025;15(5):301. doi: 10.3390/metabo15050301. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 33.Han D., Wang W., Gong J., et al. Microbiota metabolites in bone: shaping health and Confronting disease. Heliyon. 2024;10(7) doi: 10.1016/j.heliyon.2024.e28435. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 34.Fernández-Villabrille S., Baena-Huerta F., Suárez-Fernández L., et al. High dietary phosphorus impairs bone microarchitecture and induces alterations in the LGR4-R-Spondins axis in rats with normal renal function. Nutrients. 2025;17(12) doi: 10.3390/nu17122049. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 35.Bonjour J.P. Dietary protein: an essential nutrient for bone health. J Am Coll Nutr. 2005;24(6 Suppl) doi: 10.1080/07315724.2005.10719501. 526s-36s. [DOI] [PubMed] [Google Scholar]
  • 36.Groenendijk I., den Boeft L., van Loon L.J.C., de Groot L. High versus low dietary protein intake and bone health in older adults: a systematic review and meta-analysis. Comput Struct Biotechnol J. 2019;17:1101–1112. doi: 10.1016/j.csbj.2019.07.005. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 37.Ou Yang W.Y., Lai C.C., Tsou M.T., Hwang L.C. Development of machine learning models for prediction of osteoporosis from clinical health examination data. Int J Environ Res Publ Health. 2021;18(14) doi: 10.3390/ijerph18147635. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 38.Smets J., Shevroja E., Hügle T., et al. Machine learning solutions for Osteoporosis-A review. J Bone Miner Res : the official journal of the American Society for Bone and Mineral Research. 2021;36(5):833–851. doi: 10.1002/jbmr.4292. [DOI] [PubMed] [Google Scholar]
  • 39.Waldbaum J.D.H., Xhumari J., Akinsuyi O.S., et al. Association between dysbiosis in the gut Microbiota of primary osteoporosis patients and bone loss. Aging and disease. 2023;14(6):2081–2095. doi: 10.14336/AD.2023.0425. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 40.Hughes R.L., Alvarado D.A., Swanson K.S., Holscher H.D. The prebiotic potential of inulin-type fructans: a systematic review. Adv Nutr. 2022;13(2):492–529. doi: 10.1093/advances/nmab119. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 41.Lai J., Gong L., Liu Y., et al. Associations between gut microbiota and osteoporosis or osteopenia in a cohort of Chinese Han youth. Sci Rep. 2024;14(1) doi: 10.1038/s41598-024-71731-6. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 42.Huang W.C., Chen I.S., Yu H.C., et al. A simple and user-friendly machine learning model to detect osteoporosis in health examination populations in Southern Taiwan. Bone reports. 2025;24 doi: 10.1016/j.bonr.2025.101826. [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.

Data Availability Statement

Publicly available datasets were analyzed in this study. The data can be found here: https://www.cdc.gov/nchs/nhanes/.


Articles from Metabolism Open are provided here courtesy of Elsevier

RESOURCES