Skip to content

Document survey sampling terminology for the _rs functions (see #99) - #102

Merged
acoppock merged 4 commits into
mainfrom
terminology-note-99
Oct 27, 2026
Merged

acoppock merged 4 commits into
mainfrom
terminology-note-99

Conversation

@acoppock

Copy link
Copy Markdown
Collaborator

Adds a short "Terminology" section to the roxygen docs of simple_rs(), complete_rs(), strata_rs(), cluster_rs(), and strata_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 constant prob and Poisson sampling with varying prob_unit. Sample sizes match the binomial and Poisson-binomial distributions.
  • complete_rs(): SRSWOR for whole-number n (all 20 subsets of size 3 from 6 equally likely). With non-integer N*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() and strata_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) equals N (and N > 1), the floor is always used, so the realized inclusion probability is floor(N*prob)/N, not prob. The *_probabilities() functions report the realized value, so weights are right. The existing "exactly prob" 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 weighted sample() call is the floor/ceiling coin flip, and complete_rs() rejects varying prob_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 (the Config/roxygen2/version). R CMD check --as-cran --no-manual on 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.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
acoppock and others added 3 commits October 26, 2026 17:47
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
acoppock marked this pull request as ready for review October 26, 2026 23:54
@acoppock
acoppock merged commit 190d5f2 into main Oct 27, 2026
6 checks passed
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.

1 participant