Time series - correlation and lag time

被刻印的时光 ゝ 提交于 2019-12-05 22:37:25

While part of the question is more statistics based, the bit about how to do it in Python seems at home here. I see that you've since decided to do this in R from looking at your question on Cross Validated, but in case you decide to move back to Python, or for the benefit of anyone else finding this question:

I think you were in the right area looking at statsmodels.tsa, but there's a lot more to it than just the ARMA package:

http://statsmodels.sourceforge.net/devel/tsa.html

In particular, have a look at statsmodels.tsa.vector_ar for modelling multivariate time series. The documentation for it is available here:

http://statsmodels.sourceforge.net/devel/vector_ar.html


The page above specifies that it's for working with stationary time series - I presume this means removing both trend and any seasonality or periodicity. The following link is ultimately readying a model for forecasting, but it discusses the Box-Jenkins approach for building a model, including making it stationary:

http://www.colorado.edu/geography/class_homepages/geog_4023_s11/Lecture16_TS3.pdf

You'll notice that link discusses looking for autocorrelations (ACF) and partial autocorrelations (PACF), and then using the Augmented Dickey-Fuller test to test whether the series is now stationary. Tools for all three can be found in statsmodels.tsa.stattools. Likewise, statsmodels.tsa.arma_process has ACF and PACF.

The above link also discusses using metrics like AIC to determine the best model; both statsmodels.tsa.var_model and statsmodels.tsa.ar_model include AIC (amongst other measures). The same measures seem to be used for calculating lag order in var_model, using select_order.


In addition, the pandas library is at least partially integrated into statsmodels and has a lot of time series and data analysis functionality itself, so will probably be of interest. The time series documentation is located here:

http://pandas.pydata.org/pandas-docs/stable/timeseries.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!