optiallo: Optimal allocation in stratified simple random sampling

Description Usage Arguments Details Value See Also Examples

View source: R/optiallo.R

Description

Allocates a sample of size n using Neyman optimal allocation in Stratified Simple Random Sampling.

Usage

1
optiallo(n, x, stratum = NULL, ...)

Arguments

n

a positive integer indicating the desired sample size.

x

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

stratum

a vector indicating the stratum to which every unit belongs (see ‘Details’).

...

other arguments passed to stratify (see ‘Details’).

Details

Allocates a sample of size n using Neyman optimal allocation in Stratified Simple Random Sampling.

If stratum==NULL, the stratification is generated via stratify. Then at least the number of strata should be passed to stratify using the argument H.

Value

A list with two elements:

stratum

a vector indicating the stratum to which each element belongs.

nh

a vector indicating the sample size of the strata to which each element belongs.

See Also

stratify for defining the stratification using the cum-sqrt-rule.

Examples

1
2
3
4
5
x<- 1 + sort( rgamma(100, shape=4/9, scale=108) )
st1<- stratify(x,H=6)
optiallo(n=30,x,stratum=st1)

optiallo(n=30,x,H=6)

Example output

Loading required package: shiny
Loading required package: mvtnorm
Loading required package: cubature
$stratum
  [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 2 2 2 2 2 2 2 2 2 2 2
 [38] 2 2 2 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 3 3 4 4 4 4 4 4
 [75] 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6

$nh
  [1] 2.020313 2.020313 2.020313 2.020313 2.020313 2.020313 2.020313 2.020313
  [9] 2.020313 2.020313 2.020313 2.020313 2.020313 2.020313 2.020313 2.020313
 [17] 2.020313 2.020313 2.020313 2.020313 2.020313 2.020313 2.020313 2.020313
 [25] 2.020313 2.020313 4.896141 4.896141 4.896141 4.896141 4.896141 4.896141
 [33] 4.896141 4.896141 4.896141 4.896141 4.896141 4.896141 4.896141 4.896141
 [41] 4.896141 4.896141 4.896141 4.896141 4.896141 4.896141 4.896141 4.896141
 [49] 4.896141 4.896141 4.896141 4.896141 4.896141 4.154946 4.154946 4.154946
 [57] 4.154946 4.154946 4.154946 4.154946 4.154946 4.154946 4.154946 4.154946
 [65] 4.154946 4.154946 4.154946 4.154946 4.871185 4.871185 4.871185 4.871185
 [73] 4.871185 4.871185 4.871185 4.871185 4.871185 4.871185 4.871185 4.871185
 [81] 4.871185 4.871185 4.871185 7.057415 7.057415 7.057415 7.057415 7.057415
 [89] 7.057415 7.057415 7.057415 7.057415 7.057415 7.000000 7.000000 7.000000
 [97] 7.000000 7.000000 7.000000 7.000000

$stratum
  [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 2 2 2 2 2 2 2 2 2 2 2
 [38] 2 2 2 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 3 3 4 4 4 4 4 4
 [75] 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6

$nh
  [1] 2.020313 2.020313 2.020313 2.020313 2.020313 2.020313 2.020313 2.020313
  [9] 2.020313 2.020313 2.020313 2.020313 2.020313 2.020313 2.020313 2.020313
 [17] 2.020313 2.020313 2.020313 2.020313 2.020313 2.020313 2.020313 2.020313
 [25] 2.020313 2.020313 4.896141 4.896141 4.896141 4.896141 4.896141 4.896141
 [33] 4.896141 4.896141 4.896141 4.896141 4.896141 4.896141 4.896141 4.896141
 [41] 4.896141 4.896141 4.896141 4.896141 4.896141 4.896141 4.896141 4.896141
 [49] 4.896141 4.896141 4.896141 4.896141 4.896141 4.154946 4.154946 4.154946
 [57] 4.154946 4.154946 4.154946 4.154946 4.154946 4.154946 4.154946 4.154946
 [65] 4.154946 4.154946 4.154946 4.154946 4.871185 4.871185 4.871185 4.871185
 [73] 4.871185 4.871185 4.871185 4.871185 4.871185 4.871185 4.871185 4.871185
 [81] 4.871185 4.871185 4.871185 7.057415 7.057415 7.057415 7.057415 7.057415
 [89] 7.057415 7.057415 7.057415 7.057415 7.057415 7.000000 7.000000 7.000000
 [97] 7.000000 7.000000 7.000000 7.000000

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