Skip to content

fix for potential errors in z_cor_test#117

Merged
arcaldwell49 merged 2 commits into
Lakens:masterfrom
arcaldwell49:cor-missing-check
Apr 17, 2026
Merged

fix for potential errors in z_cor_test#117
arcaldwell49 merged 2 commits into
Lakens:masterfrom
arcaldwell49:cor-missing-check

Conversation

@arcaldwell49

Copy link
Copy Markdown
Collaborator

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.

Copilot AI review requested due to automatic review settings April 17, 2026 12:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 in z_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).

Comment thread R/cor_test.R
Comment thread .claude/settings.local.json
@arcaldwell49 arcaldwell49 merged commit 16c4385 into Lakens:master Apr 17, 2026
4 checks passed
@arcaldwell49 arcaldwell49 deleted the cor-missing-check branch April 17, 2026 15:57
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

Successfully merging this pull request may close these issues.

2 participants