if (FALSE) {
# Example 1
# Select sample and check balance
set.seed(12345);
N = 100; # population size
n = 10; # sample size
p = rep(n/N,N); # inclusion probabilities
X = cbind(p,runif(N),runif(N)); # matrix of auxiliary variables
pflight = flightphase(p,X);
# check balance after flight
colSums(X)
colSums(X/p*pflight)
# select final sample as indicators
indicators = landingphase(p,pflight,X);
# check final balance
colSums(X)
colSums(X/p*indicators)
# final sample as indexes
s = (1:N)[indicators==1];
}
Run the code above in your browser using DataLab