Relax numerical precision for covariance matrix symmetry check#74
Merged
gbradburd merged 2 commits intogbradburd:masterfrom May 2, 2026
Merged
Relax numerical precision for covariance matrix symmetry check#74gbradburd merged 2 commits intogbradburd:masterfrom
gbradburd merged 2 commits intogbradburd:masterfrom
Conversation
Collaborator
|
Hi, Chris! Let's see; these covariance matrices are getting produced in would fix this up? Then, I think we'll only get non-symmetric matrices if the user passes them in, in which case maybe the tolerance doesn't need to be updated, actually. What do you think? |
Contributor
Author
|
Hey Peter! Ah so the user can input a covariance matrix. I had wondered why the symmetry check was necessary. I like your fix. included it in recent commit, deleted the tol=1e-10. |
Owner
|
thanks Chris for the question and Peter for the elegant solution! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Behavior:
The cross validation function sometimes gives an error (below) when checking for symmetry of the covariance matrices from each CV fold. The error seems more common for large genotype inputs (and for randomly generated allele frequencies).
Error message:
Example:
The offending values can be as close as:
-0.0039732048102367745
-0.0039732048102368300
Fix:
isSymmetric()takes a tolerance argument with default100 * .Machine$double.eps(= 2.220446e-16). I replaced this with 1e-10 which seems plenty precise and works for several iterations of the above example.Don't know if it would also be good to copy the upper triangle onto the lower triangle of each covariance matrix?