Learn R Programming

StratifiedSampling (version 0.4.1)

fbs: Fast Balanced Sampling

Description

This function implements the method proposed by Hasler and Tillé (2014). It should be used for selecting a sample from highly stratified population.

Usage

fbs(X, strata, pik)

Value

A vector with elements equal to 0 or 1. The value 1 indicates that the unit is selected while the value 0 is for rejected units.

Arguments

X

A matrix of size (\(N\) x \(p\)) of auxiliary variables on which the sample must be balanced.

strata

A vector of integers that specifies the stratification.

pik

A vector of inclusion probabilities.

Author

Raphaël Jauslin raphael.jauslin@unine.ch

Details

Firstly a flight phase is performed on each strata. Secondly, several flight phases are applied by adding one by one the stratum. By doing this, some strata are managed on-the-fly. Finally, a landing phase is applied by suppression of the variables. If the number of element selected in each stratum is not equal to an integer, the function can be very time-consuming.

References

Hasler, C. and Tillé Y. (2014). Fast balanced sampling for highly stratified population. Computational Statistics and Data Analysis, 74, 81-94

Examples

Run this code

N <- 100
n <- 10
x1 <- rgamma(N,4,25)
x2 <- rgamma(N,4,25)

strata <- rep(1:n,each = N/n)

pik <- rep(n/N,N)
X <- as.matrix(cbind(matrix(c(x1,x2),ncol = 2)))

s <- fbs(X,strata,pik)

t(X/pik)%*%s
t(X/pik)%*%pik

Xcat <- disj(strata)

t(Xcat)%*%s
t(Xcat)%*%pik


Run the code above in your browser using DataLab