# The Effects of Train Passes on Dwell Time Delays in Sweden
## 3 Modelling with Odds Ratios and Logistic Regression
### Logistic Regression Model  
The model in this study is a logistic regression model that is created to contain the main effects of different types of train passes and with the occurrence of dwell time delays as the response. There is always a trade-off between the prediction performance and the underlying causal inference that must be taken into consideration when selecting a suitable model for the topic of study [24]. In this case, we opted for a simple statistical model, which can provide a better understanding of the relationship between parameters, instead of a more complex model. Other types of models might provide better predictive power but be more difficult to interpret.  
If \(x_{1},x_{2}\) are dummy variables representing cancelled and unscheduled passes, respectively, the model has the form:  
\[\log\biggl{(}\frac{\pi_{i}}{1-\pi_{i}}\biggr{)}=\beta_{0}+\beta_{1}x_{1}+\beta _{2}x_{2} \tag{8}\]  
In this model, the independent variable in this study was the type of pass, a categorical variable with three categories. Thus, two dummy variables were created, with trains in the category for scheduled pass as the reference group. This reference group was codedas zero in the data set, and odds ratios for other groups relative to the reference group were calculated. For the three scenarios we considered, the expressions for the logistic regressions are thus as follows:  
\[\log\text{Odds}(\text{Scheduled pass})=\quad\log\biggl{(}\frac{\pi_{0}}{1-\pi_{0}} \biggr{)}=\beta_{0}+0*\beta_{1}+0*\beta_{2}=\beta_{0} \tag{9}\]  
\[\log\text{Odds}(\text{Cancelled pass})=\log\biggl{(}\frac{\pi_{1}}{1-\pi_{1}} \biggr{)}=\beta_{0}+1*\beta_{1}+0*\beta_{2}=\beta_{0}+\beta_{1} \tag{10}\]  
\[\log\text{Odds}(\text{Unscheduled pass})=\log\biggl{(}\frac{\pi_{2}}{1-\pi_{2}} \biggr{)}=\beta_{0}+0*\beta_{1}+1*\beta_{2}=\beta_{0}+\beta_{2} \tag{11}\]  
Substituting and shifting these terms, we get the following:  
\[\begin{split}\beta_{1}&=\log\biggl{(}\frac{\pi_{1} }{1-\pi_{1}}\biggr{)}-\log\biggl{(}\frac{\pi_{0}}{1-\pi_{0}}\biggr{)}=\log \biggl{(}\frac{\frac{\pi_{1}}{1-\pi_{1}}}{\frac{\pi_{0}}{1-\pi_{0}}}\biggr{)} \\ &=\log\biggl{(}\frac{\text{Odds}\left(\text{Cancelled pass}\right)}{ \text{odds}\left(\text{Scheduled pass}\right)}\biggr{)}\end{split} \tag{12}\]  
\[\begin{split}\beta_{2}&=\log\biggl{(}\frac{\pi_{2} }{1-\pi_{2}}\biggr{)}-\log\biggl{(}\frac{\pi_{0}}{1-\pi_{0}}\biggr{)}=\log \biggl{(}\frac{\frac{\pi_{2}}{1-\pi_{2}}}{\frac{\pi_{0}}{1-\pi_{0}}}\biggr{)} \\ &=\log\biggl{(}\frac{\text{odds}\left(\text{Unscheduled pass} \right)}{\text{odds}\left(\text{Scheduled pass}\right)}\biggr{)}\end{split} \tag{13}\]  
The odds ratios can thus be expressed as:  
\[\text{Odds ratio}\left(\frac{\text{Cancelled pass}}{\text{Scheduled pass}} \right)=\text{e}^{\log\bigl{(}\frac{\text{Odds}\left(\text{Cancelled pass} \right)}{\text{Odds}\left(\text{Scheduled pass}\right)}\bigr{)}}=\text{e}^{ \beta_{1}} \tag{14}\]  
\[\text{Odds ratio}\left(\frac{\text{Unscheduled pass}}{\text{Scheduled pass}}\right)=\text{e}^{\log\bigl{(}\frac{\text{Odds}\left(\text{Unscheduled pass}\right)}{\text{Odds}\left(\text{Scheduled pass}\right)}\bigr{)}}=\text{e}^{\beta_{2}} \tag{15}\]