3
$\begingroup$

17.7736 17.7736 17.7638 17.7638 17.754 17.754 17.7834 17.7834 17.7834 17.7834 17.7834 17.7834 17.7834 17.7834 17.8324 17.8324 17.8324 17.852 17.9304 17.9304 17.9304 18.1166 18.1166 18.1166 18.1166 18.1166 18.1166 18.1166 18.1362 18.146 18.146 18.1656 18.1754 18.1656 18.1656 18.1656 18.1656 18.1656 18.146 18.1362 18.1362 18.1656 18.1656 18.1656 18.1264 18.1264 18.1264 18.1264 18.1264 18.1166 18.1166 18.1166 18.1166 18.1166 18.1166 18.1166 18.1166 18.1166 18.1264 18.1264 18.1264 18.1264 18.1

I think this dataset is stationary because the values very near with each other But the surprise when using the Kpss test with this code show that this is not stationary . What is the wrong please I am very confuse

# KPSS test
from statsmodels.tsa.stattools import kpss
#57358

data = pd.read_csv("C:/Users/3800.txt") #, header=0, index_col=0) 

def kpss_test(data, **kw):    
    statistic, p_value, n_lags, critical_values = kpss(data, **kw)
    # Format Output
    print(f'KPSS Statistic: {statistic}')
    print(f'p-value: {p_value}')
   # print(f'num lags: {n_lags}')
    print('Critial Values:')
        
    for key, value in critical_values.items():
        print(f'   {key} : {value}')
                
    print(f'Result: The series is {"not " if p_value < 0.05 else ""}stationary')
 
kpss_test(data)
$\endgroup$

2 Answers 2

7
$\begingroup$

Have you plotted your data? I did. Does it look stationary or “almost stationary” to you?

$\endgroup$
7
  • $\begingroup$ +1 skimming the numbers, it looked like this kind of trend was present. $\endgroup$
    – Dave
    Commented Aug 31, 2022 at 23:00
  • $\begingroup$ @oleva Do these tests have the same null hypothesis? $\endgroup$
    – dipetkov
    Commented Sep 1, 2022 at 11:27
  • $\begingroup$ @dipetkov.No, it have not! $\endgroup$
    – ayla
    Commented Sep 1, 2022 at 11:56
  • $\begingroup$ Could you check the update please? why this difference? I used another dataset $\endgroup$
    – ayla
    Commented Sep 1, 2022 at 12:15
  • $\begingroup$ @oleva You are focusing on the numbers returned by the tests rather than on what the tests are supposed to test. It will help to start with theory and understand it first. $\endgroup$
    – dipetkov
    Commented Sep 1, 2022 at 12:18
3
$\begingroup$

I didn’t count how many points you have, but it looks like “a lot” is a good description.

When you have “a lot” of points, hypothesis tests have the to reject small deviations from the null hypothesis, even deviations so small that they are not of any practical consequence.

This could be what you’re seeing: you’re right that the time series is just about stationary, and the formal test is catching that the time series is not quite exactly stationary.

(I’m not actually convinced that “almost stationary” applies to your time series, but if it does, the test is catching that it is almost stationary, not perfectly stationary.)

$\endgroup$
3
  • $\begingroup$ Could you check the update please? why this difference? $\endgroup$
    – ayla
    Commented Sep 1, 2022 at 12:15
  • $\begingroup$ @oleva It’s really not fair to answerers (or future readers) to make the question a moving target. If you have a new question (and yours is totally legitimate), please post it $\endgroup$
    – Dave
    Commented Sep 1, 2022 at 12:38
  • $\begingroup$ Yes, that's right, I modified it, I know it is not permissible, but I asked before and did not get an answer, so I thought I would get the answer here. $\endgroup$
    – ayla
    Commented Sep 1, 2022 at 12:51

Your Answer

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

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