S.STSI {TeachingSampling} | R Documentation |
Draws a simple random sample without replacement of size n_h in stratum h of size N_h
S.STSI(S, Nh, nh)
S |
Vector identifying the membership to the strata of each unit in the population |
Nh |
Vector of stratum sizes |
nh |
Vector of sample size in each stratum |
The selected sample is drawn according to a selection-rejection (list-sequential) algorithm in each stratum
The function returns a vector of size n=n_1+cdots+n_h. Each element of this vector indicates the unit that was selected.
Hugo Andrés Gutiérrez Rojas hugogutierrez@usantotomas.edu.co
Sarndal, C-E. and Swensson, B. and Wretman, J. (1992), Model Assisted Survey Sampling. Springer.
Guti'errez, H. A. (2009), Estrategias de muestreo: Dise~no de encuestas y estimaci'on de par'ametros.
Editorial Universidad Santo Tom'as.
############ ## Example 1 ############ # Vector U contains the label of a population of size N=5 U <- c("Yves", "Ken", "Erik", "Sharon", "Leslie") # Vector Strata contains an indicator variable of stratum membership Strata <- c("A", "A", "A", "B", "B") Strata # The stratum sizes Nh <- c(3,2) # Then sample size in each stratum nh <- c(2,1) # Draws a stratified simple random sample without replacement of size n=3 sam <- S.STSI(Strata, Nh, nh) sam # The selected sample is U[sam] ############ ## Example 2 ############ # Uses the Marco and Lucy data to draw a stratified random sample # accordind to a SI design in each stratum data(Marco) data(Lucy) attach(Marco) # Level is the stratifying variable summary(Level) # Defines the size of each stratum N1<-summary(Level)[[1]] N2<-summary(Level)[[2]] N3<-summary(Level)[[3]] N1;N2;N3 Nh <- c(N1,N2,N3) # Defines the sample size at each stratum n1<-14 n2<-123 n3<-263 nh<-c(n1,n2,n3) # Draws a stratified sample sam <- S.STSI(Level, Nh, nh) # The information about the units in the sample is stored in an object called data data <- Lucy[sam,] data dim(data)