# Risk Assessment for Linear Regression Models in Metrology
## 2 Materials and Methods
### Risk Calculation
The acceptance lines (curves) change along the guard band axis, depending on the length \(w_{k}\) of the guard band:  
\[w_{k}=\frac{r_{k}\cdot w_{\max}}{2},k=1,2,\ldots,n_{3}. \tag{23}\]  
According to [13], the risk of rejection of a product conforming to the specifications, i.e., the global producers' risk \(R_{P}\), is calculated from the equation:  
\[R_{P}=\int_{-\infty}^{A_{L}}\int_{T_{L}}^{T_{U}}g_{0}(\eta)h(\eta_{m}|\eta)d \eta_{m}d\eta+\int_{A_{U}}^{\infty}\int_{T_{L}}^{T_{U}}g_{0}(\eta)h(\eta_{m}| \eta)d\eta_{m}d\eta. \tag{24}\]  
The risk of accepting a non-compliant product, i.e., the global consumer's risk \(R_{C}\), according to [13], is calculated using the following equation:  
\[R_{C}=\int_{-\infty}^{T_{L}}\int_{A_{L}}^{A_{U}}g_{0}(\eta)h(\eta_{m}|\eta)d \eta_{m}d\eta+\int_{T_{U}}^{\infty}\int_{A_{L}}^{A_{U}}g_{0}(\eta)h(\eta_{m}| \eta)d\eta_{m}d\eta. \tag{25}\]  
The random variables \(Y\) and \(Y_{m}\) are normally distributed. Therefore, the prior \(g_{0}(\eta)\) in equations (24) and (25) has the form:  
\[g_{0}(\eta)=\frac{1}{u_{0}\sqrt{2\pi}}\mathrm{exp}\left[-\frac{1}{2}\left( \frac{\eta-y_{0}}{u_{0}}\right)^{2}\right], \tag{26}\]  
and the likelihood function has the form:  
\[h(\eta_{m}|\eta)=\frac{1}{u_{m}\sqrt{2\pi}}\mathrm{exp}\left[-\frac{1}{2}\left( \frac{\eta_{m}-\eta}{u_{m}}\right)^{2}\right]. \tag{27}\]In the simplification procedure, which is elaborately outlined in detail in [18], the double integrals present in formulas (24) and (25) can be reduced to single integrals. The global producer risk for models M1 and M2 can be calculated using the expression:  
\[\mathrm{T_{Uj}}=\mathrm{y_{j}}+\frac{\Delta\mathrm{T}}{2},j=1,2,\ldots, \mathrm{n_{2}}, \tag{19}\]0  
where the label \(\varphi_{0}\) denotes density function for the unit normal distribution, which can be calculated from the following equation:  
\[\mathrm{T_{Uj}}=\mathrm{y_{j}}+\frac{\Delta\mathrm{T}}{2},j=1,2,\ldots, \mathrm{n_{2}}, \tag{19}\]1  
The quantity \(\mathrm{F}(z)_{jk},j=1,2,\ldots,n_{3}\), \(k=1,2,\ldots,n_{3}\) is expressed through the cumulative distribution function (CDF) for the unit normal distribution [13]. For models M1 and M2, \(\mathrm{F}(z)_{jk}\) has the form:  
\[\mathrm{T_{Uj}}=\mathrm{y_{j}}+\frac{\Delta\mathrm{T}}{2},j=1,2,\ldots, \mathrm{n_{2}}, \tag{19}\]2  
Global consumers' risk is calculated, according to [13], from  
\[\mathrm{T_{Uj}}=\mathrm{y_{j}}+\frac{\Delta\mathrm{T}}{2},j=1,2,\ldots, \mathrm{n_{2}}, \tag{19}\]3  
For the standard measurement uncertainty of future measurements \(u_{m}\), in equations (27) and (30), the values \(u_{m}=u_{0}/2\), \(u_{m}=u_{0}\) and \(u_{m}=2u_{0}\) were taken. The formulas for global producer's risk and global consumer's risk for the non-linearized model M3 and the linearized model M4 were obtained by inserting the values \(u_{0}{}^{\mathrm{LRA}},j=1,2,\ldots,n_{2}\) instead of \(u_{0}{}^{\mathrm{CUM}}\) into equations (28), (30) and (31). It is clear from equations (18)-(31) that the global risks of producers and consumers are calculated for each value of the moderate scale, namely, for all reference values \(x_{1},x_{2},\ldots,x_{n_{2}}\) and for all values of the multiplicative factor \(r_{k},k=1,2,\ldots,n_{3}\) in the nodes of the subdivision of the guard band. In this way, risk surfaces are obtained. The total number of grid points where the values of global producers' and consumers' risk were evaluated is \(n_{2}\cdot n_{3}=273\). The risk evaluation was performed by numerically solving the integrals from equations (28) and (31). All calculations and 2D graphs were performed by using the R software package, version 4.2.0, while 3D graphs were created using the Octave software package, version 8.4.0 [57, 58, 59]. This can be a challenge because the measurer is required to be familiar with mathematics and programming. That is why risk calculation is often avoided.