View source: R/optimum_allocation.R
optimum_allocation | R Documentation |
Determines the optimum sampling fraction and sample size for each stratum in a stratified random sample, which minimizes the variance of the sample mean according to Neyman Allocation or Exact Optimum Sample Allocation (Wright 2014).
optimum_allocation(
data,
strata,
y = NULL,
sd_h = NULL,
N_h = NULL,
nsample = NULL,
ndigits = 2,
method = c("WrightII", "WrightI", "Neyman"),
allow.na = FALSE
)
data |
A data frame or matrix with at least one column specifying
each unit's stratum, and either 1) a second column holding the value of the
continuous variable for which the sample mean variance should be minimized
( |
strata |
a character string or vector of character strings specifying the name(s) of columns which specify the stratum that each unit belongs to. If multiple column names are provided, each unique combination of values in these columns is taken to define one stratum. |
y |
a character string specifying the name of the
continuous variable for which the variance should be minimized.
Defaults to |
sd_h |
a character string specifying the name of the
column holding the within-stratum standard deviations for each stratum.
Defaults to |
N_h |
a character string specifying the name of the
column holding the population stratum sizes for each stratum.
Defaults to |
nsample |
the desired total sample size. Defaults to |
ndigits |
a numeric value specifying the number of digits to which the standard deviation and stratum fraction should be rounded. Defaults to 2. |
method |
a character string specifying the method of optimum sample allocation to use. Must be one of:
|
allow.na |
logical input specifying whether y should
be allowed to have NA values. Defaults to |
Returns a data frame with the number of samples allocated to each stratum, or just the sampling fractions if nsample is NULL.
Wright, T. (2014). A Simple Method of Exact Optimal Sample Allocation under Stratification with any Mixed Constraint Patterns, Research Report Series (Statistics #2014-07), Center for Statistical Research and Methodology, U.S. Bureau of the Census, Washington, D.C.
optimum_allocation(
data = iris, strata = "Species", y = "Sepal.Length",
nsample = 40, method = "WrightII"
)
# Or if input data is summary of strata sd and N:
iris_summary <- data.frame(
strata = unique(iris$Species),
size = c(50, 50, 50),
sd = c(0.3791, 0.3138, 0.3225)
)
optimum_allocation(
data = iris_summary, strata = "strata",
sd_h = "sd", N_h = "size",
nsample = 40, method = "WrightII"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.