-
-
Notifications
You must be signed in to change notification settings - Fork 68
Not able to run #10
Description
I added below :
import statsmodels
from statsmodels.tsa.stattools import adfuller
in first input.
Then I tested the code till :
#Stationarity test
def test_stationarity(timeseries):
...
...
I got stuck with this error message :
Results of dickey fuller test
---------------------------------------------------------------------------
MissingDataError Traceback (most recent call last)
Input In [102], in <cell line: 27>()
25 else:
26 print("Weak evidence against null hypothesis, time series is non-stationary ")
---> 27 test_stationarity(train['Close'])
`Input In [102], in test_stationarity(timeseries)` ` 16 plt.show(block = False)` ` 18 print('Results of dickey fuller test')` `---> 19 result = adfuller(timeseries, autolag = 'AIC')` ` 20 labels = ['ADF Test Statistic','p-value','#Lags Used','Number of Observations Used']` ` 21 for value,label in zip(result, labels):`
File ~/.local/lib/python3.10/site-packages/statsmodels/tsa/stattools.py:321, in adfuller(x, maxlag, regression, autolag, store,regresults)
315 # 1 for level
316 # search for lag length with smallest information criteria
317 # Note: use the same number of observations to have comparable IC
318 # aic and bic: smaller is better
320 if not regresults:
--> 321 icbest, bestlag = _autolag(
322 OLS, xdshort, fullRHS, startlag, maxlag, autolag
323 )
324 else:
325 icbest, bestlag, alres = _autolag(
326 OLS,
327 xdshort,
(...)
332 regresults=regresults,
333 )
`File ~/.local/lib/python3.10/site-packages/statsmodels/tsa/stattools.py:129, in _autolag(mod, endog, exog, startlag, maxlag,
method, modargs, fitargs, regresults)
127 method = method.lower()
128 for lag in range(startlag, startlag + maxlag + 1):
--> 129 mod_instance = mod(endog, exog[:, :lag], *modargs)
130 results[lag] = mod_instance.fit()
132 if method == "aic":``
File ~/.local/lib/python3.10/site-packages/statsmodels/regression/linear_model.py:906, in OLS.init(self, endog, exog, missing, hasconst, **kwargs)` ` 903 msg = ("Weights are not supported in OLS and will be ignored"` ` 904 "An exception will be raised in the next version.")` ` 905 warnings.warn(msg, ValueWarning)` `--> 906 super(OLS, self).__init__(endog, exog, missing=missing,` ` 907 hasconst=hasconst, **kwargs)` ` 908 if "weights" in self._init_keys:` ` 909 self._init_keys.remove("weights")`
File ~/.local/lib/python3.10/site-packages/statsmodels/regression/linear_model.py:733, in WLS.__init__(self, endog, exog, ``weights, missing, hasconst, **kwargs)
731 else:
732 weights = weights.squeeze()
--> 733 super(WLS, self).__init__(endog, exog, missing=missing,
734 weights=weights, hasconst=hasconst, **kwargs)
735 nobs = self.exog.shape[0]
736 weights = self.weights
`File ~/.local/lib/python3.10/site-packages/statsmodels/regression/linear_model.py:190, in RegressionModel.__init__(self, endog,
exog, **kwargs)
189 def init(self, endog, exog, **kwargs):
--> 190 super(RegressionModel, self).init(endog, exog, **kwargs)
191 self._data_attr.extend(['pinv_wexog', 'wendog', 'wexog', 'weights'])``
File ~/.local/lib/python3.10/site-packages/statsmodels/base/model.py:267, in LikelihoodModel.init(self, endog, exog, **kwargs)` ` 266 def __init__(self, endog, exog=None, **kwargs):` `--> 267 super().__init__(endog, exog, **kwargs)` ` 268 self.initialize()`
File ~/.local/lib/python3.10/site-packages/statsmodels/base/model.py:92, in Model.__init__(self, endog, exog, **kwargs)
90 missing = kwargs.pop('missing', 'none')
91 hasconst = kwargs.pop('hasconst', None)
---> 92 self.data = self._handle_data(endog, exog, missing, hasconst,
93 **kwargs)
94 self.k_constant = self.data.k_constant
95 self.exog = self.data.exog
`File ~/.local/lib/python3.10/site-packages/statsmodels/base/model.py:132, in Model._handle_data(self, endog, exog, missing,
hasconst, **kwargs)
131 def _handle_data(self, endog, exog, missing, hasconst, **kwargs):
--> 132 data = handle_data(endog, exog, missing, hasconst, **kwargs)
133 # kwargs arrays could have changed, easier to just attach here
134 for key in kwargs:``
File ~/.local/lib/python3.10/site-packages/statsmodels/base/data.py:700, in handle_data(endog, exog, missing, hasconst, **kwargs)` ` 697 exog = np.asarray(exog)` ` 699 klass = handle_data_class_factory(endog, exog)` `--> 700 return klass(endog, exog=exog, missing=missing, hasconst=hasconst,` ` 701 **kwargs)`
File ~/.local/lib/python3.10/site-packages/statsmodels/base/data.py:88, in ModelData.__init__(self, endog, exog, missing, ``hasconst, **kwargs)
86 self.const_idx = None
87 self.k_constant = 0
---> 88 self._handle_constant(hasconst)
89 self._check_integrity()
90 self._cache = {}
`File ~/.local/lib/python3.10/site-packages/statsmodels/base/data.py:134, in ModelData._handle_constant(self, hasconst)` ` 132 exog_max = np.max(self.exog, axis=0)` ` 133 if not np.isfinite(exog_max).all():` `--> 134 raise MissingDataError('exog contains inf or nans')` ` 135 exog_min = np.min(self.exog, axis=0)` ` 136 const_idx = np.where(exog_max == exog_min)[0].squeeze()`
MissingDataError: exog contains inf or nans
`train_log = np.log(`
I give up for formatting. God knows, how this type of error stack can be provided to developer. Height of frustration.