0

Pasty 很好地集成在 Statsmodels 中,允许基于 string 编写 R 风格的公式

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
==============================================================================

因此,搜索我要查找的参数非常麻烦。

有没有办法强制摘要输出以与推算字符串相同的顺序显示?

4

0 回答 0