On stationarity detection of time series

Stationary test of time series

The research and processing of time series is actually quite interesting. Most of the time it’s just playing hooligans. We assume that there are rules, and then study it. When God opens his eyes, we can always find something to justify it, hehe.
The timing model of the ARIMA family is always indispensable for the detection of timing stability. Why does it require the time series to be stable? Because this model is linear. In order to avoid the uncontrollable influence of nonlinear factors on the prediction, I will block these nonlinear factors in advance. If they are blocked, it will not affect it, and then you can model happily.
Today, let’s talk about how to detect the stationarity of time series.


1 observation

Just draw the time series and see if it fluctuates around a certain mean value. If it is, then it is stable;


2 ACF、PACF

Although the observation method does not require hands-on work and protects the vital interests of the vast number of developers, there are always people who question it. It would be bad if you have some personal grievances. So someone came up with a good way: draw a picture, draw the ACF and PACF of the time series, the picture can always be clear at a glance.

2.1 ACF

  • ACF censored . That is, the autocorrelation coefficient eventually tends to 0, the truncation point is the first point, and q is the number. At this time, the timing is stable.
  • ACF trailing - triangular symmetry . It shows that the timing is monotonic.
  • ACF smear - sinusoidal fluctuations . It shows that the timing is periodic.

Censored (q=7):
ACF censored
Tailing (sinusoidal fluctuations):
ACF smear

2.2 PACF

It is only judged that the timing is stable and unstable, and PACF is not used. Not much to say, and neither will we.


3 Unit root test of Dragon Slayer

I observed and observed, and drew pictures. What are the shortcomings? Yes, it is the theoretical basis. At this time, we have to resort to the unit root test.

from statsmodels.tsa.stattools import adfuller

The unit root test will get a pvalue. If the pvalue is less than 0.05, the null hypothesis is rejected and the time series is stable. If it is much larger than 0.05, find the difference again.
One thing to note here is that every time a difference is made, a sequence value will be lost, so when finding the unit root, remember to dropnaremove the null value.


These three methods should be the eight [doge]

Guess you like

Origin blog.csdn.net/qq_42774234/article/details/131641993