简体   繁体   English

StatsModels SARIMAX with exogenous variables - 如何提取外生系数

[英]StatsModels SARIMAX with exogenous variables - how to extract exogenous coefficients

I fit a statsmodels SARIMAX model to my data, leveraging some exogenous variables.我利用一些外生变量将 statsmodels SARIMAX model 拟合到我的数据中。

How to extract the fitted regression parameters for the exogenous variables?如何提取外生变量的拟合回归参数? It is clear per documentation how to get AR, MA coefficients, but nothing about exog coefficients.根据文档很清楚如何获得 AR、MA 系数,但没有关于 exog 系数的信息。 Any advice?有什么建议吗?

Code snippet below:下面的代码片段:

#imports
import pandas as pd
from statsmodels.tsa.statespace.sarimax import SARIMAX
#X and Y variables, index as dates, X has several columns with exog variables
X = df[factors]
Y = df[target]

#lets fit it
model= SARIMAX(endog=Y[:'2020-04-13'], exog = X[:'2020-04-13'], order = (5,2,1))

#fit the model
model_fit = model.fit(disp=0)
#get AR coefficients
model_fit.polynomial_ar

There isn't a specific attribute for this, but you can always access all parameters using the model_fit.params attribute.这没有特定的属性,但您始终可以使用model_fit.params属性访问所有参数。

For the SARIMAX model, the exog parameters are always right after any trend parameters, so the following should always work:对于 SARIMAX model, exog参数总是紧跟在任何趋势参数之后,因此以下应该始终有效:

exog_params = model_fit.params[model.k_trend:model.k_trend + model.k_exog]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 具有外生变量矩阵的statsmodels SARIMAX大小不同 - statsmodels SARIMAX with exogenous variables matrices are different sizes 在 Statsmodels -python 中使用 SARIMAX 预测具有外生变量的样本外 - Forecasting out-of-sample with exogenous variables using SARIMAX in Statsmodels -python 如何使用 statsmodels 的 ARMA 来预测外生变量? - How to use statsmodels' ARMA to predict with exogenous variables? Sarimax 内生和外生变量 - 前提是外生值的形状不合适 - Sarimax endogenous and exogenous variables - Provided exogenous values are not of the appropriate shape 在从 Python 中的 statsmodels 传递到 SARIMAX() 的 exog 参数之前,我们是否需要对外生变量进行差分? - Do we need to do differencing of exogenous variables before passing to exog argument of SARIMAX() from statsmodels in Python? 使用python statsmodels修复summary_col中的标签外生变量 - Fix Label Exogenous Variables in summary_col with python statsmodels Python Statsmodels:将SARIMAX与外生回归变量一起使用以获取预测的均值和置信区间 - Python Statsmodels: Using SARIMAX with exogenous regressors to get predicted mean and confidence intervals SARIMAX 外生数据样本外预测 - SARIMAX out of sample forecast with exogenous data 使用 Statsmodels -python 中的时变回归示例代码预测具有外生变量的样本外 - Forecasting out-of-sample with exogenous variables using Time-varying regression example code in Statsmodels -python ValueError:提供的外生值不适合 SARIMAX model - ValueError: Provided exogenous values are not of the appropriate shape for SARIMAX model
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM