Conversation
On a large problem the products of unit counts in the "recognizably infeasible" check overflow integer arithmetic: with 14,748 treated units and 372,150 controls, nt * mxc is about 5.5 billion, so it becomes NA and the enclosing if() stops with "missing value where TRUE/FALSE needed" rather than reporting that the restrictions cannot be met. Computing the two products in double precision leaves the comparisons unchanged and lets the check do its job. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
benthestatistician
approved these changes
Sep 17, 2026
benthestatistician
left a comment
Collaborator
There was a problem hiding this comment.
Looks good to me, thanks. I don't think the change necessitates its own test. I'm also happy either to leave in place the other NA integer overflow warning.
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.
On a large sparse problem, fullmatch stops with "missing value where TRUE/FALSE needed" rather than matching or reporting that the restrictions cannot be met. Reproducible with simulated data on 0.10.8.9002:
The cause is the recognizably infeasible check in fmatch. Both nt times mnc and nt times mxc are integer products of unit counts, and here the second is about 5.5 billion, so it overflows to NA and the enclosing if cannot evaluate. This change computes the two products in double precision, which leaves the comparisons unchanged.
With the change the same call returns an unmatched result and the warning the check exists to produce, "Matching failed. (Restrictions impossible to meet?)", which is right: four controls per treated unit cannot absorb 372,150 controls. Adding mean.controls makes the problem feasible and it matches normally, with and without the change.
One related observation I have not fixed here. A few lines further on, the node supply is built with mxc times nt, which overflows the same way and still warns. That value has to remain an integer for the NodeInfo class, so it needs a different treatment, and it only arises on problems that are already infeasible. Happy to take that on in a separate change if you would like.
I did not add a test, since reproducing the overflow needs a problem large enough to be slow in a test suite. Glad to add one if you would prefer it.
Composed with assistance from Claude Opus 5.