statespace.SARIMAX 模型:为什么模型使用所有数据来训练模式,并预测训练模型的范围

2022-01-11 00:00:00 python statsmodels time-series

问题描述

我按照教程学习了 SARIMAX 模型: 有影响.或者换句话说,如果您有每日数据并且 p 为 6,您可以理解为周二数据是否会影响周日数据.

  • d.差分参数.它定义了您的流程的集成级别.这意味着您应该应用多少次时间序列差分运算符以使您的时间序列平稳
  • 问.您可以将其解释为有多少先前的噪声(错误)影响当前值
  • 这里有一个很好的答案你可以找到非季节性成分值

    I followed the tutorial to study the SARIMAX model: https://www.digitalocean.com/community/tutorials/a-guide-to-time-series-forecasting-with-arima-in-python-3. The date range of data is 1958-2001.

    mod = sm.tsa.statespace.SARIMAX(y,
                                    order=(1, 1, 1),
                                    seasonal_order=(1, 1, 1, 12),
                                    enforce_stationarity=False,
                                    enforce_invertibility=False)
    
    results = mod.fit()
    

    when are fitting an ARIMA Time Series Model, I found the author all date range data to fit parameter of model. But when validating Forecasts, the author used date started from 1998-01-01 as one part of date range of data for fitting model.

    pred = results.get_prediction(start=pd.to_datetime('1998-01-01'), dynamic=False)
    

    I know in machine learning model, the training data and validation(test) data is different, I mean different range. I mean the author is right? why do like this(I mean the reason touse all train data), I a new one to SARIMAX model.

    Could you guys tell me more about this model, for example how about predict days or weeks not just month, I mean how to set the parameter of order=(1,1,1), seasonal_order=(1, 1, 1, 12). Thanks!

    解决方案

    The author is right. When you do a regression (linear, higher-order or logistic - doesn't matter) - it is absolutely ok to have deviations from your training data (for instance - logistic regression even on training data may give you a false positive).

    Same stands for time series. I think this way the author wanted to show that the model is built correctly.

    seasonal_order=(1, 1, 1, 12)
    

    If you look at tsa stats documentation you will see that if you want to operate with quarterly data - you have to assign the last parameter (s) - value of 4. Monthly - 12. It means that if you want to operate with weekly data seasonal_order should look like this

    seasonal_order=(1, 1, 1, 52)
    

    daily data will be

    seasonal_order=(1, 1, 1, 365)
    

    order component is the parameter that is responsible for non-seasonal parameters p, d and q respectively. You have to find them depending on your data behaviour

    • p. You can interpret it as wether has an influence on . Or in other words, if you have a daily data and p is 6 you can understand it as wether Tuesday data will have an influence on Sunday data.
    • d. Differencing parameter. It defines the level of integration of your process. It means how many times you should apply time series differencing operator in order to make your time series stationary
    • q. You can interpret it as how many prior noises (errors) affect the current value

    Here is a good answer how you can find non-seasonal component values

    相关文章