| select_units | R Documentation |
Draws a probability sample of the units of a frame (segments, grid cells, establishments) with equal or size-proportional inclusion probabilities, within strata when given, by one of three methods:
select_units(
frame,
n,
size = NULL,
coords = NULL,
strata = NULL,
method = c("lpm", "systematic", "srs", "cube"),
replicates = 1,
seed = 1,
balance = NULL
)
frame |
Data frame with one row per unit: coordinate columns ( |
n |
Sample size: a single number (allocated to strata in proportion
to the sum of |
size |
Column of the size measure for probability-proportional-to-size
selection, or |
coords |
Names of the coordinate columns used for spatial balance (any
number of columns for |
strata |
Column with the stratum of each unit, or |
method |
|
replicates |
Number of independent interpenetrating replicates for
|
seed |
Seed. |
balance |
For |
"lpm": the local pivotal method (Grafström, Lundström and Schelin,
2012), which spreads the sample over the coordinate space so that nearby
units are rarely selected together;
"systematic": systematic sampling with probabilities proportional to
size along a Hilbert curve through the coordinates (a spatially ordered
systematic sample), drawn as replicates independent interpenetrating
systematic samples so that a design-based variance can be estimated;
"srs": simple random sampling without replacement.
Spatial balance reduces the variance of totals of spatially structured variables and, at the same time, spreads the field work; the cost model and the routing make that tension explicit.
The frame as a tibble with columns pi (inclusion probability in
the union of the replicates) and sampled, of class fieldopt_sample,
with attributes n, coords, strata, method, seed and, for
replicated systematic samples, replicates (a logical matrix, one column
per replicate) and pi_replicate (inclusion probability within one
replicate).
Grafström, A., Lundström, N. L. P. and Schelin, L. (2012). Spatially balanced sampling through the pivotal method. Biometrics, 68(2), 514–520.
set.seed(1)
cells <- expand.grid(x = 1:20, y = 1:20)
cells$unit <- paste0("c", seq_len(nrow(cells)))
cells$intensity <- cut(
cells$x + rnorm(400, sd = 3), c(-Inf, 7, 14, Inf),
c("low", "mid", "high")
)
cells$size <- c(low = 1, mid = 2, high = 4)[cells$intensity]
s <- select_units(cells,
n = c(low = 10, mid = 15, high = 25), size = "size",
strata = "intensity"
)
table(s$intensity, s$sampled)
r <- select_units(cells, n = 40, method = "systematic", replicates = 4)
dim(attr(r, "replicates"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.