## 2 Methods
### Data Preprocessing
#### 2.2.2 Granger Causality Tests and DTW  
According to the Granger causality test [19], given two variables \(x\) and \(y\), variable \(x\) can be considered to influence variable \(y\) in an appropriate statistical sense if the forecasting of the value of \(y\) is based on the past values of \(y\) and the past values of \(x\) is better than the forecasting of the value of \(y\) is based only on the past values of \(y\). As in Equation (5), one can test for Granger causality between the two series by constructing binary vector autoregressive models:  
\[\left\{\begin{aligned} y_{t}=\alpha+\sum_{i=1}^{m}\beta_{i}y_{t-i}+ \sum_{j=1}^{n}\gamma_{j}x_{t-j}+\eta_{t}\\ y_{t}=\alpha+\sum_{i=1}^{m}\beta_{i}y_{t-i}+\eta_{t}\end{aligned}\right. \tag{5}\]  
where \(x_{t}\) and \(y_{t}\) are elements of two time series on a uniform time scale. Two autoregressive models are constructed for \(y_{t}\); model 1 includes the causal hypothesis, while model 2 does not. In these models, \(\alpha,\beta,\) and \(\gamma\) are the parameters to construct the autoregressive model, and \(\eta_{t}\) represents the residual term. The values of m and n, determining the number of lag terms, are selected based on the Bayesian Information Criterion, ultimately determining the maximum lag order as \(n=15\).  
After obtaining the two autoregressive models, the hypothesis that \(y_{t}\) and \(x_{t}\) are not causally related is initially assumed, followed by conducting F-tests on both models [16]. If the calculated p-value of the F-test is less than 0.05, the hypothesis is rejected, indicating that x is the Granger cause of y. The Granger cause can help determine which sensor data can change in time ahead of other sensors' data changes and impact them; further, it can obtain information on how information flows and propagates through the sensor network, which helps to understand the interconnections between sensors.  
The causal network presented in this paper is directly constructed based on the results of the Granger causality test. By setting the significance level of the F-test's calculated \(p\)-value (significance level) to be less than 0.01 as the threshold, a threshold network can be constructed. At each time scale, series are considered nodes, with edges indicating their Granger relationships.  
For water demand recorded by different sensors, after undergoing EEMD, the three temporal components, \(I_{1}(t)\), \(I_{2}(t)\), \(I_{3}(t)\), are subjected to Granger causality tests separately with the time series components of other sensors, and the causal matrices for short-term, middle-term, and long-term components, \(G_{s}\), \(G_{M}\), \(G_{L}\)\(\in\mathbb{R}^{N\times N}\), are constructed. A multi-time scale network allows for the exploration of richer information than the original data level and enables more detailed data analysis across multiple time scales. This way, utilizing the decomposed time series avoids modeling each decomposed \(imf\) separately, thereby reducing model complexity and allowing subsequent models to learn information from causal spatial-temporal relationships.  
The adjacency matrix \(G_{DTW}\) generated using \(DTW\) can supplement the information regarding the relationships between time series. Its generation process is illustrated in Equations (6) and (7) as follows:  
\[D(i,j)=Dist\big{(}x_{i},y_{j}\big{)}+min(D(i-1),j),D(i,j-1),D(i-1,j-1)) \tag{6}\]  
\[G_{DTW}(i,j)=\left\{\begin{aligned} & 1,D\big{(}X^{i},X^{i}\big{)}< \varepsilon\\ & 0,otherwise\end{aligned}\right. \tag{7}\]  
where the \(Dist\) function represents the calculation of the Euclidean distance between two times, \(D(i,j)\) denotes the shortest distance between the subsequent \(X=(x_{1},x_{2},x_{3},\ldots,x_{i})\) and \(Y=(y_{1},y_{2},y_{3},\ldots,y_{j})\), by which it better reflects the similarity between two time series. \(X^{i}\) denotes the series of sensor \(i\). If the \(DTW\) calculation of two sequences is less than the threshold \(\varepsilon\), they are considered to have a neighboring relationship.