Created
June 26, 2020 11:01
-
-
Save Knk00/cb9976178180b8086699a647315e0062 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def ADF_test (self, series): | |
adf = adfuller(series) | |
print('ADF test') | |
print("\tADF Statistic: {}\n".format (adf[0])) | |
print("\tp-value: {}\n".format (adf[1])) #Since the p-value is far from 0.05 it not stationary | |
print ("\tCritical values : \n") | |
for key, value in adf[4].items(): | |
print("\t\t{} : {}\n".format(key, value)) | |
if (adf[1] < 0.05): | |
print('Reject the null hypothesis') | |
print('Series is Stationary') | |
else: | |
print('Failed to reject the null hypothesis') | |
print('Series is Non-Stationary') | |
return adf | |
def hodrick_prescott(self, series, lamb = 6.25): | |
df = series.to_frame() | |
cycle, trend = hpfilter(series, lamb= lamb) | |
df['cycle'], df['trend'] = cycle, trend | |
return df | |
'''Helper Fuctions for Seasonal Decomposition''' | |
def ets_Decomposition_multiplicative(self, series): | |
result = seasonal_decompose(series, model = 'multiplicative') | |
return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment