Learn R Programming

TeachingSampling (version 4.1.1)

S.STSI: Stratified sampling applying SI design in all strata

Description

Draws a simple random sample without replacement of size \(n_h\) in stratum \(h\) of size \(N_h\)

Usage

S.STSI(S, Nh, nh)

Arguments

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

Value

The function returns a vector of size \(n=n_1+\cdots+n_H\). Each element of this vector indicates the unit that was selected.

Details

The selected sample is drawn according to a selection-rejection (list-sequential) algorithm in each stratum

References

Sarndal, C-E. and Swensson, B. and Wretman, J. (1992), Model Assisted Survey Sampling. Springer. Gutierrez, H. A. (2009), Estrategias de muestreo: Diseno de encuestas y estimacion de parametros. Editorial Universidad Santo Tomas.

See Also

E.STSI

Examples

Run this code
# NOT RUN {
############
## 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 Lucy data to draw a stratified random sample
#  accordind to a SI design in each stratum
data(Lucy)
attach(Lucy)
# 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<-70
n2<-100
n3<-200
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)
# }

Run the code above in your browser using DataLab