Created
          July 13, 2021 11:46 
        
      - 
      
 - 
        
Save dBenedek/f15773abe844a56e0751cce905ea9093 to your computer and use it in GitHub Desktop.  
    [Stationary tests in Python] #python #tests #stationary #statistics
  
        
  
    
      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
    
  
  
    
  | # Example of the Augmented Dickey-Fuller unit root test | |
| from statsmodels.tsa.stattools import adfuller | |
| data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | |
| stat, p, lags, obs, crit, t = adfuller(data) | |
| print('stat=%.3f, p=%.3f' % (stat, p)) | |
| if p > 0.05: | |
| print('Probably not Stationary') | |
| else: | |
| print('Probably Stationary') | |
| # Example of the Kwiatkowski-Phillips-Schmidt-Shin test | |
| from statsmodels.tsa.stattools import kpss | |
| data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | |
| stat, p, lags, crit = kpss(data) | |
| print('stat=%.3f, p=%.3f' % (stat, p)) | |
| if p > 0.05: | |
| print('Probably not Stationary') | |
| else: | |
| print('Probably Stationary') | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment