[This article was first published on R Works, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)Want to share your content on R-bloggers? click here if you have a blog, or here if you don't. Data centers required to fuel the ambitions of Artificial Intelligence companies have sparked a nationwide conversation. AI companies are moving quickly to build out infrastructure and local communities are pushing back to resist what they see as the appropriation of public resources such as electricity and water to further enrich wealthy corporations. Moreover, the sentiment shared by both the political left and right is that data centers will significantly degrade the quality of life for those living adjacent to a data center and to the extended community as well. This post implements a non-trivial Bayesian Network to study the risks involved. I hope it is of some interest to a broad audience including, people interested in clarifying their thoughts about the risks that data centers may pose to their particular community and analysts curious about Bayesian Networks. However, I think the sample model built out in this post will be especially interesting to decision analysts who know quite a bit about Bayesian Networks but may be unfamiliar with the R programming language and unaware that there is capable opensource software which can provide capabilities beyond those offered by proprietary software systems.Other than addressing the topic of data center risks the analysis contains no original research except perhaps the contribution of ChatGPT 5.6 Luna which conjured up the innovative parts of the synthetic data generation algorithm from a series of requirements.Data Center RisksRational discussion about the perceived risks associated with the construction of data centers could benefit from a disciplined approach to organizing information and opinions into risk a analysis flexible enough to the consequences of complex interactions among risk factors. The Bayesian Network presented in this post is intended to be first step towards building such a tool.In general, the risks imposed by data centers fall into the following general categories. See Appendix C below for some references to investigative reporting supporting these risk categories.Electricity. A data center’s power demand can affect the immediate substation, the regional transmission system, and electricity rates for customers across a utility territory. The key questions are who pays for new generation and transmission, whether the facility has a dedicated rate, and whether its demand is flexible during shortages.Water. Water use depends heavily on cooling design, climate, server load, and the use of reclaimed water. The relevant impact area is often the watershed rather than the property boundary. During droughts, a data center may compete with households, agriculture, industry, and ecosystems.Land and housing. The facility itself may occupy hundreds of acres when parking, substations, cooling systems, security setbacks, and transmission corridors are included. Construction can remove farmland or open space, while the associated workforce and infrastructure can increase housing demand.Noise and air quality. The most immediate quality-of-life impacts are usually construction activity, cooling-system noise, transformer hum, generator testing, lighting, and occasional diesel emissions. These effects decline with distance but can remain significant for nearby homes, schools, and outdoor spaces.Grid reliability and affordability. A data center can bring grid upgrades that improve regional infrastructure, but rapid demand growth can also strain generation and transmission. If costs are not assigned directly to the facility, residential and small-business customers may absorb part of them.Governance and fairness. The distance framework should be paired with an equity analysis: who receives jobs, tax revenue, and infrastructure improvements, and who experiences noise, land loss, water competition, higher rates, or pollution? Community-benefit agreements, transparent resource-demand disclosures, enforceable noise and water standards, and clear cost-recovery rules can substantially change the outcome.Potential BenefitsSupporters of data centers emphasize the potential benefits of building a data center. These may include increased tax revenue and increased temporary employment. However, most of the reporting referenced below indicates that they do not compensate for the risks.Organizing the risks and benefitsModel building begins by organizing nodes into a a Directed Acyclic Graph (DAG) with arrows pointing from root nodes which are thought to drive other nodes that represent factors that intensify risk. Eventually the information in these nodes flow to nodes which quantify different kinds of risk. Finally the information from the risk nodes flow into a node that quantifies overall community risk. The following graph expands on the general categories listed above, enumerates a number of risk factors with arrows indicating the direction influence or causality. The names of the nodes are for the most part self explanatory. Note that the scale of the data center and distance from the data center are fundamental factors driving risk.The number of nodes in this graph are probably much larger than would be required for an exploratory mode. However, I have elected to go with the larges list that seemed to me to be reasonable and coherent in order to provide an example that is more complex than a typical “toy” mode. And since it is usually much easier to remove code than add it, the model below should be useful in deriving a more parsimonious custom model.%%| label: fig-risk-network%%| fig-cap: "Data Center Risk Network"%%| fig-alt: "Directed network showing data-center impacts and risks leading to overall community risk."flowchart LR Scale --> LandFootprint Scale --> ElectricityDemand Scale --> WaterDemand Scale --> ConstructionIntensity Scale --> BackupGeneration Scale --> WorkforceDemand Scale --> NoiseExposure Scale --> AirQualityExposure Scale --> AccessToBenefits Scale --> EconomicBenefit Cooling --> WaterDemand Cooling --> NoiseExposure Distance --> NoiseExposure Distance --> AirQualityExposure Distance --> TrafficExposure Distance --> VisualLandUseExposure Distance --> AccessToBenefits Distance --> ElectricityCostRisk LandFootprint --> VisualLandUseExposure ConstructionIntensity --> TrafficExposure BackupGeneration --> AirQualityExposure ElectricityDemand --> GridStress GridCapacity --> GridStress GridStress --> ElectricityCostRisk GridStress --> ReliabilityRisk WaterDemand --> WaterCompetition WaterAvailability --> WaterCompetition WaterCompetition --> WaterSecurityRisk Vulnerability --> WaterSecurityRisk WorkforceDemand --> HousingPressure HousingAvailability --> HousingPressure WorkforceDemand --> ServicePressure HousingAvailability --> ServicePressure LandFootprint --> EnvironmentalDegradation WaterDemand --> EnvironmentalDegradation WaterAvailability --> EnvironmentalDegradation NoiseExposure --> QualityOfLifeRisk AirQualityExposure --> QualityOfLifeRisk TrafficExposure --> QualityOfLifeRisk VisualLandUseExposure --> QualityOfLifeRisk HousingPressure --> QualityOfLifeRisk Vulnerability --> QualityOfLifeRisk AccessToBenefits --> EconomicBenefit QualityOfLifeRisk --> OverallCommunityRisk WaterSecurityRisk --> OverallCommunityRisk ElectricityCostRisk --> OverallCommunityRisk ReliabilityRisk --> OverallCommunityRisk EnvironmentalDegradation --> OverallCommunityRisk HousingPressure --> OverallCommunityRisk ServicePressure --> OverallCommunityRisk EconomicBenefit --> OverallCommunityRiskThe DAGThe code below builds a discrete Bayesian Network based on the above directed acyclic graph using bnlearn package.Required packages and helper functions# ============================================================# Bayesian Network for Data-Center Community Risk# ============================================================# Install packages once if necessary:# install.packages(c("bnlearn", "ggplot2"))library(bnlearn)library(ggplot2)library(Rgraphviz)library(igraph)library(dplyr)library(tidyr)library(ggridges)library(ggtern)# ------------------------------------------------------------# 2. Helper functions for generating categorical variables# ------------------------------------------------------------# sample_category Some DAG StatisticsThere are a few statistics that may provide some insight into the structure of a Bayesian Network.Average Markov Blanket SizeIn a Bayesian network, a Markov blanket of a target variable consists of the variable’s parent nodes, child nodes, and spouses child nodes, the other parents of the children. These are the nodes that determine the target variables behavior. In general a smaller value for average Markov blanket size indicates a sparse network and lower computational complexity (the computational power required for probabilistic inference)Average Branching FactorThe branching factor of a node is equal to the number of direct children. The Average Branching Factor is the total number of directed edges divided by the total number of nodes. This may be interpreted as the average spread of downstream influence.Average Neighborhood SizeThe neighborhood of a node consists of both its direct parents and its direct children, treating the graph as undirected. Average neighborhood size is the average number of incoming and outgoing connections.This block of codes computes these statistics, which may be useful in comparing variations of the network.Network Statistics Calculations#library(bnlearn)# dag should be a bnlearn network created with model2network(),# empty.graph(), hc(), tabu(), gs(), etc.node_names