I try to fit Autoregression by sm.tsa.statespace.SARIMAX. But I meet a warning, then I want to set frequency information for this model. Who used to meet it, can you help me ?
If your data is really periodic and you don't have gaps in your time series, then pandas
can infer the frequency.
If the inferred frequency looks correct to you, you can use it by follow the answer at Set pandas.tseries.index.DatetimeIndex.freq with inferred_freq
For example
train.index = pd.DatetimeIndex(train.index.values,
freq=train.index.inferred_freq)
fit1 = sm.tsa.statespace.SARIMAX(...)
But note that this can still give a DatetimeIndex
whose frequency is None
if your data is not truly periodic.
For example, if you have daily data and one day is missing, then the inferred_freq
will be None
and attempting to pass freq="D"
will raise a ValueError
exception. In this case, try building your DataFrame
so that all dates are present and the values in the column(s) you're forecasting are None
on those dates. Then you can use missing="drop"
(or whatever) with your ARIMA
model.