# Bayesian Modeling of Traffic Accident Rates in Poland Based on Weather Conditions
## 2 Materials and Methods
### Models  
Our approach to modeling traffic accident counts in Poland employs generalized linear models based on the Poisson distribution. The Poisson distribution is particularly suitable for modeling traffic accident counts as it is specifically designed for count data, where observations are non-negative integers representing the number of occurrences within a fixed interval. This distribution assumes events occur independently at a constant average rate, which aligns with the random nature of traffic accidents when aggregated across geographic areas or time periods. The Poisson distribution's characteristic property that its mean equals its variance often approximately holds for accident count data at appropriate scales of aggregation, making it a statistically sound choice for our analytical framework. The probability mass function of the Poisson distribution is given by:  
\[P(Y=k)=\frac{\lambda^{k}e^{-\lambda}}{k!} \tag{1}\]  
where \(k\) is the number of occurrences (accident counts in our case) and \(\lambda\) is the expected number of occurrences, which represents both the mean and variance of the distribution. \begin{table}
\begin{tabular}{l l} \hline \hline
**Variable Name** & **Description** \\ \hline _weekly\_mean\_temperature_ & Weekly average of daily mean temperatures across all counties (\({}^{\circ}\)C) \\ _weekly\_mean\_humidity_ & Weekly average of daily mean relative humidity across all counties (\%) \\ _weekly\_total\_precipitation_ & Total weekly precipitation across all counties (mm) \\ _yearly\_population\_density_ & National population density for the corresponding year (inhabitants/km\({}^{2}\)) \\ _yearly\_passenger\_cars_ & Total number of registered passenger vehicles nationwide \\ _yearly\_road\_density_ & National average of municipal and county paved roads per 100 km\({}^{2}\) \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Variables used in the weekly nationwide accident count modeling. Figure 2: Normalized distributions of weather factors used in nationwide weekly accident modeling. The histograms show (**a**) mean temperature (z-score normalized), (**b**) mean humidity (z-score normalized), and (**c**) total precipitation (log1p normalized). These distributions represent the aggregated weekly weather conditions across Poland during the 2020–2023 study period. Distributions of yearly variables were excluded from the figure as they offered little additional insight for the analysis. In our Poisson regression models, we relate parameter \(\lambda\) to our predictor variables through a logarithmic link function:  
\[\log(\lambda)=\eta=X\beta \tag{2}\]  
This log-link function ensures that the predicted values remain positive, which is essential since accident counts cannot be negative. The linear predictor \(\eta\) is composed of the predictor matrix \(X\) (containing weather or socioeconomic variables, or both) and the coefficient vector \(\beta\). We developed four distinct models, categorized by their temporal and spatial granularity: two models for yearly county-level analysis and two models for weekly nationwide analysis. Each model configuration was designed to address specific research questions regarding the relationship between weather conditions, socioeconomic factors, and traffic accident occurrence. The core of our Bayesian framework is captured in the following model structure:  
\[y_{i} \sim\text{Poisson}(e^{\eta_{i}})\] \[\eta_{i} =\alpha+X_{i}\beta \tag{3}\] \[\alpha \sim\text{Normal}(\mu_{\alpha},\sigma_{\alpha})\] \[\beta_{k} \sim\text{Normal}(0,\sigma_{\beta})\text{ for all }k\in K\]  
where \(y_{i}\) represents the observed accident count for observation \(i\), \(\eta_{i}\) is the log-rate parameter of the Poisson distribution, \(\alpha\) is the intercept term, and \(\beta\) contains the coefficients for each predictor. \(K\) represents the set of all predictors in our model, which may include weather variables, socioeconomic variables, or both, depending on the specific model configuration.