Changelog
Source:NEWS.md
sondage 0.10.0
balanced_wor()gainsprnfor sample coordination with permanent random numbers, supported bymethod = "scps"(Grafström & Matei, 2018). Units are then visited in row order, so the sample depends only onpik,spread,prnand the row order. Drawing a second survey with1 - prncoordinates the two negatively. Spreading on a measure of response burden instead of coordinates gives the adapted SCP sampling of Matei, Smith, Smeets & Klingwort (2023).balanced_wor(method = "scps")is faster when many units are equally distant from the unit being decided, as with a 0/1 burden indicator inspread. A draw from 17,000 units takes about a tenth of the time. The weights those units receive are unchanged. Samples drawn withprnare unchanged. Withoutprn, a seed can give a different sample of the same design when many units are tied, because the order in which decided units leave the pool changes.register_method()acceptssupports_prn = TRUEfortype = "balanced". Such methods receiveprnwhen the caller supplies it.balanced_wor(method = "scps")no longer fails with “SCPS maximal weights are numerically infeasible” whensum(pik)misses an integer by a residue the input check accepts. At 1e-11 every draw failed, and residues of a few ulps, asinclusion_prob()can return, made some draws fail. Draws that succeeded before are unchanged.unequal_prob_wor(method = "cps")now draws a single unit, or all but one unit, from the exact design. Calibration did not converge when two units had inclusion probabilities near 0.5, so it warned after 500 iterations and the realized probabilities missed their targets by up to 7e-3. One draw has a closed form, odds proportional topik, which is now used. Samples of every other size are unchanged.
sondage 0.9.1
CRAN release: 2026-08-04
- Allocated the
long doublescratch buffers used by the exact Sampford joint inclusion probabilities withR_allocLD()instead ofR_alloc().R_alloc()guarantees only the alignment required bydouble, so on platforms wherelong doubleneeds 16-byte alignment the accesses were undefined behavior, as reported by CRAN’s gcc-UBSan check. Computed values are unchanged.
sondage 0.9.0
CRAN release: 2026-08-03
Initial CRAN release.
Sampling
Five dispatchers, 16 built-in methods:
-
equal_prob_wor(N, n, method=):"srs","systematic","bernoulli". -
equal_prob_wr(N, n, method=):"srs". -
unequal_prob_wor(pik, method=):"cps"(conditional Poisson / maximum entropy),"sampford"(exact fixed-size PPS with exact joint inclusion probabilities),"brewer","systematic","poisson","sps"(sequential Poisson),"pareto". -
unequal_prob_wr(hits, method=):"chromy"(minimum replacement),"multinomial". -
balanced_wor(pik, aux, strata, spread, bounds, method=):"cube"with optional stratification, and optional linear inequality constraints on the realized sample (bounds = list(B, lower, upper); Tripet & Tillé 2026). Inequality bounds enable controlled selection à la Goodman & Kish: category counts, possibly overlapping (e.g. the margins of a two-way control table), are kept within the integers adjacent to their expectations whileE(s) = pikholds exactly. They also support controlled matrix rounding and minimum group sizes."lpm2"(local pivotal method 2; Grafström, Lundström & Schelin- draws spatially balanced, well-spread samples on the coordinates in
spread."scps"implements Grafström’s (2012) maximal-weight spatially correlated Poisson sampling. Its C core uses weighted quickselect rather than sorting all remaining units at every step, for expected O(N^2 d) time and O(N) workspace.
- draws spatially balanced, well-spread samples on the coordinates in
All sampling functions return S3 design objects with class c(prob_class, {wor|wr}, "sondage_sample") (balanced designs additionally carry "balanced").
Design queries
-
inclusion_prob(): first-order inclusion probabilities (from size measures, or extracted from a WOR design). -
expected_hits(): expected number of selections (WR analogue). -
joint_inclusion_prob(): exact forcps,sampford,systematic,poisson,srs,bernoulli; high-entropy approximation forbrewer,sps,pareto,cube. Not available forlpm2orscps: well-spread designs are deliberately low-entropy, so no tractable approximation applies. Theirmethod_spec()metadata reportsvariance_family = "unsupported"rather than suggesting a high-entropy PPS variance treatment. -
joint_expected_hits(): exact analytic formultinomial/srs, simulation-based forchromy. -
sampling_cov(): sampling covariance;weighted = TRUEreturns Sen-Yates-Grundy check quantities.
Extensibility
-
register_method()/unregister_method()/registered_methods()/is_registered_method()/method_spec()register custom unequal-probability and balanced methods that flow through the existing dispatchers and generics. Balanced methods (type = "balanced") dispatch throughbalanced_wor()and opt into stratification withsupports_strata = TRUEor spatial spreading withsupports_spread = TRUE(well-spread designs such as the local pivotal method, SCPS, or the local cube receive the coordinate matrix passed tobalanced_wor(spread = )), the same way WOR/WR methods opt into permanent random numbers withsupports_prn. Spread-only methods can declaresupports_aux = FALSEso that passingauxerrors instead of being silently ignored. -
register_method()now rejects an already registered custom name instead of silently replacing its implementation. Deliberate replacements require an explicit call tounregister_method()first. - Registered methods can declare a
variance_family("srs","pps_brewer","poisson","wr","unsupported") describing the design-based variance treatment downstream packages should apply;method_spec()reports it for built-in and registered methods. - Registered methods declare where they sit in the first-order probability taxonomy with
probabilities:"exact"(realized inclusion probabilities, or expected hits for"wr", equal thepikorhitshanded to the method),"approximate"(honored to a documented approximation, as Pareto and sequential Poisson order sampling do), or"unknown"(the default:pikis a selection weight only, so design weights1/pikwould be biased). The default is deliberately strict; downstream packages may refuse to draw with an"unknown"method, while sampling through sondage itself is never affected.method_spec()reports the tier for every method: built-ins are"exact"except"sps"and"pareto", which report"approximate". - Custom WR callback contracts are documented with
hits, consistently with the values actually passed tosample_fnandjoint_fn. Validation errors now distinguish joint expected hits from joint inclusion probabilities. - Capability arguments in
register_method()now default toNULL, meaning unspecified. Explicit capabilities are type-specific: WOR/WR methods may declaresupports_prn, while balanced methods may declaresupports_aux,supports_strata, andsupports_spread. Supplying an irrelevant capability now errors instead of being silently normalized. -
method_spec()also returnssample_fnandjoint_fn, the implementation functions of a registered method (NULLfor built-ins). Downstream packages use them to fingerprint the implementation a saved design was executed with. -
method_spec()now identifies the publicdispatcherfor every method. Shared built-in names such as"srs"and"systematic"require an explicit dispatcher instead of silently selecting one variant. -
he_jip()(Brewer & Donadio 2003 high-entropy approximation) andhajek_jip()(Hajek 1964) are exported and can be passed directly asjoint_fntoregister_method().
Other features
- Batch sampling via
nrepfor Monte Carlo simulations. Fixed-size designs return a matrix; random-size designs return a list. - Permanent random numbers (
prn) for sample coordination (Bernoulli, Poisson, SPS, Pareto). - C implementations for all built-in sampling algorithms.
- Vignette “Extending sondage with Custom Methods”.