Spatial modeling and machine learning-based assessment of regional stroke risk and predictors in Ghana: a cross-sectional study

Random forest and gradient boosting models

RF and GB models were employed to evaluate the impact of covariates on stroke risk counts. The dataset was split into 80% training and 20% testing sets, with 10-fold cross-validation applied within the training set. Hyperparameters for each model were optimized using grid search: for RF, the number of trees (ntree = 500), the number of predictors sampled at each split (mtry = 3), and the minimum node size were tuned; for GB, the learning rate was set to 0.05, the maximum tree depth was tuned between 3 and 6, the number of boosting rounds ranged from 31 to 100, and the subsampling rate was fixed at 0.8 to introduce randomness and improve generalizability. The GB model was optimized using a set of tuned hyperparameters to balance predictive accuracy and generalizability. The final model was trained with 100 boosting iterations (nrounds = 100) and shallow trees of maximum depth 3, which reduced the risk of overfitting while capturing essential predictor interactions. A conservative learning rate (eta = 0.05) was applied to ensure gradual model updates, requiring more iterations but improving stability. Regularization was introduced through a minimum loss reduction requirement (gamma = 1) and a minimum child weight of 3, both of which constrained overly complex splits. To enhance robustness and prevent overfitting, each tree was grown using 80% of the training data (subsample = 0.8) and 70% of the predictors randomly sampled (colsample_bytree = 0.7). Together, these settings produced a moderately conservative boosting model that achieved a balance between accuracy, interpretability, and generalization.

Random forest

Figure 1 illustrates the variable importance rankings from the RF model, evaluated using two metrics: percent increase in mean squared error (%IncMSE) and increase in node purity (IncNodePurity). The %IncMSE reflects the degree to which model accuracy declines when a predictor’s values are randomly permuted. Higher values indicate that the variable plays a key role in prediction, while low or negative %IncMSE values suggest limited or even negative contribution to predictive accuracy. IncNodePurity measures how much each variable reduces variance across all tree splits, with higher values signifying more frequent and effective use in the model. Both metrics consistently identified GNI as the most important predictor of stroke risk, followed by diabetes prevalence and temperature. In contrast, the CPI showed the weakest contribution to model performance. These results highlight the dominant role of socioeconomic and health-related factors in predicting regional stroke risk.

Fig. 1figure 1

Random forest model for determining variable importance in predicting stroke risk

Gradient boosting

To further evaluate the association of covariates and stroke risk, we employed the GB model. The resulting feature importance plot is shown in Fig. 2. Variable importance was assessed using the gain metric, which quantifies the relative contribution of each predictor to the model by measuring the improvement in accuracy brought about by its inclusion in the decision trees. Among the three commonly used metrics in gradient boosting (gain, cover, and frequency), gain is considered the most informative, as it directly reflects the predictive strength of each variable. Consistent with the findings from the RF model, the GB model identified GNI as the most important predictor of stroke risk, followed by diabetes prevalence and temperature. The CPI emerged as the least contributory variable.

Fig. 2figure 2

Gradient boosting model for determining variable importance in predicting stroke risk

Although both the RF and GB models rank the same variables as the most important variables in predicting stroke risk, the GB model prediction accuracy is 75%, whereas that of the RF model is 13%, making the GB model the best-fitting model. The observed low accuracy of RF (13%) compared to GB (75%) may be attributed to the characteristics of our dataset rather than a model implementation error. Specifically, our dataset is very small, comprising only 16 regional observations. RF relies on bootstrapping and averaging across many trees to stabilize predictions, a process that requires larger datasets; with such a limited number of observations, the bootstrapped samples are highly overlapping, which reduces RF’s predictive stability (Han et al. 2021). In contrast, GB builds trees sequentially, each correcting the errors of the previous one (Jiang et al. 2020). This iterative approach allows GB to better capture complex patterns in small datasets, often leading to improved performance (Jiang et al. 2020; Boldini et al. 2023).

Regional stroke risk maps

The covariates identified as the most important predictors of stroke risk were incorporated into the BYM spatial model (BYM2) (Riebler et al. 2016; Besag et al. 1991a). Figure 3 displays the posterior relative risk estimates derived from the BYM2 model without covariate adjustment (left panel) and with covariate adjustment (right panel). A regional relative risk estimate greater than 1 indicates elevated stroke risk, values less than 1 denote reduced risk, and values equal to 1 imply no excess risk. The spatial analysis revealed pronounced heterogeneity in stroke risk across regions, with notably elevated risk observed in the southern regions of Ghana.

Fig. 3figure 3

Web-based interactive maps of relative risk (RR) from the BYM2 model without covariate adjustment (left panel) and with covariate adjustments (right panel)

In the map representing adjusted stroke relative risk, the Volta Region exhibits the highest relative risk range of 3.0–3.5, followed by the Central Region (2.5–3.0). The Bono East, Eastern, and Upper East regions are in the moderate risk range (1.5–2.0), while Ashanti and Bono (1–1.5) and Greater Accra, Western, Western North, Ahafo, Oti, North East, and Upper West have low relative risk ranging between 0.5 and 1.5. The Savannah and Northern regions have the lowest relative risk, between 0.0 and 0.5.

Assessing the effects of regional covariates on stroke risk

Table 1 presents the parameter estimates from the BYM2 model (Riebler et al. 2016), capturing the effects of regional covariates on stroke risk. To further explore the contribution of each covariate to stroke counts, we employed PDPs in Fig. 4, alongside SHAP summary plots (Fig. 5) and waterfall plots (Figs. 6, 7, 8 in Appendix I), from the GB model (Natekin And Knol 2013; Zhang et al. 2022c).

Table 1 BYM2 model: parameter estimates and 95% confidence intervalsFig. 4figure 4

Partial dependence plots of stroke risk on GNI (top-left panel), CPI (top-right panel), temperature (bottom-left panel), and diabetes prevalence (bottom-right panel)

Fig. 5figure 5

SHAP summary plot of variable importance and impact on regional stroke risk prediction

Fig. 6figure 6

SHAP waterfall plot: variable contributions to stroke risk prediction for Northern (top-left panel), North East (top-right panel), Savannah (middle-left panel), Bono (middle-right panel), Ahafo (bottom-left panel), and Bono East (bottom-right panel) regions

Results from the BYM2 model

In the unadjusted model, which does not account for any covariates, the overall relative risk is 0.49 (95% CI 0.38–0.63). This indicates that, on average, regional stroke risk is 51% lower than the national baseline, reflecting substantial spatial heterogeneity in stroke incidence across Ghana.

In the covariate-adjusted model, where GNI and diabetes prevalence are included as predictors, the overall relative risk increases to 1.03 (95% CI 0.12–9.17). This suggests a marginal increase (3%) in risk after accounting for these regional-level covariates.

Regarding individual covariate effects, GNI is associated with a decrease in stroke risk, with a relative risk estimate of 0.95 (95% CI 0.89–1.01). This implies that regions with higher economic output tend to have slightly lower stroke risk, though the confidence interval marginally overlaps 1, indicating borderline statistical significance. Conversely, diabetes prevalence shows a positive association with stroke risk, with a relative risk of 1.18 (95% CI 1.01–1.37). This suggests that regions with higher diabetes prevalence experience an 18% increase in stroke risk, reinforcing the role of diabetes as a key clinical determinant of stroke burden.

Gradient boosting modelPartial dependence plots (PDPs)

PDPs in Fig. 4 were used to explore the association of individual covariates with predicted stroke counts. The results showed that stroke risk decreases sharply with increasing GNI up to around 36%, after which it stabilizes. For the CPI, stroke counts drop around 40–48%, then rise beyond 50%. Stroke risk increases steadily with higher temperature and diabetes prevalence, indicating strong positive associations. These findings highlight key nonlinear effects of socioeconomic and health-related factors on stroke risk.

SHapley Additive exPlanations (SHAP)

Secondly, we employed the SHAP summary plot, presented in Fig. 5, to evaluate the relative importance and directionality of covariate effects on predicted stroke counts. The SHAP summary plot shows that GNI and diabetes prevalence (DMprev) were the most important predictors of regional stroke variation, followed by temperature and the CPI. High GNI values (purple) were predominantly associated with negative SHAP values, suggesting a protective effect against stroke outcomes, while low GNI values (yellow) shifted predictions upward. Higher diabetes prevalence was consistently associated with positive SHAP values, indicating increased predicted stroke counts. Temperature showed a moderate but variable contribution, with low and high values influencing predictions in different directions. CPI had the smallest overall contribution, with most SHAP values clustered near zero, though higher CPI values were occasionally associated with slight increases in predicted stroke outcomes.

SHAP waterfall plots

Figure 6 displays SHAP waterfall plots for six selected regions—Northern, North East, Savannah, Bono, Ahafo, and Bono East—while the corresponding plots for the remaining regions are provided in Appendix 1 (Figs. 7 and 8). A summary of the regional-level effects of each covariate on stroke risk is provided in Table 2, which shows both the direction (positive or negative) and magnitude of each variable’s contribution to regional stroke burden.

Table 2 Regional contributions of stroke predictors to stroke risk counts

In Fig. 6, we can deduce the following: In the Northern region, the model predicts a much lower stroke count (around 154 cases) relative to the baseline, primarily due to the strong negative contribution from a high GNI value, which contributes approximately –919, combined with a moderate reduction from low diabetes prevalence (–340). Although temperature provides a small positive adjustment, the net effect remains a strong decrease in stroke risk. Similarly, the North East region exhibits a very low predicted stroke count (around 61 cases), as both GNI and diabetes prevalence, along with the effects of CPI and temperature, work in unison to reduce the prediction substantially; here, extremely low diabetes prevalence (0.61) and moderate GNI (contributing around –702) lead to a pronounced downward adjustment in risk.

For the Savannah region, the cumulative negative contributions from a moderately high GNI (–732) and low diabetes prevalence (–388), along with additional small reductions from temperature and CPI, yield the lowest predicted stroke count of around 35 cases. In contrast, the Bono region shows a moderately reduced risk, with a predicted value of approximately 702 cases. In this region, although GNI contributes a negative adjustment (–299), the effect from diabetes prevalence is less pronounced (–52.5), and both temperature and CPI exert only modest influences, leading to a less extreme overall reduction compared to regions where protective factors are stronger.

Ahafo is characterized by strong protective effects; the region exhibits a predicted stroke count of roughly 98 cases largely due to a robust negative influence from a high GNI (approximately –894) and a subsequent moderate reduction from its diabetes prevalence (–331), with a slight offset provided by a higher temperature. In Bono East, the situation is markedly different. Although the high GNI normally confers a substantial protective effect (around –1147), the extremely high diabetes prevalence in this region (7.27) significantly reverses the trend by contributing a strong positive effect (around +404), while a higher temperature also adds a moderate positive adjustment (approximately +110). As a result, the net effect is an increased stroke risk, culminating in a predicted count of around 653 cases.

In Figs. 7 and 8 (Appendix 1), we observe that for the Greater Accra region, the very low GNI value results in only a minimal protective impact; combined with an exceptionally high diabetes prevalence, which drives risk upward significantly, and average contributions from temperature and CPI, this results in a final model with a very high prediction, indicating strongly elevated stroke risk. In the Oti region, both the economic and health factors support a reduction in stroke risk; the moderate level of GNI and the low diabetes prevalence produce negative adjustments, along with additional minor contributions from CPI and temperature, resulting in a relatively low predicted stroke count of about 190 cases.

In Volta, while GNI and diabetes prevalence both contribute negative effects, the region’s notably low CPI may counterbalance these reductions slightly by elevating risk, leading to a predicted count of around 1689 cases. The Western region presents an intermediate scenario, where the relatively low GNI provides only a limited risk-reducing effect, and moderate diabetes prevalence further elevates risk to yield an overall prediction in the mid-range at approximately 877 cases. Similarly, Western North, where a moderate negative influence from GNI is offset by high diabetes prevalence, results in a final prediction of about 283 cases, suggesting that the adverse impact of diabetes is the dominant factor in that region.

The Upper West region benefits from a moderate GNI coupled with very low diabetes prevalence, leading to strong protective effects and a substantially reduced predicted stroke count of roughly 146 cases. In Upper East, a high GNI exerts a strong risk-lowering influence, and when combined with low-to-moderate diabetes prevalence, along with only small adjustments from temperature and CPI, the final prediction is noticeably low at around 325 cases. Conversely, Eastern, characterized by a low GNI that provides little protection and very high diabetes prevalence that strongly increases risk, exhibits one of the highest predicted stroke counts, approximately 4355 cases; here, the adverse effects from chronic disease overwhelm any modest protection from other variables. Finally, the Central region also shows an elevated risk profile, with a low GNI and moderate-to-high diabetes prevalence working together to raise the predicted stroke count to a very high 3107 cases, albeit not as high as in the Eastern Region.

Comments (0)

No login
gif