optimStrat (version 2.1)

stratify: Stratification of an Auxiliary Variable

Description

Stratify the auxiliary variable x into H strata using the cum-sqrt-rule.

Usage

stratify(x, H, forced = FALSE, J = NULL)

Arguments

x

a positive numeric vector giving the values of the auxiliary variable.

H

a positive integer smaller or equal than length(x) giving the desired number of strata.

forced

a logical value indicating if the number of strata must be exactly equal to H (see ‘Details’).

J

a positive integer indicating the number of bins used for the cum-sqrt-rule.

Value

A numeric vector giving the stratum to which each observation in x belongs.

Details

The cum-sqrt-rule is used in order to define H strata from the auxiliary vector x.

Depending on some characteristics of x, e.g. high skewness, few observations or too many ties, the resulting stratification may have a number of strata other than H. Using forced = TRUE tries its best to obtain exactly H strata.

Note that if length(x) < H then forced will be set to FALSE.

References

Sarndal, C.E., Swensson, B. and Wretman, J. (1992). Model Assisted Survey Sampling. Springer.

See Also

optiallo for allocating the sample into the strata using Neyman optimal allocation; varstsi for computing the variance of Stratified Simple Random Sample.

Examples

Run this code
# NOT RUN {
x<- 1 + sort( rgamma(100, shape=4/9, scale=108) )
stratify(x, H=3)
# }

Run the code above in your browser using DataCamp Workspace