Nizan Zioni: Question 5
To what extent do the road lighting conditions, the time of week (mid-week/weekend), weather conditions, and the volume of vehicles on the road (the explanatory variables) influence the severity of the accident (the dependent variable)?
For this question, We’ve used 2 datasets from the UK, between the years 2005-2010
Descriptive Statistics:

## .
## Darkness Lighting: Unknown Darkness Lights Lit
## 19 3063
## Darkness Lights unlit Darkness No Lighting
## 30 7
## Daylight
## 6881


| 1 |
8811 |
88.11 |
88.11 |
88.11 |
88.11 |
| 2 |
1001 |
10.01 |
98.12 |
10.01 |
98.12 |
| 3 |
54 |
0.54 |
98.66 |
0.54 |
98.66 |
| 4 |
18 |
0.18 |
98.84 |
0.18 |
98.84 |
| 5 |
8 |
0.08 |
98.92 |
0.08 |
98.92 |
| 6 |
1 |
0.01 |
98.93 |
0.01 |
98.93 |
| 7 |
16 |
0.16 |
99.09 |
0.16 |
99.09 |
| 8 |
65 |
0.65 |
99.74 |
0.65 |
99.74 |
| 9 |
26 |
0.26 |
100.00 |
0.26 |
100.00 |
|
0 |
NA |
NA |
0.00 |
100.00 |
| Total |
10000 |
100.00 |
100.00 |
100.00 |
100.00 |
| Mean |
1.803300e+00 |
| Std.Dev |
6.858981e-01 |
| Min |
1.000000e+00 |
| Q1 |
1.000000e+00 |
| Median |
2.000000e+00 |
| Q3 |
2.000000e+00 |
| Max |
8.000000e+00 |
| MAD |
0.000000e+00 |
| IQR |
1.000000e+00 |
| CV |
3.803572e-01 |
| Skewness |
1.733886e+00 |
| SE.Skewness |
2.449120e-02 |
| Kurtosis |
1.097654e+01 |
| N.Valid |
1.000000e+04 |
| Pct.Valid |
1.000000e+02 |
| Darkness Lighting: Unknown |
19 |
0.19 |
0.19 |
0.19 |
0.19 |
| Darkness Lights Lit |
3063 |
30.63 |
30.82 |
30.63 |
30.82 |
| Darkness Lights unlit |
30 |
0.30 |
31.12 |
0.30 |
31.12 |
| Darkness No Lighting |
7 |
0.07 |
31.19 |
0.07 |
31.19 |
| Daylight |
6881 |
68.81 |
100.00 |
68.81 |
100.00 |
|
0 |
NA |
NA |
0.00 |
100.00 |
| Total |
10000 |
100.00 |
100.00 |
100.00 |
100.00 |
| 1 |
1065 |
10.65 |
10.65 |
10.65 |
10.65 |
| 2 |
1421 |
14.21 |
24.86 |
14.21 |
24.86 |
| 3 |
1510 |
15.10 |
39.96 |
15.10 |
39.96 |
| 4 |
1599 |
15.99 |
55.95 |
15.99 |
55.95 |
| 5 |
1514 |
15.14 |
71.09 |
15.14 |
71.09 |
| 6 |
1553 |
15.53 |
86.62 |
15.53 |
86.62 |
| 7 |
1338 |
13.38 |
100.00 |
13.38 |
100.00 |
|
0 |
NA |
NA |
0.00 |
100.00 |
| Total |
10000 |
100.00 |
100.00 |
100.00 |
100.00 |
| 1 |
3076 |
30.76 |
30.76 |
30.76 |
30.76 |
| 2 |
6081 |
60.81 |
91.57 |
60.81 |
91.57 |
| 3 |
675 |
6.75 |
98.32 |
6.75 |
98.32 |
| 4 |
117 |
1.17 |
99.49 |
1.17 |
99.49 |
| 5 |
32 |
0.32 |
99.81 |
0.32 |
99.81 |
| 6 |
5 |
0.05 |
99.86 |
0.05 |
99.86 |
| 8 |
14 |
0.14 |
100.00 |
0.14 |
100.00 |
|
0 |
NA |
NA |
0.00 |
100.00 |
| Total |
10000 |
100.00 |
100.00 |
100.00 |
100.00 |
Inferential Statistics
## [1] "Chi Square and kramer's correlation:"
##
## Pearson's Chi-squared test
##
## data: data_inference$weather and data_inference$accident_severity
## X-squared = 3.7588, df = 2, p-value = 0.1527
## Warning in chisq.test(data_inference$number_of_vhcls,
## data_inference$accident_severity): Chi-squared approximation may be incorrect
##
## Pearson's Chi-squared test
##
## data: data_inference$number_of_vhcls and data_inference$accident_severity
## X-squared = 107.32, df = 6, p-value < 2.2e-16
##
## Pearson's Chi-squared test with Yates' continuity correction
##
## data: data_inference$weekend and data_inference$accident_severity
## X-squared = 0.85156, df = 1, p-value = 0.3561
Conclusions:
For Light conditions and accident severity indication: association is significant. For weather conditions and accident severity indication: association is not significant. For Number of Vehicles and accident severity indication: association is significant. For Weekend / weekday indication and accident severity indication: association is non-significant.
Logistic Regression
##
## Call:
## glm(formula = accident_severity ~ weather + weekend + number_of_vhcls,
## family = "binomial", data = data_inference)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.6089 -0.5403 -0.4701 -0.4550 2.9735
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -1.48496 0.09867 -15.050 < 2e-16 ***
## weatherOther 0.04935 0.23027 0.214 0.8303
## weatherRain without high wind 0.19045 0.10039 1.897 0.0578 .
## weekendweekend 0.06890 0.06485 1.062 0.2881
## number_of_vhcls -0.36548 0.05248 -6.964 3.32e-12 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 7005.2 on 9999 degrees of freedom
## Residual deviance: 6948.5 on 9995 degrees of freedom
## AIC: 6958.5
##
## Number of Fisher Scoring iterations: 5
| (Intercept) |
0.227 |
| weatherOther |
1.051 |
| weatherRain without high wind |
1.210 |
| weekendweekend |
1.071 |
| number_of_vhcls |
0.694 |
| 0.1597645 |
| 0.1358222 |
| 0.0983310 |
| 0.1441138 |
| 0.1358222 |
| 0.1165558 |
Discussion and conclusion from the logistic regression results:
According to the logistic regression results, it can be concluded that the variables: light = daylight and number of vehicles, are significant. On top of that, based upon the odds-ratio measure, we found that day-light reduced the probability to a severe accident to 78.2% of an accident not in daylight. Also we’ve found that the more vehicles involved in a car accident, the less chance for a severe car accident. specifically - the every can involved in a car accident, the chance for a severe car accident reduces to 69.5%.
As for the confusion matrix, according to the prediction procedure, none of the observations, yielded into an event (in other words - for all observations severe accident = 0). To handle this, we’ve chosen to split the predicted results by the 90th percentile, which indicates 90% chance for a non-sever accident. the relevant value is 0.15155 which is 15.155%. In other words - 90% of the observations generate a prediction probability of no more than 15.155%.
## Confusion Matrix and Statistics
##
## Reference
## Prediction 0 1
## 0 8603 1063
## 1 279 55
##
## Accuracy : 0.8658
## 95% CI : (0.859, 0.8724)
## No Information Rate : 0.8882
## P-Value [Acc > NIR] : 1
##
## Kappa : 0.0256
##
## Mcnemar's Test P-Value : <2e-16
##
## Sensitivity : 0.96859
## Specificity : 0.04919
## Pos Pred Value : 0.89003
## Neg Pred Value : 0.16467
## Prevalence : 0.88820
## Detection Rate : 0.86030
## Detection Prevalence : 0.96660
## Balanced Accuracy : 0.50889
##
## 'Positive' Class : 0
##
Based upon the confusion matrix - there’s the following table:
