fix for potential errors in z_cor_test#117
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses failure cases in z_cor_test() by making correlation tests robust to missing paired values and by preventing the jackknife SE path from producing invalid results when Fisher’s z-transform becomes infinite (|r| = 1). It also adds regression tests to prevent these error modes from returning.
Changes:
- Filter to complete paired observations before computing
cor()/SEs inz_cor_test(). - Add explicit guards/errors for jackknife SE when |r| = 1 (or when the computed SE is non-finite/zero).
- Add unit tests covering NA handling and the |r| = 1 jackknife failure mode.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
R/cor_test.R |
Updates z_cor_test() to drop NA pairs before correlation/SE computation and adds jackknife SE guards. |
tests/testthat/test-corr.R |
Adds regression tests for NA handling and perfect-correlation jackknife errors. |
.claude/settings.local.json |
Unrelated local settings changes included in the PR (should be removed). |
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.
Code failed when 1) NAs present in one vector 2) correlation is perfect but jackknife se selected. Pull fixes the code and puts in unit tests to avoid future error in same fashion.