Description Usage Arguments Value References Examples
Select doubly balanced samples with prescribed inclusion probabilities from a finite population. To have a fixed sample size, include the inclusion probabilities as a balancing variable in Xbal
and make sure the inclusion probabilities sum to a positive integer. This is a simplified (optimized for speed) implementation of the local cube method (doubly balanced sampling). Landing is done by dropping balancing variables (from rightmost column, so keep inclusion probabilities in first column to guarantee fixed size). Euclidean distance is used in the Xspread
space.
1 | lcube(prob,Xspread,Xbal)
|
prob |
vector of length N with inclusion probabilities |
Xspread |
matrix of (standardized) auxiliary variables of N rows and q columns |
Xbal |
matrix of balancing auxiliary variables of N rows and r columns |
Returns a vector of selected indexes in 1,2,...,N.
Grafstr<c3><b6>m, A. and Till<c3><a9>, Y. (2013). Doubly balanced spatial sampling with spreading and restitution of auxiliary totals. Environmetrics, 24(2), 120-131.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | ## Not run:
# Example 1
set.seed(12345);
N = 1000; # population size
n = 100; # sample size
p = rep(n/N,N); # inclusion probabilities
X = cbind(runif(N),runif(N)); # matrix of auxiliary variables
s = lcube(p,X,cbind(p)); # select sample
plot(X[,1],X[,2]); # plot population
points(X[s,1],X[s,2], pch=19); # plot sample
# Example 2
# check inclusion probabilities
set.seed(12345);
p = c(0.2, 0.25, 0.35, 0.4, 0.5, 0.5, 0.55, 0.65, 0.7, 0.9); # prescribed inclusion probabilities
N = length(p); # population size
X = cbind(runif(N),runif(N)); # some artificial auxiliary variables
ep = rep(0,N); # empirical inclusion probabilities
nrs = 10000; # repetitions
for(i in 1:nrs){
s = lcube(p,X,cbind(p));
ep[s]=ep[s]+1;
}
print(ep/nrs);
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.