balseq {StratifiedSampling} | R Documentation |
Sequential balanced sampling
Description
Selects at the same time a well-spread and a balanced sample using a sequential implementation.
Usage
balseq(pik, Xaux, Xspread = NULL, rord = TRUE)
Arguments
pik |
A vector of inclusion probabilities. |
Xaux |
A matrix of auxiliary variables. The matrix must contains the |
Xspread |
An optional matrix of spatial coordinates. |
rord |
A logical variable that specify if reordering is applied. Default TRUE. |
Details
The function selects a sample using a sequential algorithm. At the same time, it respects the balancing equations (Xaux
) and select a well-spread sample (Xspread
). Algorithm uses a
linear program to satisfy the constraints.
Value
Return the selected indices in 1,2,...,N
See Also
BalancedSampling:lcube
, sampling:samplecube
.
Examples
N <- 100
n <- 10
p <- 10
pik <- rep(n/N,N)
Xaux <- array(rnorm(N*p,3,1),c(N,p))
Xspread <- cbind(runif(N),runif(N))
Xaux <- cbind(pik,Xaux)
s <- balseq(pik,Xaux)
colSums(Xaux[s,]/as.vector(pik[s]))
colSums(Xaux)
s <- balseq(pik,Xaux,Xspread)
colSums(Xaux[s,]/as.vector(pik[s]))
colSums(Xaux)
[Package StratifiedSampling version 0.4.2 Index]