Feng Li
School of Statistics and Mathematics
Central University of Finance and Economics
What do we mean by the expected value $E(Y_t)$?
Let the density of $Y_t$ be $f_{Y_t}$. The expected value is given by
For some time series the following holds
$$E(Y_t)=\underset{T\rightarrow\infty}{\lim}\frac{1}{T}\sum\limits_{t=1}^{T}y^{(i)}_t$$These time series are called ergodic for the mean.
Also do not confuse conditional and unconditional expections, i.e.
$$E(Y_t)\,\textrm{ is not equivalent to }\,E(Y_t|Y_{t-1},Y_{t-2},\dots)$$It is often convenient to put all variances and covariances into a matrix
$$\textrm{Var-Cov}(\mathbf{Y})=\begin{bmatrix}\textrm{Var}(Y_1) & \textrm{Cov}(Y_1,Y_2) &\cdots& \textrm{Cov}(Y_1,Y_T) \\ \textrm{Cov}(Y_1,Y_2)&\textrm{Var}(Y_2) &\cdots& \textrm{Cov}(Y_2,Y_T)\\\vdots&\vdots&\ddots&\vdots \\\textrm{Cov}(Y_1,Y_T)&\textrm{Cov}(Y_2,Y_T) &\cdots& \textrm{Var}(Y_T)\end{bmatrix}$$This is called the variance-covariance matrix.
If the following properties hold:
Then a series is weakly (or covariance) stationary
If the following property holds:
$$f(Y_{t},Y_{t+{j_1}},Y_{t+{j_1}},\dots,Y_{t+{j_n}}) \textrm{ only depends on } (j_1,j_2,\dots,j_n) \textrm { and not on time}$$Then a series is strongly stationary
Consider two processes:
$Y_t=0.2\times t+\epsilon_t$
$Y_t=\sum\limits_{i=1}^t\epsilon_i$
In both cases $\epsilon_t\overset{i.i.d}\sim N(0,\sigma^2)$
For the first process
$$\begin{aligned}E(Y_t)&=E(0.2t+\epsilon_t)\\&=E(0.2t)+E(\epsilon_t)\\&=0.2t+0=0.2t\end{aligned}$$Expected value depends on time. The series is nonstationary
Your turn: does the variance depend on time?
For the second process:
$$\begin{aligned}E(Y_t)&=E\left(\sum\limits_{i=1}^t\epsilon_i\right)\\&=\sum\limits_{i=1}^tE(\epsilon_i)\\&=\sum\limits_{i=1}^t0=0\end{aligned}$$Your turn: does the variance depend on time? Is this stationary or nonstationary?
import numpy as np
T=200
I=8
y_ex1 = np.random.standard_normal((I,T))
trend = 0.2*(np.arange(0,T)+1)
for i in range(I):
y_ex1[i,] = y_ex1[i,] + trend
y_ex1
array([[ 1.99181191, 0.74873099, 0.76237771, ..., 40.66073836, 40.0212313 , 41.0014318 ], [ 0.39736702, 1.91180765, 0.90328169, ..., 40.89142876, 40.656141 , 38.17984535], [-1.98823551, 0.49968108, 2.86359707, ..., 39.80940666, 39.47742127, 37.98607156], ..., [ 0.16828452, 0.24859632, -0.81146117, ..., 38.99058873, 39.83864486, 41.35192786], [-2.06178154, 0.92476329, 0.06123239, ..., 41.06975236, 38.93200457, 40.01663883], [-0.27183388, -1.55051855, 0.17579591, ..., 39.6672071 , 40.98419272, 41.60796254]])
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(25, 6))
for i in range(I):
#ax = f.add_subplot(I/2, 2, i + 1)
ax.plot(range(1,T+1),y_ex1[i,])
ax.axhline(y=0,color='red')
ax.axvline(x=T,color='black')
ax.axvline(x=1,color='black')
y_ex2 = np.random.standard_normal((I,T))
y_ex2 = np.cumsum(y_ex2,1)
fig, ax = plt.subplots(figsize=(25, 6))
for i in range(I):
#ax = f.add_subplot(I/2, 2, i + 1)
ax.plot(range(1,T+1),y_ex2[i,])
ax.axhline(y=0,color='red')
ax.axvline(x=T,color='black')
ax.axvline(x=1,color='black')
An MA(q) model is given by:
$Y_t=\epsilon_t+\theta_1\epsilon_{t-1}+\theta_2\epsilon_{t-2}+\dots+\theta_q\epsilon_{t-q}$
Or using lag operators:
$Y_t=(1+\theta_1L+\theta_2L^2+\dots+\theta_qL^q)\epsilon_t$
Or a more compact shorthand:
$Y_t=(1+\Theta(L))\epsilon_t$
We can (and often do) add an intercept, but I will leave it off for simplicity.
T=200
y=np.zeros(T)
epsilon=np.random.normal(0,0.1,T)
for i in range(1,T):
y[i]=epsilon[i]+0.8*epsilon[i-1]
fig, ax = plt.subplots(figsize=(25, 6))
ax.plot(np.arange(T),y)
[<matplotlib.lines.Line2D at 0x7f90ddb552e0>]
from statsmodels.graphics.tsaplots import plot_acf, plot_pacf
fig, ax = plt.subplots(1,2,figsize=(15,6))
plot_acf(y,ax=ax[0])
plot_pacf(y,ax=ax[1])
plt.show()
An AR(p) model is given by
$Y_t=\phi_1Y_{t-1}+\phi_2Y_{t-2}+\dots+\phi_pY_{t-p}+\epsilon_t$
Or using lag operators
$(1-\phi_1L-\phi_2L^2-\dots-\phi_pL^p)Y_t=\epsilon_t$
Or a more compact shorthand
$(1-\Phi(L))Y_t=\epsilon_t$
T=200
y=np.zeros(T)
epsilon=np.random.normal(0,0.1,T)
for i in range(1,T):
y[i]=0.8*y[i-1]+epsilon[i]
fig, ax = plt.subplots(figsize=(25, 6))
ax.plot(np.arange(T),y)
[<matplotlib.lines.Line2D at 0x7f90b55afe20>]
fig, ax = plt.subplots(1,2,figsize=(15,6))
plot_acf(y,ax=ax[0])
plot_pacf(y,ax=ax[1])
plt.show()
An ARMA(p,q) model is given by:
$Y_t=\phi_1Y_{t-1}+\phi_2Y_{t-2}+\dots+\phi_pY_{t-p}+\epsilon_t+\theta_1\epsilon_{t-1}+\theta_2\epsilon_{t-2}+\dots+\theta_q\epsilon_{t-q}$
Or using lag operators:
$(1-\phi_1L-\phi_2L^2-\dots-\phi_pL^p)Y_t=(1+\theta_1L+\theta_2L^2+\dots+\theta_qL^q)\epsilon_t$
Or a more compact shorthand:
$(1-\Phi(L))Y_t=(1+\Theta(L))\epsilon_t$
T=200
y=np.zeros(T)
epsilon=np.random.normal(0,0.1,T)
for i in range(1,T):
y[i]=0.8*y[i-1]+epsilon[i]+0.7*epsilon[i-1]
fig, ax = plt.subplots(figsize=(25, 6))
ax.plot(np.arange(T),y)
[<matplotlib.lines.Line2D at 0x7f90b5411be0>]
from statsmodels.graphics.tsaplots import plot_acf, plot_pacf
fig, ax = plt.subplots(1,2,figsize=(15,6))
plot_acf(y,ax=ax[0])
plot_pacf(y,ax=ax[1])
plt.show()
I
in ARIMA¶We also write that a model is ARIMA(p,d,q) where
The Box Jenkins method has the following steps