Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

methods for StatsBase.leverage #425

Open
palday opened this issue Apr 26, 2021 · 3 comments
Open

methods for StatsBase.leverage #425

palday opened this issue Apr 26, 2021 · 3 comments

Comments

@palday
Copy link
Member

palday commented Apr 26, 2021

Now that we have Cook's Distance, we can define this rather straightforwardly.

@HiramTheHero
Copy link

I've been looking for this functionality and couldn't find it. So I created the function for doing so. (Derived from here: https://en.wikipedia.org/wiki/Leverage_(statistics)) I tested it against R's hatvalues and it gives similar results.

function leverage(model::RegressionModel)
X = model.mm.m;
H = diag(X * ( ( X' * X ) ^ -1) * X');
return H;
end

Does anyone see an issue with what I have so far?

@palday
Copy link
Member Author

palday commented Apr 12, 2023

I think @ararslan had an implementation somewhere -- oh yeah as part of his work on Cook's Distance for GLM: #510

@HiramTheHero your proposal is mathematically correct but generally computing an explicit matrix inverse is less than ideal. The inverse is slow to compute and the result is often very sensitive to numerical details.

(Almost nothing in statistics except the sample mean is computed in practice with the textbook formulas. 🙁 )

@andreasnoack
Copy link
Member

Partly dup of #292

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants