0
$\begingroup$

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?

enter image description here

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.

enter image description here

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

enter image description here

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

enter image description here How can I influence 2022 prediction to predict less as it has COVID "1" like 2021

$\endgroup$

1 Answer 1

3
$\begingroup$

The graph does not show presence of a unit root, and the ADF test confirms that. However, the time series is nonstationary due to seasonality plus perhaps a downward trend. You can model that without resorting to anything related to unit roots (no differencing needed).

$\endgroup$
5
  • $\begingroup$ "You can model that without resorting to anything related to unit roots (no differencing needed)." doe it mean without transferring data into stationary we can model time series modeling? $\endgroup$
    – user172500
    Aug 22, 2022 at 9:51
  • 1
    $\begingroup$ @user172500, mind the distinction between stationarity and absence of a unit root; the latter does not imply the former. You can model your data e.g. with seasonal dummies, Fourier terms or something else for the seasonality part. However, with only three years of data it will not be easy and your estimates of seasonality will be quite noisy. Regarding the downward trend, you can model it using e.g. a linear trend, but again with only three years of data your estimate will be noisy. There is not much you can do with only three years of data given presence of yearly seasonality... $\endgroup$ Aug 22, 2022 at 12:13
  • $\begingroup$ I have added more data. 2015 to 2021 training and 2022 validation, modelled using VARMAX with an order (50,1) also used an exogenous variable "Covid" ,1 for Covid and 0 for normal,2015-2020 has 0 while 2021-2022 has 1 post covid. 2022 forecasted more magnitude than actual 2022 data.Also used enforce_stationarity=True during training.I realised this could be due to upward trend from 2015 to 2020 and downward trend between 2021 and 2022.Please see updated question I included new graph in bottom for more clarity.Not sure enforce_stationarity working, how can I solve this problem? $\endgroup$
    – user172500
    Aug 22, 2022 at 12:39
  • 1
    $\begingroup$ @user172500, if your question has changed, please clarify that in the body of it, not just in a comment under an answer. $\endgroup$ Aug 22, 2022 at 13:58
  • $\begingroup$ I edited the original question please see Edit Section $\endgroup$
    – user172500
    Aug 23, 2022 at 2:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.