【问题标题】:Do we need to do differencing of exogenous variables before passing to exog argument of SARIMAX() from statsmodels in Python?在从 Python 中的 statsmodels 传递到 SARIMAX() 的 exog 参数之前,我们是否需要对外生变量进行差分?
【发布时间】:2021-07-01 16:47:42
【问题描述】:

我正在尝试在 Python 中使用 SARIMAX 构建一个预测模型(带有 SARIMA 错误的回归),并且需要一些关于如何在 exog 参数中处理外生变量的指导。

默认参数为:

SARIMAX(endog, exog=None, order=(1, 0, 0), seasonal_order=(0, 0, 0, 0), trend=None, measurement_error=False, 
time_varying_regression=False, mle_regression=True, simple_differencing=False, enforce_stationarity=True,
enforce_invertibility=True, hamilton_representation=False, concentrate_scale=False, trend_offset=1,
use_exact_diffuse=False, dates=None, freq=None, missing='none', validate_specification=True, **kwargs)

这就是我安装模型的方式:

*在将 endog 和 exog 传递给 SARIMAX 函数之前,我没有转换变量。

SARIMAX(endog, exog=exog['TMIN_IAC'], order= (0,1,1), seasonal_order= (0,0,0,0), trend='c')

这是最终的总结:

                                SARIMAX Results                                
==============================================================================
Dep. Variable:                    all   No. Observations:                  151
Model:               SARIMAX(0, 1, 1)   Log Likelihood                -624.229
Date:                Mon, 05 Apr 2021   AIC                           1256.457
Time:                        14:36:48   BIC                           1268.500
Sample:                    01-31-2001   HQIC                          1261.350
                         - 07-31-2013                                         
Covariance Type:                  opg                                         
==============================================================================
                 coef    std err          z      P>|z|      [0.025      0.975]
------------------------------------------------------------------------------
intercept      0.2139      0.071      2.996      0.003       0.074       0.354
TMIN_IAC      -6.1222      0.474    -12.920      0.000      -7.051      -5.193
ma.L1         -0.9504      0.029    -33.060      0.000      -1.007      -0.894
sigma2       237.3801     33.036      7.185      0.000     172.631     302.130
===================================================================================
Ljung-Box (L1) (Q):                   0.25   Jarque-Bera (JB):                 2.21
Prob(Q):                              0.62   Prob(JB):                         0.33
Heteroskedasticity (H):               1.26   Skew:                            -0.08
Prob(H) (two-sided):                  0.42   Kurtosis:                         2.43
===================================================================================

我在documentation 中进行了搜索,但他们引用的最接近我的问题的是:

如果使用 simple_differencing = True,则在将模型置于状态空间形式之前,会先区分 endog 和 exog 数据。这与用户在构建模型之前对数据进行差异化具有相同的效果,这对使用结果有影响

我担心的是,根据 Alan Pankratz 在他的著作 Forecasting With Dynamic Regression Models (1991) 中的说法,如果对因变量和解释变量的多元回归中的误差应用差分应该有所不同,我不确定 Statsmodels 会自动做到这一点。

【问题讨论】:

    标签: python statsmodels arima state-space


    【解决方案1】:

    似乎来自 statsmodels 的 SARIMAX 也会自动区分响应和 exog 变量。

    根据 R 中 forecast 包中 Arima 函数的作者 Rob Hyndman 所说:

    Arima 将区分响应变量和 xreg 变量,如订单和季节参数中指定的那样。你永远不需要自己做差异化。

    所以我在 R 中运行了相同的模型并获得了相同的结果:

    Arima(endog, order = c(0,1,1),seasonal = c(0,0,0), xreg = exog, include.drift = TRUE,
    lambda = NULL, method = 'ML')
    

    模型总结:

    Regression with ARIMA(0,1,1) errors 
    
    Coefficients:
              ma1   drift  TMIN_IAC
          -0.9504  0.2139   -6.1219
    s.e.   0.0381  0.0724    0.4763
    
    sigma^2 estimated as 242.2:  log likelihood=-624.23
    AIC=1256.47   AICc=1256.74   BIC=1268.51
    

    【讨论】:

      猜你喜欢
      • 2018-08-30
      • 1970-01-01
      • 2020-08-06
      • 2018-06-25
      • 2021-10-12
      • 1970-01-01
      • 2021-09-03
      • 2021-03-26
      • 1970-01-01
      相关资源
      最近更新 更多