# Analysis of Instantaneous Energy Consumption and Recuperation Based on Measurements from SORT Runs
## 3 Results
### Knn  
For model (7), the prediction was estimated as the average value of the dependent variable for five neighbours for which the deviations between the vector of predictor values and the predictor results from the training set were the smallest in the norm \(\|\|_{2}\). The value of the coefficient of determination \(R^{2}\) for KNN equals 0.9251, slightly higher than for the linear model. For the KNN model (7), the residuals were analysed (see Figure 7). In Figure 7, we see the occurrence of extreme values in the series of residuals \(\{\epsilon_{t}\}_{1\leq t\leq n}\) and a significant correlation with lag \(\tau=1\). The Q-Q plot shows the existence of \"fat tails\". We also see significant differences between the theoretical distribution function with a normal distribution and the empirical distribution function. The tests examined the normality of the distribution of residuals using Shapiro-Wilk, Anderson-Darling, Cramer-von Mises, Lilliefors (Kolmogorov-Smirnov), the Jarque-Bera test, the D'Agostino omnibus tests and the independence of residuals using the Ljung-Box Test for shifts \(1\leq\tau\leq 10\). The Table 5 gives the values of the statistics and the value of the test probability. \begin{table}
\begin{tabular}{c c c} \hline
**Test** & **Statistics** & \(\boldsymbol{p}\)**-Value** \\ \hline Shapiro–Wilk normality test & 0.8356606 & \(<\)\(2\times 10^{-16}\) \\ [PERSON]–Darling test & 18.9269095 & \(<\)\(2\times 10^{-16}\) \\ Cramer–von Mises test & 3.7789377 & \(<\)\(2\times 10^{-16}\) \\ Lilliefors (Kolmogorov–Smirnov) test & 0.1837219 & \(<\)\(2\times 10^{-16}\) \\ Jarque–Bera test & 854.8074808 & \(<\)\(2\times 10^{-16}\) \\ D’Agostino Omnibus test & 152.8640000 & \(<\)\(2\times 10^{-16}\) \\ Ljung–Box test & 119.5279267 & \(<\)\(2\times 10^{-16}\) \\ \hline \end{tabular}
\end{table} 
Table 4: Results of normality tests and the correlation test for residuals of the linear model. Figure 6: Residuals analysis for linear model. Key trends and dependencies are shown by the residual analysis of the KNN model. While the histogram reveals that the residuals cluster around zero, suggesting a fairly unbiased forecast, it is clear that there are outliers and fat tails that cause the distribution to deviate from normal. The autocorrelation function shows a strong connection at lag 1, indicating that the residuals are not completely independent and show serial correlation. The absence of normalcy is supported by the normal Q-Q plot, especially at the extremities when the residuals deviate from the theoretical quantiles. The model seems to have a problem with residuals that are too high or too low. Consistent with previous findings in which the residuals do not strictly adhere to a normal distribution, the cumulative distribution function shows that the theoretical and empirical normal distributions differ. In general, the non-linear characteristics of the data are better captured by the KNN model than by the linear model; however, problems with residual independence and normalcy persist. These findings point to the necessity of investigating more sophisticated non-linear models, such as neural networks, or adding extra predictors to account for time lags in order to achieve better prediction accuracy. From the obtained results, we can see that, at the significance level of 0.05 based on Shapiro-Wilk, Anderson-Darling, Cramer-von Mises, Lilliefors (Kolmogorov-Smirnov), the Jarque-Bera test, and D'Agostino omnibus tests, the working hypothesis, which assumes normality of residuals, should be rejected in favour of the alternative hypothesis. Additionally, based on the Ljung-Box test, the hypothesis regarding the independence of residuals should be rejected (see also Figure 7, 'Autocorrelation function', which may mean that, at certain points during the test, additional power consumers may have been activated  
Figure 7: Residuals analysis for KNN model.