Skip to contents

Largest-remainder (Hamilton) allocation: floor(n_total * N_h / N) per stratum, leftover units to largest fractional remainders (ties to larger stratum); within-stratum draw via Fisher-Yates on an LCG stream.

Usage

morie_geron_stratified_sampling(X, y = NULL, stratum = NULL, n_total, seed = 0)

Arguments

X

Data rows (n, ...).

y

Optional labels used as strata.

stratum

Optional explicit stratum key per row.

n_total

Sample size (required).

seed

LCG seed.

Value

list with indices (0-based), X_sample, y_sample, allocation, strata, population_share, sample_share, max_share_error, estimate, n, method.

Examples

set.seed(6)
X <- matrix(rnorm(60), 30, 2)
y <- rep(c(0L, 1L, 2L), each = 10)
morie_geron_stratified_sampling(X, y, n_total = 12, seed = 1)
#> $indices
#>  [1]  5  6  8  9 10 17 18 19 22 23 25 28
#> 
#> $X_sample
#>              [,1]        [,2]
#>  [1,]  0.36802518 -0.16026528
#>  [2,] -1.30920430  0.63049313
#>  [3,]  0.04487299 -0.19349983
#>  [4,] -1.04839720 -1.60779184
#>  [5,]  1.72785109 -0.88516413
#>  [6,] -1.09437298  1.82457894
#>  [7,] -0.28928182  0.01423374
#>  [8,]  2.20741296  0.18804274
#>  [9,]  2.01486448 -0.59677030
#> [10,] -1.18815834  1.26325824
#> [11,] -1.16973591  1.08462356
#> [12,]  1.39342626 -0.11409263
#> 
#> $y_sample
#>  [1] 0 0 0 0 1 1 1 1 2 2 2 2
#> 
#> $allocation
#> $allocation$`0`
#> [1] 4
#> 
#> $allocation$`1`
#> [1] 4
#> 
#> $allocation$`2`
#> [1] 4
#> 
#> 
#> $strata
#> [1] 0 1 2
#> 
#> $population_share
#> [1] 0.3333333 0.3333333 0.3333333
#> 
#> $sample_share
#> [1] 0.3333333 0.3333333 0.3333333
#> 
#> $max_share_error
#> [1] 0
#> 
#> $estimate
#> [1] 0
#> 
#> $n
#> [1] 12
#> 
#> $method
#> [1] "Proportional allocation with the largest-remainder rule, LCG draw within strata"
#>