## 2 Methodology
### The Bayesian Technique  
The Bayesian hierarchical model with j levels is defined with three probabilistic levels [10]: those include the data model corresponding to observations \(y_{j}=\left\{y_{j},\ldots,y_{j}\right\}\), the process model considering the parameters \(\theta_{j}\) of the NB where \(\theta_{j}=\left(\beta_{j},\psi_{j}\right)\), and the parameter model setting a probabilistic distribution on the \(\theta_{j}\) hyperparameter of \(\gamma_{j}\) as \(\pi(\gamma_{j}|\rho)\). Here, \(\rho\) is the correlation or dependency across various hierarchies. The parameters of \(\beta_{j},\psi_{j}\) with normal and gamma distributions, respectively, could be written as follows:  
\[\beta_{j}\sim N\left(m_{j},\
u_{j}\right) \tag{9}\]  
\[\psi_{j}\sim Gamma\left(k_{j},\Theta_{j}\right) \tag{10}\]  
where \(m_{j},\
u_{j}\) are normal distribution parameters of mean and variance, respectively, and \(k_{j},\Theta_{j}\) are shape and scale parameters, respectively, of the gamma distribution. Now the discussed hyperparameter \(\gamma_{j}\) can be written based on:  
\[\gamma_{j}=\left(m_{j},\
u_{j},k_{j},\Theta_{j}\right) \tag{11}\]  
As the hierarchy in this study was set up for only intercept, and the priors would be set for each predictor coefficient. The term \(\psi_{j}\) is set as the gamma distribution as it adjusts dispersion through degree and scale parameters [11]. Gibbs sampling is implemented for generating \(\gamma_{j}\) parameters, coefficients and dispersion parameters. For instance, for iteration \(r\) = 1,2,..., there would be:  
\[\beta_{j}^{r+1}\left(\beta_{j}^{r},\psi_{j}^{r},m_{j}^{r},\
u_{j}^{r},k_{j}^{ r},\Theta_{j}^{r}\right)\sim\prod_{i=1}^{n}NB(y_{ij}|\beta_{j}^{r+1},\psi_{j}^{r})N( \beta_{j}^{r+1}|m_{j}^{r+1},\
u_{j}^{r+1}) \tag{12}\]  
\[\psi_{j}^{r+1}\left(\beta_{j}^{r},\psi_{j}^{r},m_{j}^{r},\
u_{j}^{r},k_{j}^{ r},\Theta_{j}^{r}\right)\sim\prod_{i=1}^{n}NB(y_{ij}|\beta_{j}^{r+1},\psi_{j}^{r+1 })\mathbb{G}(\psi_{j}^{r+1}|k_{j}^{r+1},\Theta_{j}^{r+1}) \tag{13}\]  
where \(N\) and \(\mathbb{G}\) are normal and gamma distributions, respectively. As can be seen from the above equations, as a combination of \(NB\) and \(N\) or Gamma cannot be calculated easily, applications of sampling methods necessitate the identification of those parameters. Model Syntax in JAGS  
In the Bayes method, the posterior probability, \(P(\beta|Y,X)\) of the coefficients are conditioned and are written as follows:  
\[P(\beta|Y,X)=\frac{p(y|\beta,x)*P(\beta|x)}{P(y|x)} \tag{14}\]  
where \(P(\beta|X)\) is the prior probability of the model parameters. Another characteristic of the Bayes method compared with maximum likelihood is the Bayes method assumes that the response is drawn from a probability distribution rather than a point estimate. In the model syntax, the count model should be defined. The NB distribution, compared with the Poisson distribution, requires more parameterizations to have a form making it suitable for modeling sparse datasets. This would be implemented on observation \(i\) with the success parameter \(\text{p}_{i}\) and the overdispersion parameter \(r\), which is greater than 0. The success parameter is written as follows:  
\[p_{i}=\frac{r}{r+\lambda_{i}} \tag{15}\]  
where \(\lambda_{i}\) is a conditional mean which is written as:  
\[log\ \lambda_{i}=\sum_{j}\beta_{j}X_{ij} \tag{16}\]  
A uniform prior was set for parameter \(r\) with an upper bound of 50, and a lower bound of zero. A hierarchical model with only random intercepts is written as follows:  
\[\log\bigl{(}Y_{ij}\bigr{)}=\sum_{j=1}^{J}\sum_{p=1}^{p}(\beta_{0j}+\beta_{p}X _{ij}) \tag{17}\]  
where \(Y_{ij}\) is a barrier EPDO count for a certain type of barrier. Subscript \(i\) refers to an individual crash, while subscript \(j\) refers to the hierarchy, which is equal to the number of objective hierarchies (clusters) as 4. For this study, \(p\) is the number of incorporated predictors in the count part.