

# Selection two-stage sample {SI,SI} in a two-dimensional population

library(sampling)

tableR=read.csv2(".../Data2stCCS.csv")
#or
tableR=read.csv2(file.choose())


attach(tableR)
n_m=320; n_d=25; N_m=544; N_d=365; N=N_m*N_d

m=mstage(tableR,stage=list("cluster","cluster"),varnames=list("ID_i","ID_k"),
size=list(n_m,c(rep(n_d,N_m))), method=c("srswor","srswor"))

Dummy_2d2 <- rep(0,N); Dummy_2d2[(tableR$id %in% m[[2]]$ID_unit)] <-1
#tableR=cbind(tableR,Dummy_2d2)
#or, to extract the sample
ech=getdata(tableR,m)[[2]]