Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
575 views
in Technique[技术] by (71.8m points)

statistics - How to compute Studentized Residuals in 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.

Thanks in advance.

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

from statsmodels.stats.outliers_influence import OLSInfluence

It has a resid_studentized_internal method included.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...