回归与系数的显着性检查

时间:2015-09-15 18:55:43

标签: r regression statsmodels p-value significance

有人可以将我推荐给线性回归包,它不仅会运行回归,还会计算每个回归系数的显着性标准(标准/平均值),并将它们与适当的p值进行比较(Nk) ) “自由度”?或至少提供输出,可用于计算这样的?

理想情况下,对于Python,但也会使用R

谢谢!

2 个答案:

答案 0 :(得分:1)

在R中,lm()将拟合线性模型,summary()给出完整输出,包括系数估计,标准误差,t统计和p值。 https://stat.ethz.ch/R-manual/R-patched/library/stats/html/lm.html

答案 1 :(得分:1)

statsmodels提供线性回归和其他估算模型的所有标准推断。

以下输出是从此笔记本中复制的 http://statsmodels.sourceforge.net/stable/examples/notebooks/generated/formulas.html

博客中有一些解释:

http://www.datarobot.com/blog/multiple-regression-using-statsmodels/

mod = ols(formula='Lottery ~ Literacy + Wealth + Region', data=df)
res = mod.fit()
print(res.summary())
                            OLS Regression Results
==============================================================================
Dep. Variable:                Lottery   R-squared:                       0.338
Model:                            OLS   Adj. R-squared:                  0.287
Method:                 Least Squares   F-statistic:                     6.636
Date:                Tue, 02 Dec 2014   Prob (F-statistic):           1.07e-05
Time:                        12:52:16   Log-Likelihood:                -375.30
No. Observations:                  85   AIC:                             764.6
Df Residuals:                      78   BIC:                             781.7
Df Model:                           6
Covariance Type:            nonrobust
===============================================================================
                  coef    std err          t      P>|t|      [95.0% Conf. Int.]
-------------------------------------------------------------------------------
Intercept      38.6517      9.456      4.087      0.000        19.826    57.478
Region[T.E]   -15.4278      9.727     -1.586      0.117       -34.793     3.938
Region[T.N]   -10.0170      9.260     -1.082      0.283       -28.453     8.419
Region[T.S]    -4.5483      7.279     -0.625      0.534       -19.039     9.943
Region[T.W]   -10.0913      7.196     -1.402      0.165       -24.418     4.235
Literacy       -0.1858      0.210     -0.886      0.378        -0.603     0.232
Wealth          0.4515      0.103      4.390      0.000         0.247     0.656
==============================================================================
Omnibus:                        3.049   Durbin-Watson:                   1.785
Prob(Omnibus):                  0.218   Jarque-Bera (JB):                2.694
Skew:                          -0.340   Prob(JB):                        0.260
Kurtosis:                       2.454   Cond. No.                         371.
==============================================================================

Warnings:
[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.