*2.4. Prediction*

Once the parameter is determined by the improved EM algorithm, the model can be employed to forecast the expected value of the next observation.

The conditional probability distribution of the observation *oT*+1 can be derived as

$$\begin{split} P(o\_{T+1}|o\_{T},\ldots,o\_{1},\lambda) &= \sum\_{l=1}^{N} P(o\_{T+1}|S\_{T}=s\_{l},o\_{T},\ldots,o\_{1},\lambda) P(S\_{T}=s\_{l}|o\_{T},\ldots,o\_{1},\lambda) \\ &= \sum\_{l=1}^{N} \sum\_{j=1}^{N} P\left(o\_{T+1}\middle|S\_{T+1}=s\_{j},o\_{T},\ldots,o\_{1},\lambda\right) P\left(S\_{T+1}=s\_{j}|S\tau=s\_{l},\lambda\right) \gamma\_{T}(i) \\ &= \sum\_{l=1}^{N} \sum\_{j=1}^{N} \gamma\_{T}(i) a\_{lj} b\_{j}(o\_{T+1}|o\_{T},\ldots,o\_{T+1-d}). \end{split} \tag{23}$$

Therefore, the expectation of *oT*+1 is computed by

$$
\partial\_{T+1} = \int o\_{T+1} P(o\_{T+1} | o\_{T\prime}, \dots, o\_1, \lambda) d o\_{T+1}.\tag{24}
$$

Given an observation sequence *o* = (*<sup>o</sup>*1, ··· , *oT*), *o*ˆ*t* is predicted by

$$\phi\_t = \int o\_t \mathbf{P}(o\_t | o\_{t-1}, \lambda) do\_t = \int o\_t \sum\_{i=1}^N \sum\_{j=1}^N \gamma\_{t-1}(i) b\_j a\_{ij}(o\_t | o\_{t-1}) do\_{t\prime} t \ge d. \tag{25}$$

Thus, the predicted values of the observations can be denoted by *o*ˆ = (*<sup>o</sup>*1, *o*ˆ2, ··· , *<sup>o</sup>*<sup>ˆ</sup>*T*).

#### *2.5. Performance Comparison*

The mean squared error (MSE), absolute mean error (AME) and mean absolute percentage error (MAPE) are common tools for measuring, fitting and predicting accuracy [49]. Both MSE and AME values determine the average deviation between fitting values and original values, while MAPE provides a measurement for testing the relevant difference between them. In this study, we use MSE as the criterion to evaluate the models. The equation for MSE is:

$$\text{MSE} = \frac{1}{LT} \sum\_{l=1}^{L} \sum\_{t=1}^{T} (o\_t - \mathfrak{d}\_t)^2,\tag{26}$$

where *L* is the number of predicted samples, and *T* is the length of each sample.

We assume that a variable from a production process follows a normal distribution with mean 100 and variance 25 when the process is under control, and that the observations are first-order autocorrelated with a correlation coefficient of 0.6. We use IHMM, HMM and AR(1) methods to predict observation values, respectively. The MSEs for the three models are 15.1276, 16.1867 and 15.7861, respectively. Since these MSEs are very close, we conclude that the predicted performances of the three approaches are similar. The predicted results of an observation sequence with a length of 50 from the in-control process are shown in Figure 4, from which we can see that the three models have close performances. However, the time taken for prediction using the three models are quite different. For the prediction of an observation sequence with a length of 50, IHMM is 14.6523 s, HMM is 93.6521 s, and AR(1) is almost instantaneous under the environment of win10 OS (Microsoft, Redmond, WA, USA) with CPU of Intel(R) Core(TM) i7-7500U (Santa Clara, CA, USA).

**Figure 4.** The predicted results of three models under an in-control process.

Then, we suppose the process has a shift magnitude of 3. We still use the three methods to predict observation values, respectively. The predicted results of an observation sequence with a length of 50 from the out-of-control process are shown in Figure 5, from which we can see distinctly different performances of the three models. By observing the distances between the lines with different colors, obviously, if the MSEs are calculated, the MSE from AR(1) is much less than that from IHMM, and the MSE from IHMM is much less than that from HMM. The IHMM only results in a medium-level performance in the prediction for the autocorrelated process. However, it is very interesting that the performances of corresponding residual charts have the best performances in detecting quality shifts. This seems to sugges<sup>t</sup> that the residual charts integrating IHMM can achieve a surprising effect. This result is verified in Section 3.

**Figure 5.** The predicted results of three models under an out-of-control process.

#### **3. Statistical Process Control with Residual Chart**

Residual control charts are an effective tool for online monitoring in the presence of autocorrelations. A residual chart called *e* chart is developed in our study.

Residuals are obtained by subtracting the predicted values of observations from the original values, that is *e* = *o* − *o*ˆ = (*<sup>e</sup>*1, ··· ,*eT*). The control limits of the *e* chart are given by

$$
\mathcal{U}\mathcal{U}\mathcal{L} = \mu\_{\mathcal{E}} + k\sigma\_{\mathcal{E}} \tag{27}
$$

$$L\mathbb{C}L = \mu\_{\mathfrak{c}} - k\sigma\_{\mathfrak{c}}.\tag{28}$$

where *UCL* represents the upper limit, while *LCL* represents the lower limit, *k* is the number of *σe*, *μe* represents the mean of *e*, and *σe* represents the standard deviation of *e*. *μe* and *σe* can be obtained by simulations based on sufficient samples.

If the value of *et* drops within *UCL* and *LCL*, the process is judged to be in control; otherwise, it is judged to be out of control.

#### **4. Numerical Examples**

We consider that the variable from a production process followed a normal distribution with mean 100 and variance 25 when the process is in control and that the observations were first-order autocorrelated. The correlation coefficient varies between −0.6 and 0.6 with increments of 0.3. Two shift magnitudes of 1.5 and 3 are considered. According to the definition of residual charts, the ARLs of in-control processes for all predicted methods are 370, so we focus our discussion on the out-of-control processes. By conducting multiple experiments, we find that it is appropriate to make the state number with 5 for both IHMM and HMM. The experimental results are shown in Figures 6 and 7.

**Figure 6.** The ARLs of residual charts obtained by different models when the shift magnitude is 1.5.

**Figure 7.** The ARLs of residual charts obtained by different models when the shift magnitude is 3.

As shown in Figures 6 and 7, when correlation coefficient changes from positive to negative, ARLs decrease dramatically, regardless of the approach used. Compared with positive correlations, the ARLs of negative correlations are relatively very small, and ARLs obtained by different models are very close to each other. Thus, the following discussions focus on positive correlations.

As pointed out in Section 3, although the predictions of both the IHMM and HMM are inferior to AR(1) models, the performances of residual charts from the former models are much better than the latter ones. As seen in Figures 4 and 5, when the coefficients are larger than zero, the ARLs by IHMMs are shorter than those by HMMs, and by HMMs shorter than by AR(1) models.

As correlation coefficients increase, the ARLs generally increase, regardless of the approach used, especially as the shift magnitude decreases.

Generally speaking, when detecting quality shifts, the performances of IHMM, HMM and AR(1) models are ranked with IHMMs first, HMMs second and AR(1) last. Moreover, as pointed out in Section 2, the times taken by IHMMs are much shorter than HMMs under the same running environments.

## **5. Conclusions**

In this paper, an IHMM with autocorrelated observations and a new EM algorithm are proposed. Residual charts in conjunction with the IHMM are employed for detecting quality shifts. The results demonstrates that: (1) the IHMM outperforms the HMM and AR(1) method with positive correlations; (2) the IHMM has similar performances with the HMM and AR(1) methods with negative correlations; (3) compared with positive correlations, the ARLs of the IHMM under negative correlations are relatively very small, as well as those of the HMMs and AR(1) models; (4) the IHMMs take a much shorter time than HMMs, for both training and prediction, but still longer than the AR(1) models.

Future research might focus on further experimental validations for the IHMM and its algorithm. The strict Gaussian distribution of observations could be extended to other probability distributions. Since multistage systems are commonplace in the manufacturing industry, it is worth extending this approach in this research direction.

**Author Contributions:** Conceptualization, Y.L. and Z.C.; methodology, Y.L. and Z.C.; software, Y.L.; validation, Y.L. and H.L.; formal analysis, Y.L. and H.L.; investigation, Y.L. and Y.Z.; resources, Y.L.; data curation, Y.L.; writing—original draft preparation, Y.L.; writing—review and editing, Y.L.; visualization, Y.L.; supervision, Y.L.; project administration, Y.L.; funding acquisition, Y.L. and Z.C. All authors have read and agreed to the published version of the manuscript.

**Funding:** This research was funded by the National Natural Science Foundation of China, gran<sup>t</sup> number 72171120, 71701098, 72001138 and Qing Lan Project of Jiangsu Province in China, gran<sup>t</sup> number 2021.

**Institutional Review Board Statement:** Not applicable.

**Informed Consent Statement:** Not applicable.

**Data Availability Statement:** Data are contained within the article.

**Conflicts of Interest:** The authors declare no conflict of interest.
