Hello there:
I am currently enrolled in the course "Financial time series analysis for trading", and I saw that in order to obtain the number of lags for a time series, we need to plot the ACF and PACF, but I was wondering…
Is there any other way of obtaining the number of lags other than just looking at the plots??
I was wondering if there may be a code in order to do So but without the plots, so That I can construct the let's say the ARIMA model for a particular time series… and see how to use it directly to forecast the time series at a future time… Is that possible??
Thanks
Hi Ghery,
We need Auto-Correlation Function (ACF) and Partial Auto-Correlation Function (PACF) to identify the order for an ARMA model.
In our course, we plotted ACF and PACF chats to visually tell what are the significant lag terms and what could be the correct order for our ARMA model. We can do the same without the use of plots, using the acf and pacf function from the statsmodels.tsa.stattools library. These functions will return NumPy arrays.
To know more check the documentation of acf and pacf functions.
- Documentation of acf: https://www.statsmodels.org/dev/generated/statsmodels.tsa.stattools.acf.html
- Documentation of pacf: https://www.statsmodels.org/dev/generated/statsmodels.tsa.stattools.pacf.html
I hope this helps!
Hello Ghery,
It's good to know that you are learning about time series.
The use of ACF and PACF is one of the steps involved in what is called "Box-Jenkins Methodology". This is the most well-known methodology in econometrics to find the optimal parameters of an ARMA model.
However, to find the optimal parameters through coding, researchers do something different:
- Compute various ARMA models for the asset prices.
- For each model, compute any of the two following Information criterias: BIC or AIC.
- Choose the model which has the lowest BIC or AIC.
There's a package in R called "forecast" that has the method "auto.rima" which makes this process for you. Check this article to do the same in python.
In case you have more questions, please let us know,
Thanks and regards,
Jose Carlos