You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sorry to bother you all but I was wondering, in the outliers_influence.py file in statsmodels 0.6.1, I see the following formula for the studentized residuals in get_resid_studentized_external():
@noahjgreen295 I'm (pretty) sure the formula is correct with dividing by np.sqrt(1 - hii)
There should also be unit tests that verify it against SAS and maybe others, AFAIR.
What are your strange results? Can you provide your data and example, or at least briefly describe it?
Also, to check: this was only designed for OLS, I don't think it would be correct yet for WLS or other models. (For WLS we would need wresid and hii would need to use a different hat_matrix.
I'll find the unit tests; given that they exist, it makes me believe the problem to be on my end, but will run them to be sure. I am running OLS so am OK there.
Just one last question: is the / correct because the hat matrix has been inverted elsewhere in the code? I'm sorry to bother you here, it just seemed strange to me that the formula in the code is different from the standard textbook formula.
Anyway I will seek out the unit tests and take a look at them.
I only remember this formula (with division) in any textbook, paper or documentation of other stats packages. The wikipedia page also has the definition of the hat, or projection matrix for OLS.
(I didn't check the code right now, just what you copied in your comment.)
I'm confident the current code is correct. Will examine unit tests later. Thanks for responding, and for pointing me at these two blog entries! They are very helpful.
Activity
josef-pkt commentedon Jul 15, 2012
resid_studentized_internal is without loop, but sigma estimate for resid_studentized_external uses LOO loop.
Looking at your expression and the one in influence and outliers, I don't see yet how they can match up.
If there is a LOO-sigma estimate without loop, then that would be very useful.
jseabold commentedon Jul 15, 2012
josef-pkt commentedon Jul 15, 2012
reverse engineering (without going through the math
josef-pkt commentedon Jul 15, 2012
which means we also get dffits without LOO loop
looks like mainly dfparams and cov_ratio still need the LOOO loop
noahjgreen295 commentedon Jul 26, 2015
Sorry to bother you all but I was wondering, in the
outliers_influence.pyfile in statsmodels 0.6.1, I see the following formula for the studentized residuals inget_resid_studentized_external():return self.results.resid / sigma / np.sqrt(1 - hii)By my understanding of studentized residuals, shouldn't the second
/actually be a*, like this:return self.results.resid / sigma * np.sqrt(1 - hii)Apologies if this is incorrect, I have just been getting a lot of strange results and noticed this when I took a look. Thanks!
josef-pkt commentedon Jul 26, 2015
@noahjgreen295 I'm (pretty) sure the formula is correct with dividing by
np.sqrt(1 - hii)There should also be unit tests that verify it against SAS and maybe others, AFAIR.
What are your strange results? Can you provide your data and example, or at least briefly describe it?
Also, to check: this was only designed for OLS, I don't think it would be correct yet for WLS or other models. (For WLS we would need
wresidand hii would need to use a different hat_matrix.noahjgreen295 commentedon Jul 26, 2015
I'll find the unit tests; given that they exist, it makes me believe the problem to be on my end, but will run them to be sure. I am running OLS so am OK there.
Just one last question: is the
/correct because the hat matrix has been inverted elsewhere in the code? I'm sorry to bother you here, it just seemed strange to me that the formula in the code is different from the standard textbook formula.Anyway I will seek out the unit tests and take a look at them.
josef-pkt commentedon Jul 26, 2015
https://en.wikipedia.org/wiki/Studentized_residual#How_to_studentize last equation in this section
I only remember this formula (with division) in any textbook, paper or documentation of other stats packages. The wikipedia page also has the definition of the hat, or projection matrix for OLS.
(I didn't check the code right now, just what you copied in your comment.)
josef-pkt commentedon Jul 26, 2015
related aside: I wrote outlier influence when I was still writing for my blog
http://jpktd.blogspot.fr/2012/01/influence-and-outlier-measures-in.html
http://jpktd.blogspot.fr/2012/01/nice-thing-about-seeing-zeros.html
noahjgreen295 commentedon Jul 26, 2015
I'm confident the current code is correct. Will examine unit tests later. Thanks for responding, and for pointing me at these two blog entries! They are very helpful.