如何在 Python 中计算学生化残差? [英] How to compute Studentized Residuals in Python?

查看:30
本文介绍了如何在 Python 中计算学生化残差?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试寻找这个问题的答案,但到目前为止我还没有找到任何答案.我使用 statsmodel 在均值插补数据集上实现了普通最小二乘回归模型.我可以访问 OLS 结果中的残差列表,但不能访问学生化残差.如何计算/获得学生化残差?我知道计算学生残差的公式,但我不确定如何在 Python 中编写此公式.

I've tried searching for an answer to this problem but so far I haven't found any. I used statsmodel to implement an Ordinary Least Squares regression model on a mean-imputed dataset. I can access the list of residuals in the OLS results, but not studentized residuals. How can I calculate/get studentized residuals? I know the formula for calculating studentized residuals but I'm not exactly sure how to code this formula in Python.

提前致谢.

更新:我找到了答案.我可以从 OLS reults 的 outlier_test() 函数中获得一个包含学生化残差的数据框.

UPDATE: I've found the answer. I can get a dataframe containing the studentized residuals from the outlier_test() function from OLS reults.

推荐答案

我正在处理同样的问题.解决方案是使用 statsmodels 库:

I was dealing with the same issue. The solution is to use the statsmodels library:

from statsmodels.stats.outliers_influence import OLSInfluence

它包含一个 resid_studentized_internal 方法.

这篇关于如何在 Python 中计算学生化残差?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆