## 5 Design of Prediction Model
### Submodel Linear Regression (LinR)  
This model attempts to include influences of other factors in the prediction. Provided that there are enough representative cases available in the subset for a given hour in a given segment (see the similarity function \(\Phi(i\), _hour_) above), we use multiple linear regression with vector \(\mathrm{x_{i}}\) of explanatory variables and dependent variable \(\mathrm{y_{i}}\). \[\forall i=1\dots n_{h}{}^{*}:\overset{\rightarrow}{\alpha}.\overset{ \rightarrow}{x}_{i}+\varepsilon_{i}=y_{i} \tag{2}\]  
where  
\(n_{h}{}^{*}\) is number of records from history for which it applies \(\Phi(i\), _hour_) = 1 (see above);  
\(\overset{\rightarrow}{x}_{i}=[1,\mathit{Trend}_{i},\sin(\mathit{Season}_{i}),\cos(\mathit{Season}_{i}),\mathit{Sun}_{i}]\) where  
\(\mathit{Trend}_{i}\) is order number of the day (calculated as of 1 January 2020),  
\(\mathit{Season}_{i}\) = 2 \(\times\)\(\Pi\)\(\times\)\(\mathit{DayOfYearIndex}(S_{i})/365\) is normalized order number of the day in the year, and  
\(\mathit{Sun}_{i}\) is fuzzy function providing the coefficient of sun-above-the-horizon period for the hour of i-_th_ record as follows:  
\(\langle\)0;1\(\rangle\)\(\dots\) for the period of 60 min before and upon sunrise as at HH:30,  
\(\langle\)0;1\(\rangle\)\(\dots\) for the period of 60 min before and upon sunset as at HH:30,  
otherwise, 0 if the sun is below the horizon and 1 if sun is above the horizon for the entire hour;  
\(y_{i}=\frac{S_{i}}{\mathit{FreeFlowSpeed}}\) is relative average hourly speed. Dividing by the value of the _FreeFlowSpeed_ does not affect the prediction quality. Instead, it only ensures that the calculated regression coefficients are mutually comparable between the individual _TMC segments_;  
\(\varepsilon_{i}\) is random file (prediction error). The vector on the left side is currently created by the following components: Mean value, trend, season, and information on whether the sun is above the horizon (see Section 3.1). The last component solely applies to hours where there is a change during the course of the year between the summer and winter solstice, e.g., it will be completely dark outside at 7 p.m. in the winter, yet the sun will be well above the horizon in the summer. As opposed to that, at noon and at midnight hours, this vector component contains only the same values and is thus eliminated automatically. After that, we tried to find a vector of regression coefficients \(\overset{\rightarrow}{\alpha}\) to minimize the sum of squares of random noise \(\varepsilon_{i}\), using the least-squares estimation method:  
\[\underset{\overset{\rightarrow}{\alpha}}{argmin}\quad\overset{\rightarrow}{ \sum}_{i=1}^{n_{h}}\varepsilon_{i}^{2}\to 0 \tag{3}\]  
Finally, an expected relative speed was computed as a dot-product of vector of regression coefficients \(\overset{\rightarrow}{\alpha}\) and vector \(\overset{\rightarrow}{x}_{hour}\) of explanatory variables for the hour the prediction is made for:  
\[PR_{\mathit{LinR}}(\mathit{hour})=\overset{\rightarrow}{\alpha}.\overset{ \rightarrow}{x}_{hour} \tag{4}\]  
Linear regression coefficients were computed relatively to the _FreeFlowSpeed_ (for the vector \(\overset{\rightarrow}{\alpha}\) to be comparable among road segments--see \(\mathrm{y_{i}}\) above). Therefore, the dot-product must be multiplied by the _FreeFlowSpeed_ to obtain an expected speed in km/h:  
\[P_{\mathit{LinR}}(\mathit{hour})=PR_{\mathit{LinR}}(\mathit{hour})\times FreeFlowSpeed \tag{5}\]  
The identification code for this submodel is _LinRbasic_. Submodel _CBRBasic_ still remains as a backup model when there are not enough representative cases in the subset and linear regression fails. At the same time, the value provided by the _CBRBasic_ submodel serves as an \"anchor\" to identify situations when the linear regression results are not to be trusted.