as part of a time series analysis for my master thesis I want to test whether a time series is stationary with the Augmented Dickey-Fuller test in Python. I attached the result for one time series. While I do understand that this result means that the series is stationary, I do not get what the # of lags are. Does this mean that the series is only stationary if 13 lags are used? Do I need to transform the data? Help would be highly appreciated!
import statsmodels
from statsmodels.tsa.stattools import adfuller
import pandas as pd
import statsmodels.api as sm
from statsmodels.tsa.filters.hp_filter import hpfilter
class StationaryTests:
def __init__(self, significance=.05):
self.Significance
self.pValue = None
self.isStationary = None
def ADF_Stationarity_Test(self, timeseries, printResults = True):
#Dicky-Fuller tests:
#adfTest = adfuller(timeseries, maxlag = 1)
adfTest = adfuller(timeseries, autolag='AIC')
self.pValue = adfTest[1]
if (self.pValue<self.SignificanceLevel):
self.isStationary = True
else:
self.isStationary = False
if printResults:
dfResults = pd.adfTest[0:4], index=['ADF Test Statistic', 'P-Value', '# Lags Used', '# Observations Used'])
#Add Critical Values
for key,value in adfTest[4].items():
dfResults['Critical Value (%s)' %key] = value
print('Augmented Dickey-Fuller Test Results:')
print(dfResults)