Model-based estimation of diarrhea risk and understanding the dependency on sociodemographic factors is important for prioritizing interventions. It is unsuitable to calibrate regression model with a single set of coefficients, especially for large spatial domains. For this purpose, we developed a Bayesian hierarchical varying coefficient model to account for non-stationarity in the covariates. We used the integrated nested Laplace approximation for parameter estimation. Diarrhea morbidities in Ghana motivated our empirical study. Results indicated improvement regarding model fit and epidemiological benefits. The findings highlighted substantial spatial, temporal, and spatio-temporal heterogeneities in both diarrhea risk and the coefficients of the sociodemographic factors. Diarrhea risk in peri-urban and urban districts were 13.2% and 10.8% higher than rural districts, respectively. The varying coefficient model indicated further details, as the coefficients varied across districts. A unit increase in the proportion of inhabitants with unsafe liquid waste disposal was found to increase diarrhea risk by 11.5%, with higher percentages within the south-central parts through to the south-western parts. Districts with safe and unsafe drinking water sources unexpectedly had a similar risk, as were districts with safe and unsafe toilets. The findings show that site-specific interventions need to consider the varying effects of sociodemographic factors.