flightphase: Flight phase of the cube method

Description Usage Arguments Value References Examples

View source: R/RcppExports.R

Description

This is a fast implementation of the flight phase of the cube method. 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.

Usage

1
flightphase(prob,Xbal)	

Arguments

prob

vector of length N with inclusion probabilities

Xbal

matrix of balancing auxiliary variables of N rows and q columns

Value

Returns a vector of length N with new probabilities, where at most q are non-integer.

References

Deville, J. C. and Till<c3><a9>, Y. (2004). Efficient balanced sampling: the cube method. Biometrika, 91(4), 893-912.

Chauvet, G. and Till<c3><a9>, Y. (2006). A fast algorithm for balanced sampling. Computational Statistics, 21(1), 53-62.

Examples

 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
## Not run: 
# 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];

## End(Not run)

jlisic/BalancedSampling documentation built on May 19, 2019, 12:46 p.m.