Time Series 简明教程

Time Series - Moving Average

对于平稳时间序列,移动平均模型将时间“t”处变量的值视为前“q”时间步长残差误差的线性函数。残差误差是通过将时间“t”处的值与前面值的移动平均值进行比较来计算的。

For a stationary time series, a moving average model sees the value of a variable at time ‘t’ as a linear function of residual errors from ‘q’ time steps preceding it. The residual error is calculated by comparing the value at the time ‘t’ to moving average of the values preceding.

在数学上可以写成 −

Mathematically it can be written as −

y_{t} = c\:+\:\epsilon_{t}\:+\:\theta_{1}\:\epsilon_{t-1}\:+\:\theta_{2}\:\epsilon_{t-2}\:+\:…​+:\theta_{q}\:\epsilon_{t-q}\:

y_{t} = c\:+\:\epsilon_{t}\:+\:\theta_{1}\:\epsilon_{t-1}\:+\:\theta_{2}\:\epsilon_{t-2}\:+\:…​+:\theta_{q}\:\epsilon_{t-q}\:

其中“q”是移动平均趋势参数

Where‘q’ is the moving-average trend parameter

\epsilon_ {t} 是白噪声,并且

$\epsilon_{t}$ is white noise, and

$\epsilon_{t-1}, \epsilon_{t-2}…​\epsilon_{t-q}$ 是前一时间段的误差项。

$\epsilon_{t-1}, \epsilon_{t-2}…​\epsilon_{t-q}$ are the error terms at previous time periods.

“q”的值可以使用多种方法进行校准。找到“q”的恰当值的一种方法是绘制偏自相关图。

Value of ‘q’ can be calibrated using various methods. One way of finding the apt value of ‘q’ is plotting the partial auto-correlation plot.

与显示直接和间接相关性的自相关图不同,偏自相关图显示变量与其自身在之前时间步长的关系,同时消除了间接相关性,让我们看看它对我们数据的“temperature”变量有何影响。

A partial auto-correlation plot shows the relation of a variable with itself at prior time steps with indirect correlations removed, unlike auto-correlation plot which shows direct as well as indirect correlations, let’s see how it looks like for ‘temperature’ variable of our data.

Showing PACP

[143] 中:

In [143]:

from statsmodels.graphics.tsaplots import plot_pacf

plot_pacf(train, lags = 100)
plt.show()
code snippet10

偏自相关以与相关图相同的方式进行读取。

A partial auto-correlation is read in the same way as a correlogram.