Message380446
from statsmodels.tsa.stattools import adfuller
adf = adfuller(x, regression=‘c’, autolag=‘t-stat’)
Sometimes comes error message:
UnboundLocalError: local variable ‘bestlag’ referenced before assignment
I found the reason: when using t-stat, bestlag is only assigned, when the last lag becomes significant the first time, so if no lag has a significant t-value, then bestlag is never assigned
I fixed this bug this way: open the file stattools.py and find the lines:
elif method == “t-stat”:
#stop = stats.norm.ppf(.95)
stop = 1.6448536269514722
Then add here following two lines:
bestlag = startlag
icbest = np.abs(results[startlag].tvalues[-1])
This way, the code won’t crash again and t-stat simply uses no lag when there is no significant value |
|
Date |
User |
Action |
Args |
2020-11-06 12:44:20 | gyllila | set | recipients:
+ gyllila |
2020-11-06 12:44:20 | gyllila | set | messageid: <1604666660.35.0.85933411244.issue42276@roundup.psfhosted.org> |
2020-11-06 12:44:20 | gyllila | link | issue42276 messages |
2020-11-06 12:44:20 | gyllila | create | |
|