stratify: Stratification of an Auxiliary Variable

Description Usage Arguments Details Value References See Also Examples

View source: R/stratify.R

Description

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

Usage

1
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.

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.

Value

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

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.

Examples

1
2
x<- 1 + sort( rgamma(100, shape=4/9, scale=108) )
stratify(x, H=3)

Example output

sh: 1: cannot create /dev/null: Permission denied
Loading required package: shiny
Loading required package: mvtnorm
Loading required package: cubature
  [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
 [38] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
 [75] 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3

optimStrat documentation built on Nov. 11, 2020, 5:07 p.m.