pwd {Spbsampling} | R Documentation |
Selects spatially balanced samples through the use of the
Product Within Distance design (PWD). To have constant inclusion
probabilities π_{i}=nsamp/N, where nsamp is sample size and
N is population size, the distance matrix has to be standardized with
function stprod
.
pwd(dis, nsamp, bexp = 10, nrepl = 1L, niter = 10L)
dis |
A distance matrix NxN that specifies how far all the pairs of units in the population are. |
nsamp |
Sample size. |
bexp |
Parameter β for the algorithm. The higher β is, the more the sample is going to be spread (default = 10). |
nrepl |
Number of samples to draw (default = 1). |
niter |
Number of iterations for the algorithm. More iterations are better but require more time. Usually 10 is very efficient (default = 10). |
Returns a matrix nrepl
x nsamp
, which contains the
nrepl
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.
Benedetti R, Piersimoni F (2017). A spatially balanced design with probability function proportional to the within sample distance. Biometrical Journal, 59(5), 1067-1084. https://doi.org/10.1002/bimj.201600194
# Example 1 # Draw 1 sample of dimension 15 without constant inclusion probabilities dis <- as.matrix(dist(cbind(lucas_abruzzo$x, lucas_abruzzo$y))) # distance matrix s <- pwd(dis = dis, nsamp = 15) # drawn sample # Example 2 # Draw 1 sample of dimension 15 with constant inclusion probabilities # equal to nsamp/N, with N = population size dis <- as.matrix(dist(cbind(lucas_abruzzo$x, lucas_abruzzo$y))) # distance matrix con <- rep(0, nrow(dis)) # vector of constraints stand_dist <- stprod(mat = dis, vec = con) # standardized matrix s <- pwd(dis = stand_dist, nsamp = 15) # drawn sample # Example 3 # Draw 2 samples of dimension 15 with constant inclusion probabilities # equal to nsamp/N, with N = population size, and an increased level of spread, bexp = 20 dis <- as.matrix(dist(cbind(lucas_abruzzo$x, lucas_abruzzo$y))) # distance matrix con <- rep(0, nrow(dis)) # vector of constraints stand_dist <- stprod(mat = dis, vec = con) # standardized matrix s <- pwd(dis = stand_dist, nsamp = 15, bexp = 20, nrepl = 2) # drawn samples