## 2 Theory and Method
### Time Series Forecasting Model Based on ARIMA-LSTM  
#### 2.2.1. ARIMA(p,d,q) Model  
By using the ARIMA(p,d,q) model, it is possible to analyze observations at past time points, depict the intrinsic link between them, and predict future values, which is achieved based on past time values and linear error equations [28; 29; 30; 31; 32]. The ARIMA model is usually denoted as ARIMA(p,d,q), where p is the number of autoregressive terms, q is the number of sliding average terms, and d is the number of differences needed to make it a smooth series [33]. The correlogram, autocorrelation function (ACF), and partial autocorrelation function (PACF) of the time series provide information about the lags [34]. If the time series is found to be smooth, the model can be used for estimation and forecasting. However, if it is not smooth, in order to apply ARIMA, it must be transformed to be smooth by differencing. After identification, an ARIMA model is estimated for a specific smooth time series. The simple ARIMA model is estimated based on the number of effective coefficients, the Bayesian information criterion (BIC) and the Akaike information criterion (AIC), and the adjusted R\({}^{2}\)[35]. After estimation, the selected ARIMA model needs to be diagnosed to check if the residuals are white noise. If the residuals are not white noise, the model must be re-estimated, and Q-tests and normality tests can be used to diagnose the residuals [36]. Typically, the ARIMA model is as follows:  
\[y_{t}^{\prime}=\alpha_{0}+\sum_{i=1}^{p}\alpha_{i}y_{t-i}^{\prime}+\epsilon_{t }+\sum_{i=1}^{q}\beta_{i}\epsilon_{t-i} \tag{15}\]  
\[y_{t}^{\prime}=\Delta^{d}y_{t}=(1-L)^{d}y_{t} \tag{16}\]  
\[\left(1-\sum_{i=1}^{p}\alpha_{i}L^{i}\right)(1-L)^{d}y_{t}=\alpha_{0}+\left(1 +\sum_{i=1}^{q}\beta_{i}L^{i}\right)\epsilon_{t} \tag{17}\]  
For the study, the more the number of chemical content parameters, the better the model fit, but this will be at the cost of increasing the model complexity, so the model selection should seek the best balance between the model complexity and the ability of the model to explain the data. According to the Bayesian information criterion, when the BIC is smallest, the optimal solution between the fit effect and complexity can be found [37]:  
\[\text{BIC}=\ln\left(T\right)\left(n\right)-2\ln\left(M\right) \tag{18}\]  
T: number of samples;  
n: number of unknown parameters, n = p + q + 1;  
M: maximum likelihood number of the model. The maximum likelihood estimation process for the ARIMA(p,d,q) model is [38]:  
\[Y_{t}=c+\Phi_{1}Y_{t-1}+\Phi_{2}Y_{t-2}+\cdots+\Phi_{p}Y_{t-p}+\varepsilon_{t} +\theta_{1}\varepsilon_{t-1}+\cdots+\theta_{q}\varepsilon_{t-q} \tag{19}\]  
\(\Phi_{1},\Phi_{2}\cdots\Phi_{p}\) respectively represent the autolinear correlation coefficients between \(Y_{t-1}\cdots Y_{t-p}\) and \(Y_{t}\). By introducing the \(p-1\) term in the middle, the direct relationship between \(Y_{t-1}\cdots Y_{t-p}\) and \(Y_{t}\) can be separated, and this relationship is linear. \(\Phi_{1},\Phi_{2}\cdots\Phi_{p}\) is the value to measure the size of this influence, which is the so-called PACF(\(\theta_{1}\cdots\theta_{q}\) is the same meaning as \(\Phi_{1},\Phi_{2}\cdots\Phi_{p}\)). \(\varepsilon_{t}\) is the perturbed term. Where \(\varepsilon_{t}\sim\text{idN}\left(0,\sigma^{2}\right)\), The vector of total parameters is  
\[\overset{\rightarrow}{\Theta}=\left(c,\Phi_{1},\Phi_{2},\ldots,\Phi_{p}, \theta_{1},\theta_{2},\ldots,\theta_{q},\sigma^{2}\right)\]  
The estimation of the likelihood function for the autoregressive process is conditioned on the initial value of \(y\), and the estimation of the likelihood function for the moving average process is conditioned on the initial value of \(\varepsilon\). Then ARIMA(p,d,q) is conditioned on d as the difference order and the initial values of \(y\) and \(\varepsilon\).