Answer the question
In order to leave comments, you need to log in
How to solve the problem when creating an hourly SARIMAX model?
index_start_train = '2013-05-01 00:00:00'
index_finish_train = '2013-06-01 00:00:00'
index_start_pred = '2013-06-01 00:00:00'
index_finish_pred = '2013-07-01 00:00:00'
data_time_train = data[index_start_train:index_finish_train]
data_time_train.index = pd.DatetimeIndex(data_time_train.index.values, freq=data_time_train.index.inferred_freq)
model_arima = SARIMAX(data_time_train, order=(1, 1, 1), freq = "H").fit(full_output = False, disp = 0)
----> 5 model_arima = SARIMAX(data_time_train, order=(1, 1, 1), freq = "H").fit(full_output = False, disp = 0)
6 # pred_arima = model_arima.predict(index_start_train, index_finish_pred )
7
/usr/local/lib/python3.7/site-packages/statsmodels/tsa/statespace/sarimax.py in __init__(self, endog, exog, order, seasonal_order, trend, measurement_error, time_varying_regression, mle_regression, simple_differencing, enforce_stationarity , enforce_invertibility, hamilton_representation, concentrate_scale, trend_offset, use_exact_diffuse, dates, freq, missing, **kwargs)
330 trend=trend, enforce_stationarity=None, enforce_invertibility=None,
331 concentrate_scale=concentrate_scale, dates=dates, freq=freq,
--> 332 missing=missing)
333 self._params = SARIMAXParams(self._spec)
334
/usr/local/lib/python3.7/site-packages/statsmodels/tsa/arima/specification.py in __init__(self, endog , exog, order, seasonal_order, ar_order, diff, ma_order, seasonal_ar_order, seasonal_diff, seasonal_ma_order, seasonal_periods, trend, enforce_stationarity, enforce_invertibility, concentrate_scale, trend_offset, dates, freq, missing)
419 # providing us with a time series index
420 self._model = TimeSeriesModel(endog, exog=exog, dates=dates, freq=freq,
--> 421 missing=missing)
422 self.endog = None if faux_endog else self._model.endog
423 self.exog = self._model.exog
/usr/local/lib/python3.7/site-packages/statsmodels/tsa/base/tsa_model.py in __init__(self, endog, exog, dates, freq, missing, * *kwargs)
48
49 # Date handling in indexes
---> 50 self._init_dates(dates, freq)
51
52 def _init_dates(self, dates=None, freq=None):
/usr/local/lib/python3.7/ site-packages/statsmodels/tsa/base/tsa_model.py in _init_dates(self, dates, freq)
182 start=index[0], end=index[-1], freq=freq)
183 if not inferred_freq and not resampled_index. equals(index):
--> 184 raise ValueError('The given frequency argument could'
185 ' not be matched to the given index.')
186 index = resampled_index
ValueError: The given frequency argument could not be matched to the given index.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question