# Analysis of Instantaneous Energy Consumption and Recuperation Based on Measurements from SORT Runs
## 2 Materials and Methods
### Problem Formulation
#### 2.1.1 Linear Model  
In many cases, we describe the relationship between the dependent variable \(y\) and the features (predictors) \(x_{1},x_{2},\ldots,x_{k}\) using a linear model, as follows:  
\[y=\theta_{0}+\theta_{1}x_{1}+\theta_{2}x_{2}+\cdots+\theta_{k}x_{k}+\varepsilon _{i}, \tag{1}\]  
where the influence of external factors is described by a random variable with a normal distribution \(N\left(0,\sigma^{2}\right)\). To estimate the structural parameters \(\theta_{0},\theta_{1},\ldots,\theta_{k}\) based on the observation of the dependent variable \(\left\{y_{i}\right\}_{1\leq i\leq n}\) and the predictors \(\left\{\left(x_{11},x_{2},\ldots,x_{ik}\right)\right\}_{1\leq i\leq n}\) in model (1), we use the least squares method, for this purpose we define  
\[Y=\begin{bmatrix}y_{1}\\ y_{2}\\ \vdots\\ y_{n}\end{bmatrix},\quad X=\begin{bmatrix}1&x_{11}&x_{12}&\ldots&x_{1k}\\ 1&x_{21}&x_{22}&\ldots&x_{2k}\\ \vdots&\vdots&\vdots&&\vdots\\ 1&x_{n1}&x_{n2}&\ldots&x_{nk}\end{bmatrix}, \tag{2}\]  
where \(Y\in\mathbb{R}^{n}\), \(X\in\mathbb{R}^{n\times\left(k+1\right)}\).  
From the Gauss-Markov theorem, if \(\det\left(X^{T}X\right)\
eq 0\), then estimators of the unknown parameters in the model (1) are determined as follows:  
\[\hat{\theta}=\begin{bmatrix}\hat{\theta}_{0}\\ \hat{\theta}_{1}\\ \vdots\\ \hat{\theta}_{5}\end{bmatrix}=\left(X^{T}X\right)^{-1}X^{T}Y, \tag{3}\]  
The quantity \(\varepsilon_{i}=y_{i}-\hat{\theta}_{0}-\hat{\theta}_{1}x_{i1}-\hat{\theta}_{2 }x_{i2}-\cdots-\hat{\theta}_{k}x_{ik}\) denotes the differences between the empirical and predicted values \(1\leq i\leq n\) and \(\varepsilon=\left(\varepsilon_{1},\varepsilon_{2},\ldots,\varepsilon_{n}\right)\) denotes the vector of residuals, while the quantity \(\sigma^{2}=\frac{\varepsilon^{T}\varepsilon}{n-k-1}\) denotes the variance of residuals. To assess the influence of individual features on explaining the variability of the dependent variable, we estimate the covariance matrix of structural parameters \(S^{2}=\sigma^{2}\left(X^{T}X\right)^{-1}\) and the standard deviation of the structural parameter \(\theta_{i}\) is defined as \(S(\theta_{i})=\sqrt{S_{i+1,i+1}^{2}}\) for \(i\in\left\{0,1,...,k\right\}\).  
To assess the influence of individual features, at the significance level of \(\alpha=0.05\) for each structural parameter, we create a null hypothesis.  
\(H_{0}\): \(\theta_{i}=0\) (the influence of the \(i\)th factor on the dependent variable is insignificant) against the alternative hypothesis  
\(H_{1}\): \(\theta_{i}\
eq 0\) (with factor significantly influences the dependent variable).  
Statistics defining the ratio of the structural parameter \(\theta_{i}\) to the standard deviation of this parameter \(S_{\theta_{i}}\)  
\[t_{i}=\frac{\theta_{i}}{S_{\theta_{i}}}, \tag{4}\]  
has \(t\)-distribution with \((n-k-1)\) degrees of freedom, \(j=0,1,...,k\). For each parameter we determine the test probability.  
\[p_{i}=2*P(\,T>|t_{i}|), \tag{5}\]  
where \(T\) is a random variable with a t-distribution with \((n-k-1)\) degrees of freedom (in the case when model (1) does not have the intercept \(\theta_{0}\), then then the degrees of freedom is \(n-k\)). If \(p_{i}\geq\alpha\) then, at the significance level \(\alpha\), there is no ground to reject the hypothesis \(H_{0}\); therefore, the structural parameter is not significantly different from zero and the predictor has a non-significant impact on explaining the variability of the dependent variable. If \(p_{i}<\alpha\) then, at the significance level \(\alpha\), the null hypothesis \(H_{0}\) is rejected in favor of \(H_{1}\); therefore, the structural parameter is significantly different from zero and the predictor has a significant impact on explaining the dependent variable. Using stepwise regression, we select predictors that significantly influence the dependent variable and select a model by comparing the Akaike information criterion (AIC) value.  
\[AIC=2k+n\text{log}\sigma^{2} \tag{6}\]  
A smaller \(AIC\) value corresponds to a better fit of the model to the empirical data.