本文介绍了在Python中轻松访问标准化残差,cook值,hatvalues(杠杆)等?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在拟合线性回归后,我正在寻找影响力统计数据.在R中,我可以像这样获得它们:
I am looking for influence statistics after fitting a linear regression. In R I can obtain them (e.g.) like this:
hatvalues(fitted_model) #hatvalues (leverage)
cooks.distance(fitted_model) #Cook's D values
rstandard(fitted_model) #standardized residuals
rstudent(fitted_model) #studentized residuals
等
在拟合如下模型后,如何在Python中使用statsmodels时获得相同的统计信息:
How can I obtain the same statistics when using statsmodels in Python after fitting a model like this:
#import statsmodels
import statsmodels.api as sm
#Fit linear model to any dataset
model = sm.OLS(Y,X)
results = model.fit()
#Creating a dataframe that includes the studentized residuals
sm.regression.linear_model.OLSResults.outlier_test(results)
请参见下面的答案...
See answer below...
推荐答案
我在这里找到它:
OLSInfluence.summary_frame()
这篇关于在Python中轻松访问标准化残差,cook值,hatvalues(杠杆)等?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!