在Statsmodels中很好地集成的Pasty允许编写R-style formulas based on string。
import statsmodels.formula.api as smf
res = smf.OLS.from_formula("Wealth ~ Age + Income + Happy", data=df).fit()
Print res.summary()
这将显示我的回归的摘要,但参数的顺序似乎不符合任何规则,例如:
OLS Regression Results
==============================================================================
Dep. Variable: Wealth R-squared: 0.309
Model: OLS Adj. R-squared: 0.283
Method: Least Squares F-statistic: 12.06
Date: Tue, 28 Feb 2017 Prob (F-statistic): 1.32e-06
Time: 21:36:08 Log-Likelihood: -377.13
No. Observations: 85 AIC: 762.3
Df Residuals: 81 BIC: 772.0
Df Model: 3
Covariance Type: nonrobust
===================================================================================
coef std err t P>|t| [0.025 0.975]
-----------------------------------------------------------------------------------
Intercept 38.6348 15.825 2.441 0.017 7.149 70.121
Income -0.3522 0.334 -1.056 0.294 -1.016 0.312
Age 0.4364 0.283 1.544 0.126 -0.126 0.999
Happy -0.0005 0.006 -0.085 0.933 -0.013 0.012
==============================================================================
Omnibus: 4.447 Durbin-Watson: 1.953
Prob(Omnibus): 0.108 Jarque-Bera (JB): 3.228
Skew: -0.332 Prob(JB): 0.199
Kurtosis: 2.314 Cond. No. 1.40e+04
==============================================================================
因此,搜索我正在寻找的参数非常麻烦。
有没有办法强制使用与插补字符串相同的顺序显示摘要输出?