I have a data with 4 columns, all has clear downward trend from 2020 to 2022. Except second column dickey fuller declare them stationary data.I believe due to clear trend all columns are non stationary, is it something i am missing to understand?
def Augmented_Dickey_Fuller_Test_func(series , column_name):
print (f'Results of Dickey-Fuller Test for column: {column_name}')
dftest = adfuller(series, autolag='AIC')
dfoutput = pd.Series(dftest[0:4], index=['Test Statistic','p-value','No Lags Used','Number of Observations Used'])
for key,value in dftest[4].items():
dfoutput['Critical Value (%s)'%key] = value
print (dfoutput)
if dftest[1] <= 0.05:
print("Conclusion:====>")
print("Reject the null hypothesis")
print("Data is stationary")
else:
print("Conclusion:====>")
print("Fail to reject the null hypothesis")
print("Data is non-stationary")
for name, column in df1.iteritems():
Augmented_Dickey_Fuller_Test_func(df1[name],name)
print('\n')
Results of Dickey-Fuller Test for column: ***
Test Statistic -3.877171
p-value 0.002209
No Lags Used 6.000000
Number of Observations Used 151.000000
Critical Value (1%) -3.474416
Critical Value (5%) -2.880878
Critical Value (10%) -2.577081
dtype: float64
Conclusion:====>
Reject the null hypothesis
Data is stationary
Results of Dickey-Fuller Test for column: ****
Test Statistic -2.854862
p-value 0.050854
No Lags Used 2.000000
Number of Observations Used 155.000000
Critical Value (1%) -3.473259
Critical Value (5%) -2.880374
Critical Value (10%) -2.576812
dtype: float64
Conclusion:====>
Fail to reject the null hypothesis
Data is non-stationary
Results of Dickey-Fuller Test for column: ****
Test Statistic -3.471590
p-value 0.008747
No Lags Used 5.000000
Number of Observations Used 152.000000
Critical Value (1%) -3.474121
Critical Value (5%) -2.880750
Critical Value (10%) -2.577013
dtype: float64
Conclusion:====>
Reject the null hypothesis
Data is stationary
Results of Dickey-Fuller Test for column: ****
Test Statistic -4.154383
p-value 0.000786
No Lags Used 6.000000
Number of Observations Used 151.000000
Critical Value (1%) -3.474416
Critical Value (5%) -2.880878
Critical Value (10%) -2.577081
dtype: float64
Conclusion:====>
Reject the null hypothesis
Data is stationary
Edit
We start to deliver product by end of each calendar year, while demand of product starts from 5 years back.For example , if we deliver product end of December 2021 then it means we have demand since 2016. Same for December 2022 we would have demand since 2017.We have 4 areas of production that's why you will see four colour in graph blue, yellow,green and red
I created a sequence for each year demands and transferred them from month to sequence, for example for delivery 2022 I created sequence since 2017
2017 Sequence 1-12
2018 Sequence 13-24
2019 Sequence 25-36
2020 Sequence 37-48
2021 Sequence 49-60
for each month from 1 to 60 , same for 2021
2016 Sequence 1-12
2017 Sequence 13-24
2018 Sequence 25-36
2019 Sequence 37-48
2020 Sequence 49-60
Following new graph , the trend for demand each year increasing but decreased due to post covid effect in 2021 and 2022.
I modelled using VARMAX with an order (60,1) and an exogenous variable "Covid". 1 for Covid and 0 for Non-Covid, 2015-2020 has 0 while 2021-2022 has 1 post covid effect.
2022 is for validation period (out sample forecasting) , model forecasted 2022 more magnitude than actual 2022 data.I believe this could be due to upward trend from 2015 to 2020, not sure how to handle this situation
Model is
var_model = VARMAX(train_df.iloc[:,2:6], order = (60,1),enforce_stationarity = True, exog = train_df['Covid'])
train_df.iloc[:,2:6] is four department/section , Covid is exogenous
n_forecast = test_df.shape[0]
predict = fitted_model.get_prediction(start=len(train_df),end=len(train_df) + n_forecast-1)
predictions=predict.predicted_mean
predictions
Following graph 2022 actual blue and predicted yellow for one of product out of 4.Rest 3 product forecasting is good , only one product has prediction way more than actual.Even model has learned that COVID 1 for 2021 which has low demand for this product, 2015 to 2020 is non covid indicated as 0 which has more demand
How can I influence 2022 prediction to predict less as it has COVID "1" like 2021