rank_biserial(paired = TRUE): the confidence interval counts x != mu instead of the nonzero paired differences
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 85/100
Research direction
Start in R/rank_diff.R around line 179 and read the rank_biserial() confidence-interval calculation alongside the existing .r_rbs() handling of nonzero differences. Check the existing tests for rank_biserial() and add a regression case using paired data with zero differences. Done when the paired call's confidence interval matches the one-sample call on the differences.
Written by the indexing model from the issue text.
Description
Describe the bug
For paired samples, rank_biserial() computes the estimate from the paired differences (x - y) - mu, but the standard error of its confidence interval takes the number of observations from x alone:
nd <- sum((x - mu) != 0)
(R/rank_diff.R, line 179 on main; the same in 1.0.3 on CRAN). In the paired case x and y are still separate vectors at that point, so nd counts the values of x that differ from mu, not the nonzero differences that the estimate is built on. Whenever the two counts differ, the interval is too narrow or too wide. The one-sample case is not affected, since y is 0 there.
To Reproduce
x holds no zeros, but three of the ten differences are zero:
library(effectsize)
x <- c(5.1, 6.0, 7.2, 4.8, 6.5, 5.9, 7.0, 6.1, 5.5, 6.3)
y <- c(4.9, 6.0, 6.5, 4.8, 6.8, 5.3, 6.1, 6.1, 5.9, 5.0)
rank_biserial(x, y, paired = TRUE)
#> r (rank biserial) | 95% CI
#> --------------------------------
#> 0.64 | [0.06, 0.90]
rank_biserial(x - y)
#> r (rank biserial) | 95% CI
#> ---------------------------------
#> 0.64 | [-0.07, 0.92]
The two calls describe the same data and give the same estimate, 0.642857, but the paired call uses nd = 10 where there are 7 nonzero differences, and its interval excludes zero while the correct one does not.
Expected behavior
The paired call should give the same interval as the one-sample call on the differences, [-0.065116, 0.920343], which is what nd = 7 gives. A possible fix is to count the differences, as .r_rbs() does:
nd <- sum(((x - y) - mu) != 0)
This is separate from #502, which is about how zero differences enter the estimate itself.
Specifications
RVersion 4.5.0 (2025-04-11)effectsizeVersion 1.0.3
- Dominant language
- R
- Stars
- 353
- Forks
- 25
- Avg merge
- 11h 6m
- Merged PRs (30d)
- 3
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from easystats/effectsize
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
easystats/effectsize#709 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
easystats/effectsize#708 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 20/100
easystats/effectsize#705 · 1 comment ·
-
consistency :apple: :green_apple: docs 📑
Difficulty 3/5 1-2 days Newbie friendliness 35/100
easystats/effectsize#681 · 1 comment ·
-
Significance testsOpenenhancement 🔥
Difficulty 5/5 Over a week Newbie friendliness 25/100
easystats/effectsize#638 · 7 comments ·
All issues in easystats/effectsize
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
tidymodels/censored#414 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
waldronlab/bugphyzz#256 ·
-
dbRemoveTable() fails on SQLite with 'near "TRUNCATE": syntax error' and leaves the table in placePossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
OHDSI/DatabaseConnector#348 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100