How to solve the problem when you create hourly model SARIMAX?

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)


There is code to create the model Sarimax. DataFrame hourly and hourly model is necessary.
When you create a model with the error:
----> 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 self faux_endog else._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.
April 19th 20 at 12:37
1 answer
April 19th 20 at 12:39
What it seems to me that the data you set and from the model require a build hourly models. Just try to clear this parameter.
all data have hourly indices

2013-05-01 00:00:00 13
2013-05-01 01:00:00 15
2013-05-01 02:00:00 11
2013-05-01 03:00:00 10
2013-05-01 04:00:00 17
...
- Ruben_Hammes commented on April 19th 20 at 12:42

Find more questions by tags Python