![](/img/trans.png)
[英]Forecasting out-of-sample with exogenous variables using SARIMAX in Statsmodels -python
[英]Do we need to do differencing of exogenous variables before passing to exog argument of SARIMAX() from statsmodels in Python?
我正在嘗試在 Python 中使用 SARIMAX 構建預測 model(帶有 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)
這就是我安裝 model 的方式:
*在我將 endog 和 exog 傳遞給 SARIMAX function 之前,我沒有轉換變量。
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
===================================================================================
我在文檔中進行了搜索,但他們引用的最接近我的問題的是:
如果使用simple_differencing = True,則在將 model 置於狀態空間形式之前,會區分 endog 和 exog 數據。 這與用戶在構建 model 之前區分數據的效果相同,這對使用結果有影響
我擔心的是,根據 Alan Pankratz 在他的《使用動態回歸模型進行預測》 (1991 年)一書中的說法,如果對多元回歸中的誤差應用差分,則因變量和解釋變量都應該是不同的,我不確定 Statsmodels自動執行此操作。
似乎來自SARIMAX
的 SARIMAX 也會自動區分響應和 exog 變量。
根據 Rob Hyndman 的說法, Arima
function 在 R 中的forecast
package 的作者:
Arima
將區分訂單中指定的響應變量和 xreg 變量以及季節性 arguments。 您永遠不需要自己進行差異化。
所以我在 R 中運行了相同的 model 並獲得了相同的結果:
Arima(endog, order = c(0,1,1),seasonal = c(0,0,0), xreg = exog, include.drift = TRUE,
lambda = NULL, method = 'ML')
Model總結:
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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.