# Two-Component Bayesian Hierarchical Models for Cost-Benefit Analysis of Traffic Barrier Crash [PERSON]
## 5 Model Syntax in JAGS  
All the modeling is conducted in the context of Bayesian method. \"Just another Gibbs sampler\" (JAGS) package in R was used for the modeling process [13]. The Poisson model has been used as a starting point for analyzing any count modeling. Thus, a Poisson model was considered with a log link between conditional mean as \(E(y_{i}|x_{i})=\lambda_{i}\), and linear predictor as \(\mu_{i}=\sum_{j}\beta_{j}X_{ij}\). In the syntax of the model, the two-part models should be defined explicitly: the first part distribution for the count model, and the second part as a logit model, Bernoulli distribution. Therefore, it is better to call this model a two-component model which could be applied as a hurdle or ZI model. For the ZI model, two distributions for the count part were considered: zero-inflated with negative binomial (ZINB), and Poisson (ZIP) distributions. In the model syntax, the distributions for the second model component, count model, should be defined. Compared with Poisson distribution, negative binomial (NB) distribution required more parametrization to have an acceptable form, making it suitable for modeling sparse dataset. This would be implemented on observation i with success parameter of p\({}_{i}\) and over-dispersion parameter of r, which is greater than 0. The success parameter can be written as follows:  
\[p_{i}=\frac{r}{r+\lambda_{i}} \tag{7}\]  
Figure 1: Two-component model methodological approach, ZINB. where \(\lambda_{i}\), similar to Poisson, is a conditional mean which could be written as follows:  
\[log\lambda_{i}=\sum_{j}\beta_{j}X_{ij} \tag{8}\]  
The above equation is similar to Equation (4), so no further explanation would be given. It should be noted that a prior value of r should be set in the syntax of the model in JAGS. A uniform prior was set for this value with an upper bound of 50, and a lower bound of zero. In the syntax of JAGS, the negative binomial success could be written as follows:  
\[p_{i}=\frac{r}{(r+1-zero_{part})\times\lambda_{i}} \tag{9}\]  
As can be seen from Equation (9), in general, if an observation does not belong to a zero part, the above equation would turn to the Equation (7) for Poisson distribution. A hierarchical model could be written as follows:  
\[\log\bigl{(}Y_{ij}\bigr{)}=\sum_{j=1}^{J}\sum_{p=1}^{p}(\beta_{0j}+\beta_{p}X_ {ij}) \tag{10}\]  
where \(Y_{ij}\) is a barrier crash EPDO for a certain barrier type, subscript i refers to an individual crash and subscript j refers to a hierarchies or levels, which is equal to the number of traffic barriers types as 3. For this study, p is the number of incorporated predictors in the count part. Here, as the random intercepts related to barrier type were considered only, the model coefficient would be similar across various barrier types, and only intercept would vary. Due to the absence of prior information about the included predictors in the analysis, non-informative priors were set. It has been shown in the literature review that a choice of non-informative prior distribution for a variance parameter can impact the inferences significantly [14]. Thus, in this study, for the included predictors, a standard choice of the normal distribution with mean of 0, and a very high variance of 100,000 were considered. As in the syntax, precision needs to be set which is \(\frac{1}{variance}\), this value is set in the Syntax. Furthermore, draws were obtained from 3 Markova Chain Monte Carlo (MCMC), with each chain consisting of 20,000 draw or iterations, in which 2500 of those draws were burned. Trace plot measures were used as measure for checking the mixing of the chains and estimates consistency across the chain. The identification of a best fit model is important as the finalist model would be used for cost-benefit analysis. The deviance information criterion (DIC) was used as measure for model comparisons [15]. This is a generalization of the Akaike information criterion (AIC) in the Bayesian context.