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

Potential numerical inaccuracy in weighted variance #199

Closed
fweber144 opened this issue Aug 16, 2021 · 0 comments
Closed

Potential numerical inaccuracy in weighted variance #199

fweber144 opened this issue Aug 16, 2021 · 0 comments

Comments

@fweber144
Copy link
Collaborator

The identity Var(X) = E(X^2) - E(X)^2 is prone to numerical cancellation (see, e.g., here). In a similar form, this identity is used in the predictive variances from predvar_gauss() (perhaps at other places, too):

projpred/R/extend_family.R

Lines 125 to 126 in 6cec7d6

mu_mean <- mu %*% wsample
mu_var <- mu^2 %*% wsample - mu_mean^2

Perhaps this doesn't have any larger impact in projpred, but I wanted to highlight it anyway. Alternatives to the current implementation could be those mentioned here.

fweber144 added a commit to fweber144/projpred that referenced this issue Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant