# Risk Propagation Mechanism and Prediction Model for the Highway Merging Area
## 5 Traffic Accident Risk Prediction Model
### Model Parameters  
The dataset in Section 4 is split into a training set (80%) and a validation set (20%). The mean squared error (MSE) function was used as the loss function to measure the error between the predicted and true values during LSTM model training. In the deep learning algorithm, calculating the difference between the learning results and the sample labels is an important step. The smaller the difference, the better the learning effect. This difference is the loss value. In this study, the MSE function was used as the loss function, which was suitable for solving regression problems and to evaluate the predictive performance of the model on the training and validation sets. The grid search method was used to determine the super parameter values of the LSTM model. The super parameter values of the model are shown in Table 4.  
\begin{table}
\begin{tabular}{c c c c c c c} \hline \hline
**Number of** & **Optimizer** & **Activation** & **Learning** & **Batch** & **Epoch** & **Dropout** \\
**Neurons.** & **Optimizer** & **Function** & **Rate** & **Size** & **Epoch** & **Dropout** \\ \hline
50 & ADAM & Sigmoid & 0.01 & 120 & 50 & 0.2 \\ \hline \hline \end{tabular}
\end{table}
Table 4: Parameter values of the model.  
\begin{table}
\begin{tabular}{c c} \hline \hline
**Variable Name** & **Explanation** \\ \hline Traffic\_flow\_all & Initial traffic volume in the simulation scenario \\ Speed\_1 & Average speed of vehicles passing through the first impact area \\ Speed\_2 & Average speed of vehicles passing through the second impact area \\ Speed\_3 & Average speed of vehicles passing through the third impact area \\ Traffic\_flow\_1 & Number of vehicles passing through the first impact area \\ Traffic\_flow\_2 & Number of vehicles passing through the second impact area \\ Traffic\_flow\_3 & Number of vehicles passing through the third impact area \\ RLL & Regional risk index for the first impact areas \\ RL2 & Regional risk index for the second impact areas \\ RL3 & Regional risk index for the third impact areas \\ Location & Categorical variable, 1 if the accident is in the merging areas, 0 otherwise \\ Lane1 & Categorical variable, 1 if the accident occurred in lane 1, 0 otherwise \\ Lane2 & Categorical variable, 1 if the accident occurred in lane 2, 0 otherwise \\ Lane3 & Categorical variable, 1 if the accident occurred in lane 3, 0 otherwise \\ Lane4 & Categorical variable, 1 if the accident occurred in lane 4, 0 otherwise \\ \hline \hline \end{tabular}
\end{table}
Table 3: Input variable and explanation.  
This study uses root mean square error (\(RMSE\)), mean squared error (\(MSE\)), and mean absolute error (\(MAE\)) [36] to evaluate the accuracy of the model (see Equations (12)-(14)).  
\[RMSE=\sqrt{\frac{1}{n}\sum_{i=1}^{n}(\hat{y}_{i}-y_{i})^{2}} \tag{12}\]  
\[MSE=\frac{1}{n}\sum_{i=1}^{n}(\hat{y}_{i}-y_{i})^{2} \tag{13}\]  
\[MAE=\frac{1}{n}\sum_{i=1}^{n}|\hat{y}_{i}-y_{i}| \tag{14}\]  
where \(y_{i}\) is the true value and \(\hat{y}_{i}\) is the predicted value.  
\(MSE\), \(RMSE\), and \(MAE\) are used in regression analysis to measure the difference between predicted and actual values. All three values fall into the interval \([0,+\infty)\), indicating that the difference cannot be negative, and a lower value indicates better model performance.