Last Update: June 21, 2022
My online video tutorials are hosted at YouTube channel.
For learning this concept, you can view my online video tutorials: ARIMA Models Identification: Correlograms in Python (Spyder) and ARIMA Models Identification: Correlograms in Python (Jupyter).
Videos Code
1. Packages
import pandas as pd
import statsmodels.api as sm
import statsmodels.graphics.tsaplots as tsp
import matplotlib.pyplot as plt
2. Data
mdata_obj = sm.datasets.get_rdataset(dataname="AirPassengers",
package="datasets",
cache=True)
mdata = mdata_obj.data
mdata = pd.DataFrame(data=mdata["value"]).set_index(
pd.date_range(start="1949", end="1961", freq="M"))
print(mdata.head())
print(mdata_obj.__doc__)
Ranges Delimiting
tdata = mdata[:"1958-12-31"]
fdata = mdata["1959-01-01":]
Chart
plt.plot(tdata)
plt.ylabel("Air Passengers")
plt.xlabel("Year")
plt.show()
3. ARIMA Models Identification
Correlograms
tsp.plot_acf(x=tdata, lags=24, alpha=0.05)
plt.show()
tsp.plot_pacf(x=tdata, lags=24, alpha=0.05)
plt.show()