# Neural Multivariate Grey Model and Its Applications
## 3 NMGM Model
### Parameter Optimization  
In fact, provided with an initial value and a specific timeframe, the NODE is designed to generate a prediction sequence matching the length of the given time span. This capability ensures the production of a prediction sequence that aligns precisely with the designated duration, allowing for accurate forecasting based on the initial conditions and temporal scope provided. This sequence is then used to calculate the loss. As the 1-AGO series \(X_{1}^{(1)},X_{2}^{(1)},\cdots,X_{N}^{(1)}\) are used as input to our model, the output also has N dimensions in order to optimize the weight \(\theta\) and obtain the optimal prediction sequence of the raw system characteristic sequence \(X_{1}^{(0)}\). To train NODE, the following loss function is defined:  
\[\mathcal{L}=\sum_{t=0}^{n}\left(\hat{z}-z(t)\right)^{2}=\left(Z-X_{1}^{(1)} \right)^{2}, \tag{17}\]  
where \(X_{1}^{(1)}\) is the 1-AGO sequences of system characteristic sequence \(X_{1}^{(0)}\). Based on the backpropagation algorithm, the model parameters \(\theta\) can be updated through gradients:  
\[\theta^{(t+1)}=\theta^{t}-\lambda\frac{d\mathcal{L}}{d\theta}. \tag{18}\]  
Figure 2: The flowchart of NMGM.  
Equation (16) can be used to obtain the prediction sequence \(hatX1\) after training the parameter \(theta\). Eventually, we can obtain the predicted sequence of the initial data prior to accumulation by employing the restoration equation, Equation (19).  
\[\hat{x}^{0}(k)=\hat{x}^{1}(k)-\hat{x}^{1}(k-1),s.t.k=1,2,\cdots,m-1. \tag{19}\]  
The process of the algorithm for the NMGM model is illustrated in Algorithm 1. A full adjoint sensitivities algorithm can be used to optimize the parameters. In the appendix of NODE [23], more details about the algorithm are provided.  
```
0: raw data \((X_{1}^{(0)},X_{2}^{(0)},\cdots,X_{N}^{(0)})\) where \(X_{i}^{(0)}=\big{(}x_{i}^{(0)}(1),x_{i}^{(0)}(2),\cdots,x_{i}^{(0)}(m)\big{)}\);  initialize \(\theta^{(0)}\); fun \(f_{\theta}\); \(t_{s}\); \(\lambda\); MaxIterations MI; Threshold Th; Output:\(\hat{X}_{1}^{(0)},\hat{X}_{2}^{(0)},\cdots,\hat{X}_{N}^{(0)}\)
1: initialization
2: Compute 1-AGO sequence: \(X_{j}^{(1)}=\big{(}x_{j}^{(1)}(1),x_{j}^{(1)}(2),\cdots,x_{j}^{(1)}(m)\big{)}\) where \(x_{j}^{(1)}(i)=\sum_{k=1}^{i}x_{j}^{(0)}(k),i=1,2,\cdots,m\)
3:whilek\(\leq\)MI AND Loss > th do
4: Solve \(\frac{\mathrm{d}x^{1}(t)}{dt}=f_{\theta^{(k)}}(x^{1}(t),t_{s})\) to get \((\hat{X}_{1}^{(0)},\hat{X}_{2}^{(0)},\cdots,\hat{X}_{N}^{(0)})\)
5: Get a(t) = ODESolver\(\big{(}a(t_{n}),t,\frac{\partial f_{\theta}(t)}{\partial t}\big{)}\)
6: Get \(\
abla_{\theta}Loss:\frac{\mathrm{d}t}{dt}=\int_{t_{1}}^{t_{0}}\mathbf{a}(t)^{ \tau}\frac{\partial f_{\theta}(x(t),t)}{\partial\theta}\mathrm{d}t\)
7: Iterate \(\theta:\theta^{(k+1)}=\theta^{(k)}-\lambda\
abla_{\theta}Loss\)
8: Solve \(\frac{\mathrm{d}x^{1}(t)}{dt}=f_{\theta^{(3)}}(x^{1}(t),t_{s})\) to Get \((\hat{X}_{1}^{(1)},\hat{X}_{2}^{(1)},\cdots,\hat{X}_{N}^{(1)})\)
9: Obtain prediction value \(\hat{X}^{(0)}:\hat{x}_{1}^{(0)}(k)=\hat{x}_{1}^{(1)}(k)-\hat{x}_{1}^{(1)}(k-1),k=1,2,\cdots,m-1\)
10:return\((\hat{X}_{1}^{(0)},\hat{X}_{2}^{(0)},\cdots,\hat{X}_{N}^{(0)})\).
```  
**Algorithm 1** Algorithm of the NMGM.  
In summary, the conventional GM(1, N) model adopts the least squares method for parameter training, whereas the NMGM model relies on a neural network design and thus applies gradient descent for training. Furthermore, as the neural network defines the function \(f_{\theta}\) within the whitening equation, integrating the attributes of dependent variables and associated factors into the network's architecture and training greatly enhances the model's accuracy.