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
| import numpy as np | |
| def variance_ratio(ts, lag = 2): | |
| """ | |
| Returns the variance ratio test result | |
| """ | |
| # make sure we are working with an array, convert if necessary | |
| ts = np.asarray(ts) | |
| # Apply the formula to calculate the test |
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 hurst(ts): | |
| """ | |
| Returns the Hurst Exponent of the time series vector ts | |
| """ | |
| # make sure we are working with an array, convert if necessary | |
| ts = np.asarray(ts) | |
| # Helper variables used during calculations | |
| lagvec = [] | |
| tau = [] |
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
| import numpy as np | |
| from statsmodels.regression.linear_model import OLS | |
| from statsmodels.tsa.tsatools import lagmat, add_trend | |
| from statsmodels.tsa.adfvalues import mackinnonp | |
| def adf(ts): | |
| """ | |
| Augmented Dickey-Fuller unit root test | |
| """ | |
| # make sure we are working with an array, convert if necessary |
NewerOlder