401-4623-00: Time Series Analysis
Section 3
Test the Estimated Noise Sequence
Swiss Federal Institute of Technology Zurich
Eidgenössische Technische Hochschule Zürich
Last Edit Date: 12/17/2024
Disclaimer and Term of Use:
We do not guarantee the accuracy and completeness of the summary content. Some of the course material may not be included, and some of the content in the summary may not be correct. You should use this file properly and legally. We are not responsible for any results from using this file
This personal note is adapted from Professor Fadoua Balabdaoui and Professor Nicolai Meinshausen. Please contact us to delete this file if you think your rights have been violated.
This work is licensed under a Creative Commons Attribution 4.0 International License.
Let $\hat{m}_t$ and $\hat{S}_t$ be estomators of the trend $m_t$ and seasonal components $S_t$ respectively. Then the obtained residuals $X_t - \hat{m}_t - \hat{S}_t$ can be regarded as the estimated noise. We can have the following questions.
Is the noise $IID(0, \sigma^2)$ for some $\sigma > 0$?
Is the noise stationary?
Theorem
If $Y_1, Y_2, \cdots, Y_n$ are iid random variables from $IID(0, \sigma^2)$, then for any fixed $h \ge 1$
$$\sqrt{n} \begin{pmatrix} \hat{\rho}(1) \\ \vdots \\ \hat{\rho}(h) \end{pmatrix} \xrightarrow{d} \mathcal{N}(0, I_{n \times n})$$
where $0 \in \mathbb{R}^n$ and identity matrix $I_{n \times n} \in \mathbb{R}^{n \times n}$.
Note that "$\xrightarrow{d}$" is a notation for convergence in distribution. Recall that given random vectors $W_k \in \mathbb{R}^k$ with CDF $F_n$ and a random vector $W \in \mathbb{R}^k$ with CDF $F$, we say that $\{W_n\}_n$ converges in distribution (in law) weakly to $W$ ($W_n \xrightarrow{d} W$) if $\lim_{n \rightarrow \infty} F_n(W) = F(W)$ whenever $F$ is continuous at $W$.
Alternatively, we can say
$$W_n \xrightarrow{d} W$$
if and only if
$$\lim_{n \rightarrow \infty} \mathbb{E}\left[ e^{iv^TW_n} \right] = \mathbb{E}_{\forall v \in \mathbb{R}^{k}}\left[ e^{iv^TW_n} \right].$$
Now let $\beta \in (0, 1)$ and $Z_{\beta}$ be that $\beta$-quantile of $\mathcal{N}(0,1)$. This means that
$$Z_{\beta} = F^{-1}(\beta)$$
where $F$ is the CDF of $\mathcal{N}(0, 1)$, which means
$$F(x) = \int_{-\infty}^x \frac{1}{\sqrt{2 \pi}} e^{-\frac{t^2}{2}} dt, \forall x \in \mathbb{R}.$$
Thus, we have that $F(\beta) = \mathbb{P}(Z \le Z_{\beta}) = \beta$ where $Z \in \mathcal{N}(0,1)$.
Now let $\beta = 1 - \frac{\alpha}{2}$ for some probability $\alpha \in (0, 1)$, we have
$$ \begin{align} \mathbb{P}\left(|Z| > Z_{1 - \frac{\alpha}{2}}\right) &= \mathbb{P} \left( Z > Z_{1 - \frac{\alpha}{2}} \text{ or } Z < - Z_{1 - \frac{\alpha}{2}} \right) \\ &= \mathbb{P} \left( Z > Z_{1 - \frac{\alpha}{2}}\right) + \mathbb{P} \left(Z < - Z_{1 - \frac{\alpha}{2}} \right) \\ &= 2 \mathbb{P}\left( Z > Z_{1 - \frac{\alpha}{2}} \right) \end{align} $$
In the following, we will discuss the excedance test, the portmanteau test, and the difference sign test.
Specifically, the excedance test and the portmanteau test are based on the theorem above.
The exceedance test¶
From the theorem above, we can say that $\sqrt{n} \hat{\rho}(1), \cdots, \sqrt{n} \hat{\rho}(h)$ behave approximately like $Z_1, \cdots, Z_h \overset{\text{iid}}{\sim} \mathcal{N}(0, 1)$.
When $n$ is large enough, we can have $\sqrt{n} |\hat{\rho}(1)|, \cdots, \sqrt{n} |\hat{\rho}(h)|$ behave approximately like $|Z_1|, \cdots, |Z_h|$.
For some large $h$, we have that
$$\underbrace{\frac{1}{h} \sum_{i = 1}^h \mathbb{1} \{|Z_i| > Z_{1 - \frac{\alpha}{2}}\}}_{\text{the observed proportion of exceeding } Z_{1 - \frac{\alpha}{2}}} \approx \underbrace{\alpha}_{\text{true probability of } |Z| > Z_{1 - \frac{\alpha}{2}} \text{ with } Z\sim \mathcal{N}(0, 1)}$$
As a result, we have
$$ \begin{align} &\frac{1}{h} \sum_{i = 1}^h \mathbb{1} \{ \sqrt{n} |\hat{\rho(i)}| > Z_{1-\frac{\alpha}{2}}\} \approx \alpha \\ \Leftrightarrow &\sum_{i = 1}^h \mathbb{1} \left\{ |\hat{\rho(i)}| > \frac{Z_{1-\frac{\alpha}{2}}}{\sqrt{n}}\right\} \approx h\alpha . \end{align}$$
The informal exceedance test is done as follows
Plot $\hat{\rho}(1), \cdots, \hat{\rho}(h)$ and the boundaries $-\frac{Z_{1 - \frac{\alpha}{2}}}{\sqrt{n}}$ and $\frac{Z_{1 - \frac{\alpha}{2}}}{\sqrt{n}}$.
Reject the IID hypothesis if there are more than $h\alpha$ cases of exceedance being outside the boundaries.
Example¶
Suppose we have $\alpha = 0.05$ and $h = 20$. Note these can give us $\alpha h = 1$, and $\alpha = 0.05$ can give us $Z_{1 - \frac{\alpha}{2}} = 1.96$.
The test rejects the IID hypothesis if there are at least 2 exceedance cases.
The Portmenteau test¶
Recall that
$$\sqrt{n} \begin{pmatrix} \hat{\rho}(1) \\ \vdots \\ \hat{\rho}(h) \end{pmatrix} \xrightarrow{d} \begin{pmatrix} Z_1 \\ \vdots \\ Z_h \end{pmatrix}$$
as $n \rightarrow \infty$ under the iid assumtion with $Z_1, Z_2, \cdots, Z_n \overset{\text{iid}}{\sim} \mathcal{N}(0, 1)$.
By the continuous mapping theorem
$$ \begin{align} &\left\|\sqrt{n} \begin{pmatrix} \hat{\rho}(1) \\ \vdots \\ \hat{\rho}(h) \end{pmatrix}\right\|^2 \xrightarrow{d} \left\|\begin{pmatrix} Z_1 \\ \vdots \\ Z_h \end{pmatrix}\right\|^2 \\ \Leftrightarrow & n\sum_{i = 1}^h \hat{\rho}(i)^2 \xrightarrow{d} \sum_{i = 1}^h Z_i^2 \sim \chi_h^2 \end{align} $$
where $\| . \|$ represents the $\ell_2$ distance.
Now let $q_{1-\alpha, h}$ be the $1-\alpha$ quantile of $\chi_h^2$, we have
$$\mathbb{P}(Q_n > q_{1 - \alpha, h}) = 1 - \mathbb{P}(Q_n \le q_{1 - \alpha, h}) \xrightarrow{n \rightarrow \alpha} 1 - (1 - \alpha) = \alpha.$$
The Portmanteau theorem rejects the IID hypothesis if an only if $Q_n > q_{1 - \alpha, h}$.
Example¶
For $\alpha = 0.05$ and $h = 20$, $q_{0.05, 20} \approx 31.4$, which comes from the $\chi^2$ distribution with degrees of freedom of 20.
Suppose we have $Q_n = n\sum_{i = 1}^h \hat{\rho}(i)^2 = 100 \times 0.2 = 20$. In this case, $Q_n = 20 < q_{0.05, 20} \approx 31.4$, we fail to reject the null hypothesis.
The difference sign test¶
Under the assumption that $Y_1, Y_2, \cdots, Y_n$ are iid, these random variables are exchangeable. This means taht their distribution remains unchanged under any permutation of these random variables.
Let $S_n = \sum_{i = 2}^n \mathbb{1} \{ Y_i > Y_{i - 1} \}$. If $Y_1, Y_2, \cdots, Y_n$ are iid, then
$$\frac{S_n - \frac{n - 1}{2}}{\sqrt{\frac{n + 1}{12}}} \xrightarrow{d} \mathcal{N}(0, 1), n \rightarrow \infty.$$
The difference sign test rejects the IID hypothesis if and only if
$$\left| \frac{S_n - \frac{n - 1}{2}}{\sqrt{\frac{n + 1}{12}}} \right| > Z_{1 - \frac{\alpha}{2}}.$$
Proof:
We simply need to show that $\mathbb{E}[S_n] = \frac{n - 1}{2}$ and $\mathrm{Var}(S_n) = \frac{n + 1}{12}$.
For $\mathbb{E}[S_n]$
$$ \begin{align} \mathbb{E}[S_n] &= \mathbb{E} \left[ \sum_{i = 2}^n \mathbb{1} \{Y_i > Y_{i - 1}\} \right] \\ &= \sum_{i = 2}^n \mathbb{E} \left[ \mathbb{1} \{Y_i > Y_{i - 1}\} \right] \\ &= \sum_{i = 2}^n \mathbb{P} (Y_i > Y_{i - 1}) \\ \end{align} $$
Under the iid assumption, we have
$$\mathbb{P} (Y_i > Y_{i - 1}) = \mathbb{P} (Y_i \le Y_{i - 1}) = \frac{1}{2}$$
so
$$\mathbb{E}[S_n] = \frac{n - 1}{2}.$$
For $\mathrm{Var}(S_n)$
We have that $\mathrm{Var}(S_n) = \mathbb{E}[S_n^2] - \mathbb{E}[S_n]^2$ with $\mathbb{E}[S_n] = \frac{n - 1}{2}$, which is the result we just got above. Now
$$ \begin{align} S^2 &= \sum_{i = 2}^n \left( \mathbb{1} \{Y_i > Y_{i - 1}\} \right)^2 + \sum_{2\le i\neq j\le n} \mathbb{1} \{Y_i > Y_{i - 1}\} \mathbb{1} \{Y_j > Y_{j - 1}\}\\ &= \sum_{i=2}^n \mathbb{1} \{Y_i > Y_{i - 1}\} + 2\sum_{2\le i<j \le n} \mathbb{1} \{Y_i > Y_{i - 1}\} \mathbb{1} \{Y_j > Y_{j - 1}\} \\ &= S_n + 2\sum_{2\le i<j \le n} \mathbb{1} \{Y_i > Y_{i - 1}\} \mathbb{1} \{Y_j > Y_{j - 1}\} \end{align} $$
and hence under $H_0$
$$ \mathbb{E}[S_n^2] = \frac{n - 1}{2} + 2\sum_{2\le i<j \le n} \mathbb{P}(Y_i > Y_{i - 1}, Y_j > Y_{j - 1}). $$
Note that the events $\{ Y_i > Y_{i - 1} \}$ and $\{ Y_j > Y_{j - 1} \}$ are independent if and only if $\{i - 1, i\} \cap \{j - 1, j\} = \emptyset$, or equicalently $i - 1 \neq j$ and $i \neq j - 1$. Since $i < j$, $i - 1 \neq j$ is always true and hence independence is equivalent to $i \neq j - 1$, that is $j \ge i + 2$. Now, we can write
$$ \begin{align} \sum_{1 \le i<j \le n} \mathbb{P}(Y_i > Y_{i - 1}, Y_j > Y_{j - 1}) &= \sum_{2 \le i \le n-1, j = i+1} \mathbb{P}(Y_i > Y_{i - 1}, Y_j > Y_{j - 1}) + \sum_{2 \le i \le n-2, j \ge i+2} \mathbb{P}(Y_{i + 1} > Y_i > Y_{i - 1})\\ &= \underbrace{\sum_{2 \le i \le n-1} \mathbb{P}(Y_i > Y_{i - 1}, Y_j > Y_{j - 1})}_{A} + \underbrace{\sum_{2 \le i \le n-2, j \ge i+2} \mathbb{P}(Y_i > Y_{i - 1}, Y_j > Y_{j - 1})}_{B}\\ \end{align} $$
Under the assumption that $\mathbb{P}(Y_i = Y_j) = 0$ for $i \neq j$, $Y_{i-1}$, $Y_i$, and $Y_{i + 1}$ are distinct with probability 1. Also, under $H_0$, all the permutations of $(Y_{i - 1}, Y_i, Y_{i + 1})$ have the same probability. This means that
$$1 = 6\mathbb{P}(Y_{i + 1} > Y_i > Y_{i - 1})$$
and hence $\mathbb{P}(Y_{i + 1} > Y_i > Y_{i - 1}) = \frac{1}{6}$ and
$$A = \frac{n - 2}{6}.$$
Let us now look at $B$. In this case we know that the events $\{Y_i > Y_{i - 1}\}$ and $\{Y_j > Y_{j - 1}\}$ are indepedent and hence
$$\sum_{2\le i \le n-2, j \ge i + 2} \mathbb{P}(Y_i > Y_{i - 1}, Y_j > Y_{j - 1}) = \frac{\#\{(i, j): 2 \le i \le n-2, j \ge i + 2 \}}{4}$$
where
$$ \begin{align} \#\{(i, j): 2 \le i \le n-2, j \ge i + 2 \} &= \#\{(i, j): 2 \le i < j \le n\} - \#\{(i, j): 2 \le i \le n-1, j \ge i + 1 \} \\ &= \frac{(n - 1)^2 - (n - 1)}{2} - (n - 2) \\ &= \frac{(n - 1)(n - 2)}{2} - (n - 2). \end{align} $$
Now we can have
$$ \begin{align} \mathbb{E}[S_n^2] &= \frac{n - 1}{2} + 2 \left( \frac{n - 2}{6} + \frac{1}{4} \left( \frac{(n - 1)(n - 2)}{2} - (n - 2) \right) \right) \\ &= \frac{n - 1}{2} + \frac{(n - 1)(n - 2)}{4} - \frac{n - 2}{6} \end{align} $$
Finally, we plug values of $\mathbb{E}[S_n]^2$ and $\mathbb{E}[S_n^2]$ into $\mathrm{Var}(S_n)$ to get
$$ \begin{align} \mathrm{Var}(S_n) &= \left( \frac{n - 1}{2} \right)^2 + \left( \frac{n - 1}{2} + \frac{(n - 1)(n - 2)}{4} - \frac{n - 2}{6} \right) \\ &= \frac{n - 1}{2} + \frac{(n - 1)(n - 2)}{4} - \frac{n - 2}{6} - \frac{(n - 1)^2}{4} \\ &= \frac{6n - 6}{12} + \frac{3n^2 - 9n + 6}{12} - \frac{2n - 4}{12} - \frac{3n^2 - 6n + 3}{12} \\ &= \frac{6n - 6 + 3n^2 - 9n + 6 -2n + 4 - 3n^2 + 6n - 3}{12}\\ &= \frac{n + 1}{12}. \end{align} $$
Example¶
In the case shown in the image above, we have $S_{10} = 0 + 0 + 1 + 1 + 0 + 1 + 1 + 0 + 0 = 4$.
Given $\alpha = 0.05$, we have
$$\left| \frac{4 - \frac{10 - 1}{2}}{\sqrt{\frac{10 + 1}{12}}} \right| \approx 0.52 < 1.96.$$
As a result, we fail to reject the null hypothesis.