Type: Package
Title: Exact Optimal Allocation Algorithms for Stratified Sampling
Version: 0.1.0
Maintainer: Andrew M. Raim <andrew.raim@gmail.com>
Description: Implements several exact methods for allocating optimal sample sizes when designing stratified samples. These methods are discussed in Wright (2012) <doi:10.1080/00031305.2012.733679> and Wright (2017) <doi:10.1016/j.spl.2017.04.026>.
License: MIT + file LICENSE
Imports: Rmpfr
RoxygenNote: 7.3.2
Encoding: UTF-8
VignetteBuilder: quarto
Suggests: quarto
NeedsCompilation: no
Packaged: 2025-08-22 08:54:19 UTC; araim
Author: Andrew M. Raim [aut, cre]
Repository: CRAN
Date/Publication: 2025-08-27 16:30:17 UTC

allocation

Description

Package documentation

Author(s)

Maintainer: Andrew M. Raim andrew.raim@gmail.com


Algorithms for Exact Optimization Allocation

Description

Algorithms III and IV from Wright (2017), and classical unconstrained Neyman allocation (Neyman, 1934).

Usage

allocate_fixn(n0, N, S, lo = NULL, hi = NULL, control = allocation_control())

allocate_neyman(n0, N, S, control = allocation_control())

allocate_prec(v0, N, S, lo = NULL, hi = NULL, control = allocation_control())

Arguments

n0

Target sample size for Algorithm III; integer.

N

Population size for each stratum; integer vector of length H.

S

Standard deviation for each stratum; numeric vector of length H.

lo

Sample size lower bounds for each stratum; numeric vector of length H. Default argument NULL is transformed to a vector of ones.

hi

Sample size upper bounds for each stratum; numeric vector of length H. Default argument NULL is transformed to a vector of Inf.

control

Control object from allocation_control.

v0

Target variance for Algorithm IV; numeric.

Details

The function allocate_fixn implements Algorithm III of Wright (2017) and finds the optimal allocation for a given total sample size n0. The function allocate_prec implements Algorithm IV of Wright (2017) and optimally allocates units until the overall variance is smaller than a given v0. Classical Neyman allocation is implemented by the function allocate_neyman.

Value

A list whose structure depends on the allocation method.

allocate_neyman

allocate_fixn

allocate_prec

References

Neyman, Jerzy (1934). On the Two Different Aspects of the Representative Method: The Method of Stratified Sampling and the Method of Purposive Selection. Journal of the Royal Statistical Society, 97 (4): 558-625.

Tommy Wright (2012). The Equivalence of Neyman Optimum Allocation for Sampling and Equal Proportions for Apportioning the U.S. House of Representatives. The American Statistician, 66, pp.217-224.

Tommy Wright (2017), Exact optimal sample allocation: More efficient than Neyman, Statistics & Probability Letters, 129, pp.50-57.


Accessor for to Extract Allocation

Description

Extract the allocation from the result of one of the Allocation-Methods.

Usage

allocation(object)

Arguments

object

Result from an allocation method

Value

A numeric vector whose elements contain an allocation for the corresponding stratum.


Control Object for Allocation Methods

Description

Additional arguments (controls) for Allocation-Methods.

Usage

allocation_control(verbose = FALSE, bits = 256, tol = 1e-10, digits = 4)

Arguments

verbose

Logical; if TRUE, detailed information will be printed to the console by allocate_fixn and allocate_prec.

bits

Number of bits of precision to use with mpfr objects in internal calculations.

tol

A small positive number for use in allocate_prec; if all strata have V <= tol, regard the situation as one where no more allocation is possible, even if target value v0 has not yet been attained.

digits

Number of decimals to display in output.

Value

An list of class allocation_control.

Examples

out1 = allocation_control()
out2 = allocation_control(verbose = TRUE, bits = 128, tol = 1e-8, digits = 2)