# Modeling of Water Losses in Hydraulic Tunnels under Pressure Based on Stepwise Regression Method
## 3 Methodology for Modeling of Total Water Losses in Hydraulic Tunnels
### Modelling  
A key issue in creating the model in the form of multiple linear regression (Figure 1, block 3) is the selection of appropriate regressors, considering both the number and type of regressors. To solve this problem, we engaged the method of stepwise regression. In an iterative procedure, the techniques from this method performed automated entering and removing of regressors, thus creating optimal regression models.  
At this stage, we defined the following steps:  
* Dividing the available data into subgroups: learning dataset (LDS) and test dataset (TDS), according to the given ratio (3a);
* Generating regression models based on LDS during the iterative procedure, using the stepwise regression method with multiple model selection methods: backward, forward, and stepwise (3b). Each of these methods employs additional criteria for entry and removal of regressors. The backward method starts with all regressors in the model, and iteratively performs the removal of regressors based on the criterion of F-statistic and corresponding \(p\)-values (probability of F), until no further regressors can be removed without a statistically significant loss of accuracy. This method produced the subset of regression models \(\rho_{\text{MLRJ}}\). The forward method starts with zero regressors in the model, and iteratively performs entry of regressors, also based on the criterion of F-statistic and their \(p\)-values. The procedure stops when there are no variables that meet the entry criterion and generates the subset of regression models \(\rho_{\text{MLR2}}\). The stepwise method is a combination of the backward and forward selection methods. This method terminates when no more regressors are eligible for entry or removal based on the chosen criterion. In our methodology, the stepwise method generates four subsets of MLR models (\(\rho_{\text{MLRJ}}\), \(\rho_{\text{MLRJ}}\), \(\rho_{\text{MLRJ6}}\)), based on four different criteria for entry and removal of regressors. These criteria are: F-statistic (F-statisticmaximum for entry, F-statistic minimum for removal), maximum adjusted coefficient of determination \(\mathbb{R}^{2}\), minimum corrected Akaike information criterion (AICC), and minimum average squared error over the overfitting prevention data (ASE). The mentioned criteria are explained in detail in [31];
* Selecting the best MLR model of HT water losses, from MLR\(\chi\) models \(\chi=1,m\), based on the chosen accuracy criterion (3d). Various indicators can be selected as criteria for assessing model accuracy. One of them is the root mean squared error (RMSE). In our methodology, RMSE for the test dataset, \(\text{RMSE}^{(\text{TDS})}\), was chosen as the accuracy criterion, and is calculated according to (6): \[\text{RMSE}^{(\text{TDS})}=\sqrt{\frac{\sum_{i=1}^{n}\left(q_{i}-\hat{q}_{i} \right)^{2}}{n}},\] (6) where \(q_{i}\) and \(\hat{q}_{i}\) represent the measured and predicted values of total water losses in HT for the ith record from the TDS, respectively. The model with the \(\text{RMSE}^{(\text{TDS})}\), calculated according to (7): \[\text{RMSE}^{(\text{TDS})}_{\text{BEST}}=min(\text{RMSE}^{(\text{TDS})}_{ \chi},\chi=1,m),\] (7) was chosen as the best model, denoted as MLR\({}_{\text{BEST}}\).  
If MLR\({}_{\text{BEST}}\) is satisfactory, in comparison to some previously developed reference model of HT water losses, in terms of complexity and accuracy, or some other criteria arbitrarily chosen by the researcher, our methodology follows up with the regression analysis activity. Otherwise, we should return to block 2, and repeat the methodology stages, starting with (2.1), redefining the pool of potential predictors and their ranges, and/or redefining principal components in (2.3).