ValueWarning: No frequency information was provided, so inferred frequency MS will be used

前端 未结 1 1699
野的像风
野的像风 2021-02-19 04:19

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 ?

相关标签:
1条回答
  • 2021-02-19 05:08

    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.

    0 讨论(0)
提交回复
热议问题