[英]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.