时间序列分析:随机游走

1. 定义

  令 $\{e_t\}$ 是均值为 $\mu$,方差为 $\sigma_e^2$ 的白噪声,如果

\begin{equation}
X_t = X_{t-1} + e_t \tag{1}
\end{equation}

则称 $X_t$ 为随机游走(Random Walk)。

  式 $(1)$ 也可以使用延迟算子表示为

\begin{equation}
X_t = B X_t + e_t
\end{equation}

\begin{equation}
\phi(B) X_t = e_t
\end{equation}

其中

\begin{equation}
\phi(B) = 1 – B
\end{equation}

将随机游走的初始位置看做 $e_1$,将 $e_t$ 看做游走的步长,则 $X_t$ 就是在 $t$ 时刻所到达的位置,即有

\begin{equation}
X_t = \sum_{i=1}^t e_i \tag{2}
\end{equation}

2. 均值和方差函数

  由式 $(2)$ 易得随机游动的均值函数

\begin{equation}
E(X_t) = t\mu \tag{3}
\end{equation}

由白噪声的独立性,得到方差函数

\begin{equation}
\mathrm{Var}(X_t) = \mathrm{Var}(\sum_{i=1}^t e_i) = t \sigma^2 \tag{4}
\end{equation}

可见随机游走的方差随时间线性增长,随机游走是非平稳的。

3. 协方差和自相关函数

  设 $1 \leq t \leq s$,则协方差函数

\begin{equation}
\gamma_{t, s} = \mathrm{Cov}(X_t, X_s) = \mathrm{Cov}(e_1 + e_2 + \cdots + e_t, e_1 + e_2 + \cdots + e_t + \cdots + e_s) \tag{5}
\end{equation}

由协方差的性质(其中 $c_1, c_2, \cdots, c_m$ 和 $d_1, d_2, \cdots, d_n$ 为常数,$t_1, t_2, \cdots, t_m$ 和 $s_1, s_2, \cdots, s_n$ 为时点)

\begin{equation}
\mathrm{Cov} \bigg[ \sum_{i=1}^m c_i X_{t_i}, \sum_{j=1}^n d_j X_{s_j}\bigg] = \sum_{i=1}^m \sum_{j=1}^n c_i d_j \mathrm{Cov}(X_{t_i}, X_{s_j})
\end{equation}

式 $(5)$ 可以表示为

\begin{equation}
\gamma_{t, s} = \sum_{i=1}^s \sum_{j=1}^t \mathrm{Cov}(e_i, e_j)
\end{equation}

由白噪声的独立性,当 $i \neq j$ 时,有 $\mathrm{Cov}(e_i, e_j) = 0$;当 $i = j$ 时,有 $\mathrm{Cov}(e_i, e_j) = \mathrm{Var}(e_i) = \sigma_e^2$,而这样的项有 $t$ 个(因为 $t \leq s$),于是有 $\gamma_{t, s} = t \sigma_e^2$。由于 $\gamma_{t, s} = \gamma_{s, t}$,于是在所有的时间点上,都有

\begin{equation}
\gamma_{t, s} = t \sigma_e^2, \qquad 1 \leq t \leq s\tag{6}
\end{equation}

  于是可得随机游走的自相关函数为

\begin{equation}
\rho_{t, s} = \frac{\gamma_{t, s}}{\sqrt{\gamma_{t, t} \gamma_{s, s}}} = \sqrt{\frac{t}{s}} , \qquad 1 \leq t \leq s \tag{7}
\end{equation}

可见随着时间的推移,相邻时点上的正相关程度越来越强,而相距较远时点的相关程度越来越弱。更直观地,有如下结果

\begin{align}
&\rho_{1, 2} = \sqrt{\frac{1}{2}} = 0.707 \qquad & \rho_{11, 12} = \sqrt{\frac{11}{12}} = 0.957 \\
&\rho_{31, 32} = \sqrt{\frac{31}{32}} = 0.984 \qquad & \rho_{1, 32} = \sqrt{\frac{1}{32}} = 0.177
\end{align}

4. 模拟

  模拟随机游走过程,绘制序列和 ACF 如图 1、图 2。

set.seed(42)
x <- NULL
x[1] <- 0
for (i in 2:200) {
  x[i] <- x[i - 1] + rnorm(1)
}
x <- ts(x)
plot(x, main="Random Walk")

图 1

acf(x)

图 2

  由图 2 可见序列具有强自相关性,自相关随着滞后的增加而缓慢衰减。

5. 随机游走的一阶差分

  虽然随机游走式非平稳的,但对其进行一阶差分,得到

\begin{equation}
\nabla X_t = X_t – X_{t-1} = e_t
\end{equation}

可见 $\nabla X_t$ 是白噪声,它是平稳的。

  模拟随机游走的一阶差分,绘制序列和 ACF 如图 3、图 4。

x.diff <- diff(x)
plot(x.diff, main="Random Walk Diff")

图 3

acf(x.diff)

图 4

  由图 4 可见一阶差分后的序列只在滞后为 $0$ 时存在显著自相关。