Repository navigation
769: Make test arguments of get_pairwise_comparisons() explicit - #1249
Draft
nikosbosse wants to merge 4 commits into
Draft
nikosbosse wants to merge 4 commits into
nikosbosse wants to merge 4 commits into
Conversation
Replace `...` in get_pairwise_comparisons() and pairwise_comparison_one_group() with explicit `test_type`, `one_sided` and `n_permutations` arguments, validate them up front, and document them on get_pairwise_comparisons(). add_relative_skill() keeps its `test_type = NULL` default and forwards `...` to get_pairwise_comparisons(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reword the one_sided parameter doc, drop the signature-only test that inspected formals(), and explain in the validation test why these arguments are now checked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1249 +/- ##
=======================================
Coverage 99.18% 99.18%
=======================================
Files 41 41
Lines 2333 2344 +11
=======================================
+ Hits 2314 2325 +11
Misses 19 19 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
- Merge the forwarding checks into the existing permutation test and add a deterministic check that `one_sided` reaches permutation_test(). - Document that `one_sided` only affects the permutation test, which direction it tests, and that the p-value is shared by both rows of a pair. - Clarify that `...` in add_relative_skill() cannot change its output. - Drop the no-op NULL from the test_type defaults of compare_scores() and compare_forecasts(). - Make the test_type error expectation locale-independent. - Flag the NEWS item as breaking for positional calls. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
CLAUDE:
Description
Part of #769. This PR makes the test arguments explicit and documents what the one-sided test checks. It does not change the test itself; the open question in #769 about the null hypothesis of the one-sided test remains (see "Not addressed" below).
get_pairwise_comparisons()used to passtest_type,one_sidedandn_permutationson via...to the internal pairwise test. Following the discussion in #769, these are now explicit arguments:get_pairwise_comparisons()gainstest_type = c("non_parametric", "permutation"),one_sided = FALSEandn_permutations = 999in place of.... They are validated up front:match.arg()fortest_type(skipped whenNULL),assert_flag()forone_sidedandassert_count(positive = TRUE)forn_permutations. Previously, an invalidone_sided/n_permutationswas silently ignored unless a permutation test ran, and a misspelled argument disappeared into.... It now errors with "unused argument".pairwise_comparison_one_group()also takes these as explicit arguments and passes them tocompare_scores()by name, so...no longer appears anywhere on this path.add_relative_skill()keeps itstest_type = NULLdefault fromadd_relative_skill()runs Wilcoxon tests whose p-values it then discards #1222 and still forwards...toget_pairwise_comparisons(). Its...doc now says these arguments (one_sided,n_permutations) only affect p-values, whichadd_relative_skill()does not return.compare_forecasts()ontoget_pairwise_comparisons(), and the other functions inherit them. This also fixes the "whether two conduct" typo. Theone_sideddoc now says three things. It only affects the permutation test, because the Wilcoxon test is always two-sided. Its alternative is that the comparator appearing first inscoreshas the higher (worse) mean score. Each pair is tested once, and that p-value is shown in both output rows of the pair.NULLis removed from thetest_typedefault vectors ofcompare_scores()andcompare_forecasts().assert_countandassert_flagare added to the groupedimportFrom(checkmate, ...)block. I checked this against roxygen2 8.1.0, the version inConfig/roxygen2/version. It regenerates NAMESPACE and DESCRIPTION exactly as committed.baselinenow bind them differently. Calls that passed them by name are unaffected.Not addressed (left for #769 / a follow-up)
one_sidedstill has no effect on the default Wilcoxon test.scores.Both points are about which hypothesis to test, which #769 raises as an open question. Changing them changes the p-values users get, so I left that decision to the maintainers instead of folding it into this refactor.
Tests
get_pairwise_comparisons() validates the test arguments (#769): I ran this test againstorigin/main'sR/pairwise-comparisons.R. Only theone_sided = "yes",n_permutations = 0andadd_relative_skill(n_permutations = 2.5)expectations fail there, and all three pass after the change. Thetest_type = "t_test"andalternative = "less"→ "unused argument" expectations already pass before the change, so they only guard existing behaviour. Thetest_typeexpectation matches"non_parametric"rather than base R's translated "should be one of" message.permutation_tests work as expected(existing test, extended): this test guards the forwarding of all three arguments and passes both before and after the change.n_permutationsis checked through p-values that are multiples of 1/51.test_typeis checked through permutation p-values that differ from the Wilcoxon ones, andNULLgivesNA.one_sidedis checked with a deterministic two-model case: one model is better on every forecast, so the two-sided p is 1/51 and the one-sided p is 1. I ran a mutation check: replacingone_sided = one_sidedwithFALSEat each of the three forwarding sites (get_pairwise_comparisons→pairwise_comparison_one_group→compare_scores→permutation_test) makes this test fail.Checklist
get_pairwise_comparisons()#769).devtools::test(): FAIL 0, PASS 1050. The 4 warnings come from unrelated pre-existing tests.Config/roxygen2/version). This produced no churn outside this change.lintr::lint_package()to check for style issues introduced by my changes. I ranlintr::lint()on the changed files. The only lints are the spuriousobject_usage_linterones that also hit pre-existing code.Implementation: two independent drafts were compared by a judge agent; draft A was chosen as base.
Review
An independent adversarial agent reviewed this PR. Changes made in response:
one_sidedforwarding was untested (major): I added a deterministic check (described above) and confirmed with mutation checks at all three forwarding sites that it catches a droppedone_sided. The PR description no longer claims more than the tests pin down.permutation_tests work as expectedtest.get_pairwise_comparisons()#769": theone_sideddoc now states which direction is tested, that it does not affect the Wilcoxon test, and that the p-value is shared by both rows of a pair. The PR now says "Part of Rethink the way arguments are passed inget_pairwise_comparisons()#769" instead of closing it....inadd_relative_skill(): the doc now says these arguments cannot change its output."non_parametric".NULLin the default vectors: removed fromcompare_scores()andcompare_forecasts().Rebutted:
alternative = ...): the mirrored-row issue above means a one-sided p-value is only valid for one row of each pair. Extendingone_sidedto the default test would spread that problem to every default call, and it would silently change p-values. That belongs to the null-hypothesis discussion in Rethink the way arguments are passed inget_pairwise_comparisons()#769, not to this refactor. Also, the suggested"less"would be the opposite direction to the permutation test, which tests that the first comparator is worse, i.e."greater".pairwise_comparison_one_group(): I tried this. Existing tests call the internal function directly without the test arguments, and they then fail withargument "test_type" is missing. Keeping the defaults, which matchcompare_scores(), is simpler than making every direct caller spell out three arguments it does not care about.🤖 Generated with Claude Code