surveyplanning (version 1.8)

expvar: Expected precision for the estimates of totals

Description

The function computes expexted precision as variance, standard error, and coefficient of variation for the estimates of totals.

Usage

expvar(Yh, Zh=NULL, H, s2h, nh, poph, Rh = NULL, deffh = NULL, Dom = NULL, dataset = NULL)

Arguments

Yh
The expected totals for variables of interest in each stratum. Object convertible to data.table, variable names as character vector, or column numbers.
Zh
Optional variables of denominator for the expected ratio estimation in each stratum. Object convertible to data.table, variable names as character vector, or column numbers.
H
The stratum variable. One dimensional object convertible to one-column data.table, variable name as character, or column number.
s2h
The expected population variance $S^2$ for variables of interest in each stratum. Variables is defined the same arrangement as Yh. Object convertible to data.table, variable name as character vector, or column numbers.
nh
Sample size in each stratum. One dimensional object convertible to one-column data.table, variable name as character, or column number.
poph
Population size in each stratum. One dimensional object convertible to one-column data.table, variable name as character, or column number.
Rh
The expected response rate in each stratum (optional). If not defined, it is assumed to be 1 in each stratum (full-response). Object convertible to one-column data.table, variable name as character, or column number.
deffh
The expected design effect for the estimates of totals (optional). If not defined, it is assumed to be 1 for each variable in each stratum. If is defined, then variables is defined the same arrangement as Yh. Object convertible to data.table, variable name as character vector, or column numbers.
Dom
Optional variables used to define population domains. Only domains as unions of strata can be defined. If supplied, estimated precision is calculated for each domain. An object convertible to data.table, variable names as character vector, or column numbers.
dataset
Optional survey data object convertible to data.table with one row for each stratum.

Value

A list with three data objects:
resultH
An object as data.table, with variables: H - stratum, variableY - the name of variable of interest, variableZ - the name of optional variable of denominator for the expected ratio estimation, estim - total value, deffh - the expected design effect, s2h - population variance $S^2$, nh - sample size, Rh - the expected response rate, poph - population size, nrh - expected number of respondents, var - expected variance, se - expected standard error, cv - expected coeficient of variance.
resultDom
An object as data.table, with variables: Dom - domain, variableY - the name of variable of interest, variableZ - the name of optional variable of denominator for the expected ratio estimation, poph - the population size, nh - sample size, nrh - expected number of respondents, estim - total value, var - the expected variance, se - the expected standart error, cv - the expected coeficient of variance.
result
An object as data.table, with variables: variableY - the name of variable of interest, variableZ - the name of optional variable of denominator for the expected ratio estimation, poph - the population size, nh - sample size, nrh - expected number of respondents, estim - total value, var - the expected variance, se - the expected standart error, cv - the expected coeficient of variance.

See Also

expsize, optsize, dom_optimal_allocation

Examples

Run this code

data <- data.table(H = 1:3,
                   Yh = 10 * 1:3, Yh1 = 10 * 4:6,
                   s2h = 10 * runif(3), s2h2 = 10 * runif(3),
                   nh = rep(4 * 1:3),
                   poph = 8 * 1:3,
                   Rh = rep(1, 3),
                   deffh = rep(2, 3), deffh2 = rep(3, 3),
                   dd = c(1, 1, 1))

vars <- expvar(Yh = c("Yh", "Yh1"), H = "H",
               s2h = c("s2h", "s2h2"),
               nh = "nh", poph = "poph",
               Rh = "Rh", deffh = c("deffh", "deffh2"),
               dataset = data)

vars

Run the code above in your browser using DataLab