Repository navigation
Document survey sampling terminology for the _rs functions (see #99) - #102
Merged
Merged
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
complete_rs() and strata_rs() inherited complete_ra()'s rule of never rounding a count up to N. Under assignment the rule keeps a control arm nonempty; under sampling it only biases inclusion downward: complete_rs(N = 10, prob = 0.95) always sampled 9 units, and a one-unit stratum with strata_prob = 0.3 was never sampled. complete_rs() now uses the plain floor/ceiling mixture, and strata_rs() takes an affected stratum whole with probability equal to the fractional part of N_s * prob, after block_ra()'s draw so unaffected designs keep their seeds. The _probabilities() functions report the corrected values. cluster_rs() and strata_and_cluster_rs() are fixed through these two. See #99. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
complete_ra() rounds a count down rather than up to N, which keeps a control unit when N > 1. With N = 1 and prob strictly between 0 and 1 the same rule left the unit in control on every draw, while complete_ra_probabilities() reported prob. block_ra()'s two-arm kernel did the same for one-unit blocks under block_prob (and prob_unit), and cluster_ra() and block_and_cluster_ra() inherited both. The correcting coin is drawn after the existing draws and only when the case arises, so every other design keeps its stream: 16 seeded designs across complete, block, cluster, and sampling functions draw identically before and after. strata_rs() now leaves one-unit strata to block_ra(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
acoppock
marked this pull request as ready for review
October 26, 2026 23:54
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.
Adds a short "Terminology" section to the roxygen docs of
simple_rs(),complete_rs(),strata_rs(),cluster_rs(), andstrata_and_cluster_rs(), giving the names the survey sampling literature uses. Function names are unchanged: they follow the analogous random assignment functions. See #99.Mappings, each checked against the code and by simulation (200,000 draws):
simple_rs(): independent draws, so Bernoulli sampling with constantproband Poisson sampling with varyingprob_unit. Sample sizes match the binomial and Poisson-binomial distributions.complete_rs(): SRSWOR for whole-numbern(all 20 subsets of size 3 from 6 equally likely). With non-integerN*prob, a mixture of SRSWOR of size floor and ceiling.strata_rs(): stratified SRSWOR, strata independent, same floor/ceiling mixture within a stratum.cluster_rs()andstrata_and_cluster_rs(): (stratified) SRSWOR of clusters.cluster_rs(simple = TRUE)is Bernoulli or Poisson sampling of clusters.One caveat the note states: when
ceiling(N*prob)equalsN(andN > 1), the floor is always used, so the realized inclusion probability isfloor(N*prob)/N, notprob. The*_probabilities()functions report the realized value, so weights are right. The existing "exactlyprob" wording in the parameter docs does not mention this case; I left it for a separate decision.The bias claim does not apply to randomizr: no sampling function draws a fixed-size unequal-probability sample through
sample(prob =). The only weightedsample()call is the floor/ceiling coin flip, andcomplete_rs()rejects varyingprob_unit. With the probabilities from the issue,simple_rs()gives inclusion rates within sampling error of the targets (e.g. 0.0696 vs 0.07 and 0.9105 vs 0.91), and pairwise inclusion is the product of the margins, as Poisson sampling requires.man/regenerated with roxygen2 8.0.0 (theConfig/roxygen2/version).R CMD check --as-cran --no-manualon the built tarball: no errors or notes, one expected warning that 2.0.1 equals the CRAN version (no bump here). NEWS.md has a development-version bullet. Draft because Alex should read the wording first.