swd {Spbsampling} | R Documentation |
Sum Within Distance (Spatially Balanced Sampling Design)
Description
Selects spatially balanced samples through the use of the
Sum Within Distance design (SWD). To have a constant inclusion
probabilities \pi_{i}=n/N
, where n
is sample size and
N
is population size, the distance matrix has to be standardized with
function stsum
.
Usage
swd(dis, n, beta = 10, nrepl = 1L, niter = 10L)
Arguments
dis |
A distance matrix NxN that specifies how far all the pairs of units in the population are. |
n |
Sample size. |
beta |
Parameter |
nrepl |
Number of samples to draw (default = 1). |
niter |
Maximum number of iterations for the algorithm. More iterations are better but require more time. Usually 10 is very efficient (default = 10). |
Value
Returns a list with the following components:
-
s
, a matrixnrepl
xn
, which contains thenrepl
selected samples, each of them stored in a row. In particular, the i-th row contains all labels of units selected in the i-th sample. -
iterations
, number of iterations run by the algorithm.
References
Benedetti R, Piersimoni F (2017). A spatially balanced design with probability function proportional to the within sample distance. Biometrical Journal, 59(5), 1067-1084. doi:10.1002/bimj.201600194
Examples
# Example 1
# Draw 1 sample of dimension 15 without constant inclusion probabilities
dis <- as.matrix(dist(cbind(income_emilia$x_coord, income_emilia$y_coord))) # distance matrix
s <- swd(dis = dis, n = 15)$s # drawn sample
# Example 2
# Draw 1 sample of dimension 15 with constant inclusion probabilities
# equal to n/N, with N = population size
dis <- as.matrix(dist(cbind(income_emilia$x_coord,income_emilia$y_coord))) # distance matrix
con <- rep(1, nrow(dis)) # vector of constraints
stand_dist <- stsum(mat = dis, con = con) # standardized matrix
s <- swd(dis = stand_dist$mat, n = 15)$s # drawn sample
# Example 3
# Draw 2 samples of dimension 15 with constant inclusion probabilities
# equal to n/N, with N = population size and an increased level of spread, i.e. beta = 20
dis <- as.matrix(dist(cbind(income_emilia$x_coord,income_emilia$y_coord))) # distance matrix
con <- rep(1, nrow(dis)) # vector of constraints
stand_dist <- stsum(mat = dis, con = con) # standardized matrix
s <- swd(dis = stand_dist$mat, n = 15, beta = 20, nrepl = 2)$s # drawn samples