Python ARIMA time series model used to explain the process of

Today small for everyone to share an article on the ARIMA model to explain the use of time-series processing of Python, Xiao Bian feel very good content, now for everyone to share, have a good reference value, a friend in need to follow the small series with a look Look
ARIMA model

Full ARIMA model is autoregressive moving average model, a commonly used statistical models to predict time series, generally referred to as ARIMA (p, d, q).

Adaptation of ARIMA

ARIMA model is relatively simple to use. In applying the ARIMA model, to ensure the following:

Time series data is relatively stable, substantially constant overall rise absent or decreased, it may be unstable if a differential manner by stabilized.
Non-linear processing not only linear processing
determines the timing data is stable

The basic determination method: stability data, there is no generally rising and falling trend, there is no periodicity, variance tends to a stable value.

ARIMA mathematical expression

ARIMA (p, d, q), where p is the number of lags the data itself, i.e. is autoregressive model AR model parameters. d is the difference a few time-series data required to get stable data. q is the number of lags prediction error, i.e., the model MA is slidably average model parameters.

a) p AR model parameters

AR model describes the relationship between the current value and the historical value, AR model of order p hysteresis can be expressed as: Here Insert Picture Description
where u is a constant, et represents the error.

b) q model parameters MA

MA model describes the relationship between the current value from the cumulative error of the regression portion, MA lag model of order q may be expressed as: Here Insert Picture Description
where u is a constant, et represents the error.

c) d and the differential parameter

First difference: Here Insert Picture Description
second order difference: Here Insert Picture Description
D) the ARIMA the AR + MA = Here Insert Picture Description
the ARIMA model using procedure

Acquiring time series data
observed whether the data is smooth, or differential, into a stationary timing data to determine D
PACF p and q is determined by observing the autocorrelation coefficients of the autocorrelation coefficients ACF and Partial Here Insert Picture Description
obtained after p, D, q using ARIMA ( p, d, q) is trained to predict
Python calls ARIMA

#差分处理
diff_series = diff_series.diff(1)#一阶
diff_series2 = diff_series.diff(1)#二阶
#ACF与PACF
#从scipy导入包
from scipy import stats
import statsmodels.api as sm
#画出acf和pacf
sm.graphics.tsa.plot_acf(diff_series)
sm.graphics.tsa.plot_pacf(diff_series)
#arima模型
from statsmodels.tsa.arima_model import ARIMA
model = ARIMA(train_data,order=(p,d,q),freq='')#freq是频率,根据数据填写
arima = model.fit()#训练
print(arima)
pred = arima.predict(start='',end='')#预测

We recommend learning Python buckle qun: 913066266, look at how seniors are learning! From basic web development python script to, reptiles, django, data mining, etc. [PDF, actual source code], zero-based projects to combat data are finishing. Given to every little python partner! Every day, Daniel explain the timing Python technology, to share some of the ways to learn and need to pay attention to small details, click on Join us python learner gathering
summary

That's all for this article, I hope the contents of this paper has some reference value of learning for everyone to learn or work

Published 47 original articles · won praise 53 · views 50000 +

Guess you like

Origin blog.csdn.net/haoxun03/article/details/104270297