Crash Risk Assessment of O ﬀ -Ramps, Based on the Gaussian Mixture Model Using Video Trajectories

: The focus of this paper is the crash risk assessment of o ﬀ -ramps in Xi’an. The time-to-collision (TTC) is used for the measurement and cross-comparison of the crash risk of each location. Five sites from the urban expressway in Xi’an were selected to explore the TTC distribution. An unmanned aerial vehicle and a camera were used to collect tra ﬃ c ﬂow data for 20 min at each site. The parameters, including speed, deceleration rate, truck percentage, tra ﬃ c volume, and vehicle trajectories, were extracted from video images. The TTCs were calculated for each vehicle. The Gaussian mixture model (GMM) was proposed to predict the TTC probability density functions (PDFs) and cumulative density functions (CDFs) for ﬁve sites. The Kolmogorov–Smirnov (K-S) test indicated that the samples followed the estimated GMM distribution. The relationship between the crash risk level and inﬂuencing factors was studied by an ordinal logistic regression model and a naive Bayesian model. The results showed that the naive Bayesian model had an accuracy of 86.71%, while the ordinal logistic regression model had an accuracy of 84.81%. The naive Bayesian model outperformed the ordinal logistic regression model, and it could be applied to the real-time collision warning system.


Introduction
An urban expressway is a high-speed multi-lane highway with access ramps and median dividers. The expressway is an important component of the urban transportation system in China's major developed cities. The urban expressways have distinct features, such as short spacing between entrance or exit ramps, complex connections with frontage roads [1], and short deceleration lanes, which increase the probability of accidents. The off-ramps of urban expressways suffer from more crashes than other segments due to frequent, lane-changing behaviors. According to the crash report (Traffic Management Bureau, Ministry of Public Security 2017), there were 6116 crashes and 1472 fatalities on expressways in 2016. In addition, it was reported that urban expressway crashes make up 5.6% of total roadway crashes in Xi'an and resulted in 673,370 RMB of economic loss in 2011 [2]. In Shanghai, crashes at off-ramps accounted for 21.6% of total expressway crashes [3]. Actually, the crashes are likely to occur in the vicinity of ramps. Hence, it is very important to predict and evaluate the crash risk of ramps. However, the random circumstances, as well as various missing data increase the difficulty when it comes to the solid accuracy of safety evaluations.
Many factors play a role in the safety of off-ramps, including annual average daily traffic (AADT), ramp configurations, ramp lengths, deceleration lanes, acceleration lanes [4], and the number of lanes [1].

Data Collection
In order to explore the crash risks upstream from expressway off-ramps, we selected five sites from the urban expressway in Xi'an, which is a six-lane expressway, and the lane width is 3.75 m. The five sites are shown in Figure 1. The speed limit is 100 km/h for passenger cars and 80 km/h for trucks. The off-ramp influence area is 150 m past the ramp and 200 m before, and there is no on-ramp in this influence area. The investigated off-ramps are at straight and flat segments, connecting parallel to accesses. The length of the deceleration lane is 140 m. The traffic signs are placed at 2 km, 1 km, and 500 m away from exits. The vehicles are divided into passenger cars and trucks, according to "Technical Standard for Highway Engineering 2016". The vehicles for which the axis distance is greater than 3.8 m are trucks. Otherwise, the vehicles are considered as passenger vehicles. An unmanned aerial vehicle was used to collect traffic flow for 20 min at each site, from 2 December to 3 December, during the morning peak hour. Images were used from a camera mounted on a nearby pedestrian overcrossing.

Statistical Analysis of Traffic Flow
As mentioned earlier, the inner lane, middle lane, and outer lane are referred to as Lanes 1, 2, and 3, respectively. Vehicle trajectories were extracted from an unmanned aerial vehicle by Tracker at a frequency of 5 Hz. A one-second video was composed of 25 frames. The vehicle trajectories were extracted from the video images by the following steps: Step 1: A coordinate reference system was set up in the video to calculate vehicle positions at different times.
Step 2: In this study, the 3.75 m width of the lane was used to calibrate the position of vehicles with the ground plane.
As shown in Figure 2, the pedestrian overcrossing and the upper-bound road constituted a coordinate reference system. Figure 3 is the vehicle trajectories extracted from the video. The red  Each vehicle was considered as a pixel, and the vehicle was tracked automatically. We extracted 1552 trajectories as samples at off-ramps. An eight second video was used for analysis in the observation area. Because we calculated the vehicle position at 5 Hz, there were 40 position data for each trajectory record.
In this study, the Grubbs outlier test was used to detect the outliers based on the spot speed, as Equation (1). The outliners were removed from the trace data to eliminate the error and improve the accuracy. The missing data were replaced by the mean of the adjacent points to obtain a full trace.
The correctness of each sample was calculated as Equation (1).
Therefore, the correctness of the subsample was calculated as follows: The correctness of the total sample was 95.33%. This showed that the quality of the extracted data was sufficient to meet the modeling requirements.
The average speed, 85% speed, speed standard deviation (speed S.D.), and traffic volume for each lane are statistically summarized in Table 1. The traffic composition was calculated for Lane 3.  Each vehicle was considered as a pixel, and the vehicle was tracked automatically. We extracted 1552 trajectories as samples at off-ramps. An eight second video was used for analysis in the observation area. Because we calculated the vehicle position at 5 Hz, there were 40 position data for each trajectory record.
In this study, the Grubbs outlier test was used to detect the outliers based on the spot speed, as Equation (1). The outliners were removed from the trace data to eliminate the error and improve the accuracy. The missing data were replaced by the mean of the adjacent points to obtain a full trace.
The correctness of each sample was calculated as Equation (1).
Therefore, the correctness of the subsample was calculated as follows: The correctness of the total sample was 95.33%. This showed that the quality of the extracted data was sufficient to meet the modeling requirements.
The average speed, 85% speed, speed standard deviation (speed S.D.), and traffic volume for each lane are statistically summarized in Table 1. The traffic composition was calculated for Lane 3. Each vehicle was considered as a pixel, and the vehicle was tracked automatically. We extracted 1552 trajectories as samples at off-ramps. An eight second video was used for analysis in the observation area. Because we calculated the vehicle position at 5 Hz, there were 40 position data for each trajectory record.
In this study, the Grubbs outlier test was used to detect the outliers based on the spot speed, as Equation (1). The outliners were removed from the trace data to eliminate the error and improve the accuracy. The missing data were replaced by the mean of the adjacent points to obtain a full trace.
The correctness of each sample was calculated as Equation (1).
Therefore, the correctness of the subsample was calculated as follows: The correctness of the total sample was 95.33%. This showed that the quality of the extracted data was sufficient to meet the modeling requirements.
The average speed, 85% speed, speed standard deviation (speed S.D.), and traffic volume for each lane are statistically summarized in Table 1. The traffic composition was calculated for Lane 3. The speed S.D. of Lane 1 was higher than the other lanes, which illustrated larger speed gaps among vehicles. The 85% speed of Lane 3 was the lowest, usually below 40 km/h, due to the great impact that lane-changing had on it. The traffic volumes were between 697 veh/h and 919 veh/h. Traffic flow for Lane 2 was higher than the other lanes. The diverging rate described the proportion of exiting vehicles at the current off-ramp. Due to large residential communities, the diverging rates were higher at Site 1 and Site 4. The highest diverging rate as 19.27% at Site 4, and the lowest was 6.71% at Site 5. The truck percentage ranged from 6.25% to 23.8%. The speed decreased with the increased presence of trucks in the traffic flow.
The speed S.D. for the five sites of each lane is shown in Figure 4. It can be seen from Figure 4 that Lane 3 had the maximum speed S.D. and Lane 1 had the minimum speed S.D. at each location, which indicated that Lane 3 had a wider range of speed variation and a greater risk of crashes compared with other lanes.  The speed S.D. of Lane 1 was higher than the other lanes, which illustrated larger speed gaps among vehicles. The 85% speed of Lane 3 was the lowest, usually below 40 km/h, due to the great impact that lane-changing had on it. The traffic volumes were between 697 veh/h and 919 veh/h. Traffic flow for Lane 2 was higher than the other lanes. The diverging rate described the proportion of exiting vehicles at the current off-ramp. Due to large residential communities, the diverging rates were higher at Site 1 and Site 4. The highest diverging rate as 19.27% at Site 4, and the lowest was 6.71% at Site 5. The truck percentage ranged from 6.25% to 23.8%. The speed decreased with the increased presence of trucks in the traffic flow.
The speed S.D. for the five sites of each lane is shown in Figure 4. It can be seen from Figure 4 that Lane 3 had the maximum speed S.D. and Lane 1 had the minimum speed S.D. at each location, which indicated that Lane 3 had a wider range of speed variation and a greater risk of crashes compared with other lanes.

TTC Definition
TTC is defined as the time required for two vehicles to collide if they continue running at their present speed while on the same path [23]. The two vehicles are in a car-following state, as seen below in Figure 5. This indicator illustrates the crash risks in TTC.

TTC Definition
TTC is defined as the time required for two vehicles to collide if they continue running at their present speed while on the same path [23]. The two vehicles are in a car-following state, as seen below in Figure 5. This indicator illustrates the crash risks in TTC. TTC of off-ramps in the mainline can be calculated by using Equation (2), as shown below.
where TTCf (t) denotes the TTC of the following vehicle. Ll(t) denotes the position of the leading vehicle at a certain time t. Lf(t) denotes the position of the following vehicle at a certain time t. ll(t) denotes the length of the leading vehicle. Vl(t) denotes the speed of the leading vehicle. Vf(t) denotes the speed of the following vehicle. The distance between the rear of the leading vehicle and the front of the following vehicle can be represented as Ll(t) − Lf(t) − ll(t). The speed difference between the two vehicles can be represented as Vf(t) − Vl(t). Therefore, the TTC of individual vehicles can be calculated by this equation.

TTC Calculation
The lane-change process at off-ramps is show in Figure 6. TTC for each vehicle is calculated as Equation (2). The values of 15% TTC, 50% TTC, and 85% TTC are summarized in Table 2. TTC of off-ramps in the mainline can be calculated by using Equation (2), as shown below.
where TTC f (t) denotes the TTC of the following vehicle. L l (t) denotes the position of the leading vehicle at a certain time t. L f (t) denotes the position of the following vehicle at a certain time t. l l (t) denotes the length of the leading vehicle. V l (t) denotes the speed of the leading vehicle. V f (t) denotes the speed of the following vehicle. The distance between the rear of the leading vehicle and the front of the following vehicle can be represented as L l (t) − L f (t) − l l (t). The speed difference between the two vehicles can be represented as V f (t) − V l (t). Therefore, the TTC of individual vehicles can be calculated by this equation.

TTC Calculation
The lane-change process at off-ramps is show in Figure 6.

TTC Definition
TTC is defined as the time required for two vehicles to collide if they continue running at their present speed while on the same path [23]. The two vehicles are in a car-following state, as seen below in Figure 5. This indicator illustrates the crash risks in TTC. TTC of off-ramps in the mainline can be calculated by using Equation (2), as shown below.
where TTCf (t) denotes the TTC of the following vehicle. Ll(t) denotes the position of the leading vehicle at a certain time t. Lf(t) denotes the position of the following vehicle at a certain time t. ll(t) denotes the length of the leading vehicle. Vl(t) denotes the speed of the leading vehicle. Vf(t) denotes the speed of the following vehicle. The distance between the rear of the leading vehicle and the front of the following vehicle can be represented as Ll(t) − Lf(t) − ll(t). The speed difference between the two vehicles can be represented as Vf(t) − Vl(t). Therefore, the TTC of individual vehicles can be calculated by this equation.

TTC Calculation
The lane-change process at off-ramps is show in Figure 6. TTC for each vehicle is calculated as Equation (2). The values of 15% TTC, 50% TTC, and 85% TTC are summarized in Table 2. TTC for each vehicle is calculated as Equation (2). The values of 15% TTC, 50% TTC, and 85% TTC are summarized in Table 2. When comparing the TTCs of three lanes, the TTCs were distributed in a wider range in Lane 3. The 85% TTCs were smaller than 34.73 s for the expressway. The 50% TTCs ranged from 10.35 s to 29.67 s. The smaller TTCs indicated an increased probability of crash occurrences. The 15% TTCs of Lane 1 and Lane 2 were between 7.56 s and 23.65 s. The TTC of Lane 3 was significantly smaller than other lanes, since Lane 3 was disturbed by the interruption of vehicles merging from the other lane. The 15% TTCs ranged from 3.05 s to 9.03 s, which indicated that Lane 3 was more dangerous than the other lanes. TTC frequency distribution and TTC cumulative distribution are depicted in Figure 7a,b.  When comparing the TTCs of three lanes, the TTCs were distributed in a wider range in Lane 3. The 85% TTCs were smaller than 34.73 s for the expressway. The 50% TTCs ranged from 10.35 s to 29.67 s. The smaller TTCs indicated an increased probability of crash occurrences. The 15% TTCs of Lane 1 and Lane 2 were between 7.56 s and 23.65 s. The TTC of Lane 3 was significantly smaller than other lanes, since Lane 3 was disturbed by the interruption of vehicles merging from the other lane. The 15% TTCs ranged from 3.05 s to 9.03 s, which indicated that Lane 3 was more dangerous than the other lanes. TTC frequency distribution and TTC cumulative distribution are depicted in Figure 7a Figure 7b is the cumulative frequency of TTCs for all three lanes. For Lane 3, the 15% TTC, 50% TTC, and 85% TTC were 3.4 s, 7.5 s, and 16.7 s, respectively. For Lane 1 and Lane 2, TTC almost overlapped. The 15% TTC, 50% TTC, and 85% TTC were 3.3 s, 9.7 s, and 16.7 s, respectively. The 50% TTCs of Lane 1 and Lane 2 were greater than Lane 3.
Cross-sectional comparisons for the five sites are shown above in Figure 8. The smaller TTC indicated a higher risk of crash. The 15% TTC, 50% TTC, and 85% TTC for Site 1 and Site 4 were smaller than the other sites, which indicated a higher crash risk level. Therefore, Site 1 and Site 4 were more dangerous than the other three sites.   Figure 7b is the cumulative frequency of TTCs for all three lanes. For Lane 3, the 15% TTC, 50% TTC, and 85% TTC were 3.4 s, 7.5 s, and 16.7 s, respectively. For Lane 1 and Lane 2, TTC almost overlapped. The 15% TTC, 50% TTC, and 85% TTC were 3.3 s, 9.7 s, and 16.7 s, respectively. The 50% TTCs of Lane 1 and Lane 2 were greater than Lane 3.
Cross-sectional comparisons for the five sites are shown above in Figure 8. The smaller TTC indicated a higher risk of crash. The 15% TTC, 50% TTC, and 85% TTC for Site 1 and Site 4 were smaller than the other sites, which indicated a higher crash risk level. Therefore, Site 1 and Site 4 were more dangerous than the other three sites.

TTCs' Distribution Prediction with GMM
It is very important to understand the distribution of TTCs in danger determination. GMM is widely used in PDF estimation, which is a parametric PDF represented as a weighted sum of Gaussian component densities. The basic theoretical assumption is that an arbitrary distribution can be approximated by the weighted Gaussian models if there are enough Gaussian models. In this study, GMM was applied to explore the TTC distribution and capture the features for risk assessment

TTCs' Distribution Prediction with GMM
It is very important to understand the distribution of TTCs in danger determination. GMM is widely used in PDF estimation, which is a parametric PDF represented as a weighted sum of Gaussian component densities. The basic theoretical assumption is that an arbitrary distribution can be approximated by the weighted Gaussian models if there are enough Gaussian models. In this study, GMM was applied to explore the TTC distribution and capture the features for risk assessment without Sustainability 2020, 12, 3076 9 of 20 any distribution assumption. The PDF of the completed GMM is the sum of the sub-PDF described by Equation (3).
where the parameter TTC k is the TTC of the k th vehicle, which can be calculated by choosing a mixture weight ω i and p(TTC k µ i , σ 2 i ). ω i is between zero and one, which represents the percentage of the TTC belonging to category i. The total sum of ω i is 1. µ i is the mean vector. σ 2 i is the variance vector. GMM was used to estimate the PDF of TTC samples, and the estimated model was the sum of several Gaussian components with different probabilities ω i .
Each component density function is as Equation (4).
The complete GMM was parameterized by means, variances, and mixture weights from all components of Gaussian densities. Each sub-model is represented as λ = (ω i , µ i , σ i ). The number of sub-Gaussian models should be consistent with the crash risk levels.
The popular and well-known method for estimating the parameters of GMM is the maximum likelihood estimation (MLE). To train samples TTC i , the MLE function of GMM can be written as Equation (5).
The function L Θ TTC is called the likelihood of parameters given the training data. The likelihood is a function of Θ where the TTC value is fixed.
The expectation-maximization (E-M) algorithm iterates through two steps to obtain the estimation of parameters. The E-M algorithm is a general method of finding the maximum-likelihood estimation of parameters when the given data are incomplete or have missing values. The goal of the algorithm is to find the parameters that make L Θ TTC the largest. The two steps, the E-step and the M-step, are repeated until the maximum change in the estimation reaches convergence.
The condition of convergence is as Equation (6).
where ε is a random constant. In this study, the crash risks were divided into three levels: high, medium, and low. Therefore, three Gaussian sub-models were used to fit the TTCs' distribution. The iteration stop condition was 1 × 10 −15 . The confidence level of estimation was 95%.
The modeling process is shown in Figure 9. GMM was used to estimate the TTC distribution for five sites. The blue line represents the high risk level. The green line and red line represent the medium and low risk level.
The PDFs and CDFs for five sites are illustrated in Figures 10 and 11.
where ε is a random constant. In this study, the crash risks were divided into three levels: high, medium, and low. Therefore, three Gaussian sub-models were used to fit the TTCs' distribution. The iteration stop condition was 1 × 10 −15 . The confidence level of estimation was 95%.
The modeling process is shown in Figure 9.   The PDF indicated the probability of crash risk at a certain TTC value. The intersections of crossing curves in Figure 10 show the transition from high to medium risk. The place with a smaller TTC than the intersection had a greater probability at a high crash risk level, otherwise it had a greater probability at the medium crash risk level. Therefore, the TTC of the transition point on the PDF curves was considered as the threshold to distinguish high crash risk from medium crash risk.
The K-S test is a nonparametric test of the equality of continuous, one-dimensional probability distributions that can be used to compare a sample with a reference probability distribution. In statistics, the K-S test is applied to compare the TTC samples with the proposed GMM probability The PDF indicated the probability of crash risk at a certain TTC value. The intersections of crossing curves in Figure 10 show the transition from high to medium risk. The place with a smaller TTC than the intersection had a greater probability at a high crash risk level, otherwise it had a greater probability at the medium crash risk level. Therefore, the TTC of the transition point on the PDF curves was considered as the threshold to distinguish high crash risk from medium crash risk.
The K-S test is a nonparametric test of the equality of continuous, one-dimensional probability distributions that can be used to compare a sample with a reference probability distribution. In statistics, the K-S test is applied to compare the TTC samples with the proposed GMM probability distribution. The comparison was set at the 0.05 confidence level. The K-S sig. value shows that the null hypotheses is accepted, and the samples were drawn from the reference distribution as given in Table 3.  Table 4 is the theoretical estimation with GMM at a given percentage, and the severe crash thresholds are listed in the last column. The theoretical values of 15% TTC, 30% TTC, 50% TTC, and 85% TTC for the five sites were calculated. The severe crash risk thresholds obtained from the PDF curves for Sites 1 to 5 were 2.23 s, 6.71 s, 2.61 s, 2.29 s, and 2.60 s, respectively.
The 15% TTC, 50% TTC, and 85% TTC for Site 1 and Site 4 were smaller than the other sites. Comparing the crash risk thresholds with the 15% TTC, it was found that the severe crash risk thresholds obtained from the distribution density functions were smaller than the 15% TTC of the collected samples.
The small TTC indicated that the driver had a short time to take measures to avoid collisions. Therefore, crashes were likely to occur at Site 1 and Site 4 after TTC, and Site 2 was safer than other sites. The thresholds could also be used to warn about the collisions.

Crash Risk Modeling
The paper proposed an ordinal logical regression model and a naive Bayesian model with four variables including speed, speed S.D., traffic volume, and truck percentage.
TTC has been proven to be an effective indicator for rating the severity of crash risks. The crash risks were divided into three levels: high, medium, and low, according to the TTC thresholds in Table 4. The critical value for crash risk classification was determined by the derived PDFs. Combining with the results of previous research [40], the critical value for high risk was 2.7 s. When the TTC was between 0 and 2.7 s, the crash risk of off-ramps was high. The critical value for the medium risk was 4.7 s. When the TTC was between 2.7 and 4.7 s, the crash risk of off-ramps was medium; when the TTC was greater than 4.7 s, the crash risk of off-ramps was low.
Since not all vehicles on the mainline were required to enter the ramp, 158 samples were selected from 1552 trajectory samples to develop the models, including 69 samples with a low crash risk, Sustainability 2020, 12, 3076 13 of 20 44 samples with a medium risk, and 45 samples with a high risk. The following two conditions were considered when screening samples. The first one was that the vehicle was about to run out of ramp, and the second condition was that a collision had occurred, which was represented by a small TTC.
In order to test the validity of the model, 120 samples were randomly selected as the training dataset, and all samples were selected as the validation dataset. Meanwhile, the training datasets included 51 samples with a low crash risk, 27 samples with a medium risk, and 42 samples with a high risk. Before establishing the model, the relationship between the crash risks of off-ramps and four independent variables was analyzed separately, and the relationship between the crash risks of off-ramps and speed, traffic volume, speed S.D., and truck percentage was obtained, as shown in Figures 12-15 In order to test the validity of the model, 120 samples were randomly selected as the training dataset, and all samples were selected as the validation dataset. Meanwhile, the training datasets included 51 samples with a low crash risk, 27 samples with a medium risk, and 42 samples with a high risk. Before establishing the model, the relationship between the crash risks of off-ramps and four independent variables was analyzed separately, and the relationship between the crash risks of off-ramps and speed, traffic volume, speed S.D., and truck percentage was obtained, as shown in Figures 12-15, respectively.    In order to test the validity of the model, 120 samples were randomly selected as the training dataset, and all samples were selected as the validation dataset. Meanwhile, the training datasets included 51 samples with a low crash risk, 27 samples with a medium risk, and 42 samples with a high risk. Before establishing the model, the relationship between the crash risks of off-ramps and four independent variables was analyzed separately, and the relationship between the crash risks of off-ramps and speed, traffic volume, speed S.D., and truck percentage was obtained, as shown in Figures 12-15, respectively.    In order to test the validity of the model, 120 samples were randomly selected as the training dataset, and all samples were selected as the validation dataset. Meanwhile, the training datasets included 51 samples with a low crash risk, 27 samples with a medium risk, and 42 samples with a high risk. Before establishing the model, the relationship between the crash risks of off-ramps and four independent variables was analyzed separately, and the relationship between the crash risks of off-ramps and speed, traffic volume, speed S.D., and truck percentage was obtained, as shown in Figures 12-15, respectively.    It can be seen from Figure 13 that the impact of traffic volume on crash risk was relatively obvious. The lower crash risk corresponded to the smaller traffic volume, and the higher crash risk corresponded to the larger traffic volume. In addition, Figures 12, 14, and 15 illustrate that the impact of speed, speed S.D., and truck percentage on crash risk was not obvious.

The Ordinal Logistic Regression Model
In this study, the ordinal logistic regression model was used to describe the relationship between independent variables and ordinal response variables. It was based on the cumulative probability theory. The ordinal logistic regression model assumes that the dependent variable Y can be divided into ordinal g categories (Y = 1, 2, ..., g). X1, X2, …, Xm are independent variables. The ordinal logistic regression model is as Equation (7).
where is the constant term of the j th regression equation. is the regression coefficient of independent variable Xm .
There are g − 1 equations for the different categories of Y. The concept of the ordinal logistic regression model is to assume that the independent variables have the same influence on the odds ratio of cumulative probability. The regression coefficients of each variable in all equations are the same, and the differences in the cumulative probability of the different categories are depicted by the constant terms.
The corresponding probability of event occurrence is P1, P2, Pg for each category, and P1 + P2 + Pg = 1. Hence, the probability when Y = j is as Equation (8).
The value of Y means the crash risk level. Y = 1 indicates a low risk, and Y = 2 indicates a medium risk, while Y = 3 indicates a high risk.
The proportional odds assumption for the independent variables of the ordinal logistic regression is validated by the test of parallel lines. The test of parallel lines tests the proportional odds assumption for explanatory variables. The null hypothesis states that the slope coefficients in the model are the same across response categories.
The test results are shown in Table 5. In this case, = 4.351, P = 0.361, indicating that the regression equations were parallel to each other. Hence, the analysis could be carried out by the ordinal logistic regression model. It can be seen from Figure 13 that the impact of traffic volume on crash risk was relatively obvious. The lower crash risk corresponded to the smaller traffic volume, and the higher crash risk corresponded to the larger traffic volume. In addition, Figure 12, Figure 14, and Figure 15 illustrate that the impact of speed, speed S.D., and truck percentage on crash risk was not obvious.

The Ordinal Logistic Regression Model
In this study, the ordinal logistic regression model was used to describe the relationship between independent variables and ordinal response variables. It was based on the cumulative probability theory. The ordinal logistic regression model assumes that the dependent variable Y can be divided into ordinal g categories (Y = 1, 2, ..., g). X 1 , X 2 , . . . , X m are independent variables. The ordinal logistic regression model is as Equation (7).
where β 0 j is the constant term of the j th regression equation. β m is the regression coefficient of independent variable X m . There are g − 1 equations for the different categories of Y. The concept of the ordinal logistic regression model is to assume that the independent variables have the same influence on the odds ratio of cumulative probability. The regression coefficients of each variable in all equations are the same, and the differences in the cumulative probability of the different categories are depicted by the constant terms.
The corresponding probability of event occurrence is P 1 , P 2 , P g for each category, and P 1 + P 2 + P g = 1. Hence, the probability when Y = j is as Equation (8).
The value of Y means the crash risk level. Y = 1 indicates a low risk, and Y = 2 indicates a medium risk, while Y = 3 indicates a high risk.
The proportional odds assumption for the independent variables of the ordinal logistic regression is validated by the test of parallel lines. The test of parallel lines tests the proportional odds assumption for explanatory variables. The null hypothesis states that the slope coefficients in the model are the same across response categories.
The test results are shown in Table 5. In this case, χ 2 = 4.351, P = 0.361, indicating that the regression equations were parallel to each other. Hence, the analysis could be carried out by the ordinal logistic regression model. The ordinal logistic regression model was designed to explore the crash risk level and explanatory variables. The significance level of the model was set to the 95% confidence interval. The results showed the significance level of traffic volume and speed S.D. at 0.000 and 0.027, which were less than 0.05, indicating that these two independent variables could significantly affect the dependent variable. The significance level of speed and truck percentage at 0.062 and 0.502, which were greater than 0.05, indicated that the speed and truck percentage were less correlated with the dependent variable in this model. The ordinal logistic regression model results are shown in Table 6. Two variables including traffic volumes and speed S.D. were considered in the estimation model. The ordinal logistic regression showed that the proposed model could well evaluate the relationship between the crash risks of off-ramps and each independent variable. In addition, although the ordinal logistic regression model ignored the impact of speed and truck percentage on the crash risk, its accuracy was as high as 84.81%. The speed and truck percentage had a smaller impact on the crash risk than the other two independent variables, so they were ignored in the model.

The Naive Bayesian Model
The naive Bayesian model is a statistical method. Based on the Bayesian theorem and the independent hypothesis of characteristic conditions, it can predict the possibility between variables. The naive Bayesian model is characterized by high accuracy and high speed. It assumes that there is no interaction between any single attribute and classification result, which makes the calculation easier. In the study of traffic behavior, the Bayesian theorem can be applied to judge the probability of traffic behavior based on traffic flow.
According to the Bayesian rule, the conditional probability P(A|B) represents the possibility of event A occurring when B occurs. The calculation formula is as Equation (9).
where P(A) is the prior probability when A occurs. P(B) is the prior probability when B occurs. P(A|B) is the conditional probability of A after the occurrence of B, which is called the posterior probability of A. P(B|A) is the conditional probability of B after the occurrence of A, which is also called the posterior probability of B.
In the Bayesian rule, the denominator can be regarded as the normalized coefficient η, and Equation (10) can be obtained.
P(x y) = P(y x)P(x P(y) = ηP(y x)P(x),η = P(y) −1 = 1 If there is various observation information in traffic flow detection, it can be calculated by Equation (11).
The naive Bayesian model was established with variables such as speed, speed S.D., traffic volume, and truck percentage. The model was trained by 120 training datasets and validated by 158 datasets. The Bayesian naive model classification results are shown in Table 7. It was found that the naive Bayesian model could well evaluate the relationship between the crash risks of off-ramps and each independent variable. The established model was tested by the validation datasets, and the prediction accuracy was 86.71%, which ensured the efficiency of the naive Bayesian model. Traffic volume was one of the most common exposure variables in the previous analyses, and there was a significant positive relationship between traffic volume and crash risks of off-ramps. It could be seen from the naive Bayesian model that the relationship between crash risk and traffic volume was the most obvious. The average traffic volume corresponding to low crash risk, medium crash risk, and high crash risk was 108, 177, and 275, respectively.

Discussion
The ordinal logistic regression model and the naive Bayesian model were designed to explore the relationship between the crash risks of off-ramps and the explanatory variables including speed, speed S.D., traffic volume, and truck percentage.
When evaluating the fit of a model, the Akaike information criterion (AIC) and Bayesian information criterion (BIC) are usually used to analyze the model. The calculation formulas are shown in Equations (13) and (14). The AIC and the BIC are proposed to prevent overfitting problems when training the model. As the accuracy of the model continues to increase, the number of unknown parameters in the model will increase, and the model will become more complex, which will lead to overfitting problems. Therefore, an evaluation for model should consider both the accuracy of fitting and the number of unknown parameters. In general, smaller AIC and BIC show a good fitting.
where k is the number of model parameters, n is the number of samples, and L is the likelihood function. The MLE is used in the training model of ordinal logistic regression. After calculation, the AIC was 119.81, and BIC was 125.9352. The naive Bayesian model did not use the MLE in the training model, so AIC and BIC could not be calculated. Then, the prediction accuracy of the two models was compared and analyzed.
The ordinal logistic regression model considered speed S.D. and traffic volume, while the naive Bayesian model took four independent variables into account. The ordinal logistic regression model and the naive Bayesian model were tested with all 158 data, and the predicted results are shown in Tables 8 and 9. It can be observed from Tables 8 and 9 that the prediction accuracy of the two models was relatively high. The prediction accuracy of the ordinal logistic regression model was 84.81%, and the prediction accuracy of the naive Bayesian model was 86.71%. The naive Bayesian outperformed the ordinal logistic regression model.
In addition, both models had relatively low prediction accuracy for medium crash risk, which may be due to the similar sample data of medium crash risk and low crash risk.
An advanced crash warning system at off-ramps was designed based on the crash risk probability to enhance safety. The system integrating the model could predict the real-time crash risk level with real-time traffic flow information from loops including traffic volume, truck percentage, speed, and speed S.D. The system sends the warning signals according to the crash risk level. The framework of the system is as Figure 16. Sustainability 2020, 12, x FOR PEER REVIEW 18 of 20 Figure 16. The framework of the collision risk warning system.

Conclusions
The paper studied the TTC distribution of an urban expressway. The trajectories from the Xi'an expressway were collected by an unmanned aerial vehicle and a camera. After the analysis, the following conclusions were obtained.
1. The traffic flows of all sites were above 780 veh/h during rush hour. The 85% speed was approximately 38-49 km/h. The truck percentage was between 6.25% and 23.8%. 2. TTC decreased with increasing traffic volume, and was positive in the diverging rate, traffic volume, and speed deviation. 3. The TTC probability distributions of Lane 1 and Lane 2 were similar. The TTC of Lane 3 was smaller than Lane 1 and Lane 2. Due to the interaction of merging vehicles, the safety level of Lane 3 was lower than the other lanes. 4. The TTC distribution could be represented by three sub-Gaussian models. The smaller TTC indicated a greater probability of crash. The theoretical thresholds were considered as critical values for crash risk division. 5. Two prediction models of crash risks of off-ramps were proposed with four independent variables of speed, speed S.D., traffic volume, and truck percentage. The ordinal logistic regression model considered two independent variables, while the naive Bayesian model considered all independent variables.

Conclusions
The paper studied the TTC distribution of an urban expressway. The trajectories from the Xi'an expressway were collected by an unmanned aerial vehicle and a camera. After the analysis, the following conclusions were obtained.

1.
The traffic flows of all sites were above 780 veh/h during rush hour. The 85% speed was approximately 38-49 km/h. The truck percentage was between 6.25% and 23.8%.

2.
TTC decreased with increasing traffic volume, and was positive in the diverging rate, traffic volume, and speed deviation.

3.
The TTC probability distributions of Lane 1 and Lane 2 were similar. The TTC of Lane 3 was smaller than Lane 1 and Lane 2. Due to the interaction of merging vehicles, the safety level of Lane 3 was lower than the other lanes.

4.
The TTC distribution could be represented by three sub-Gaussian models. The smaller TTC indicated a greater probability of crash. The theoretical thresholds were considered as critical values for crash risk division.

5.
Two prediction models of crash risks of off-ramps were proposed with four independent variables of speed, speed S.D., traffic volume, and truck percentage. The ordinal logistic regression model considered two independent variables, while the naive Bayesian model considered all independent variables. 6.
The prediction accuracy of the ordinal logistic regression model was 84.81%, and the prediction accuracy of naive Bayesian model was 86.71%. The AIC and BIC of the ordinal logistic regression model were 119.81 and 125.9352. The naive Bayesian outperformed the ordinal logistic regression model.