Learn R Programming

MOSAlloc (version 1.2.3)

constructDobjPrecisionSTRS: Constructor for precision objective components

Description

A helper function for generating precision matrix D and finite population correction d under stratified random sampling (STRS) as input to the multiobjective allocation function mosalloc().

Usage

constructDobjPrecisionSTRS(X_var, X_tot, N, list, fpc = TRUE)

Value

The function constructDobjPrecisionSTRS() returns a list containing

$D (type: matrix): the precision matrix for quality objectives and

$d (type: vector): the vector of finite population corrections
useable as input to the multiobjective allocation function mosalloc().

Arguments

X_var

(type: matrix) A matrix containing stratum- (rows) and variable- (columns) specific precision units.

X_tot

(type: matrix) A matrix containing stratum- (rows) and variable- (columns) specific totals.

N

(type: vector) A vector of stratum sizes.

list

(type: list) A list of lists taking subpopulation- (domain/area) specific arguments. Elements are lists containing the following components which inturn correspond to one specific precision restriction:
..$stratum_id (type: numeric) A vector containing the indices of the strata considered for the current objective component. The indices must coincide with the corresponding row numbers of X_var and X_tot.
..$variate (type: character or numeric) The column name or column index of X_var to be addressed.
..$measure (type: character or numeric) As character "relVAR" (relative variance) or "VAR" (variance). A numerical between 0 and 1 indicates a gradation coefficient that balances between "relVar" (..$measure = 0) and "VAR" (..$measure = 1).
..$name (type: character) The name of the subpopulation (domain/area).

fpc

(type: logical) A TRUE or FALSE statement indicating whether the finite population correction should be considered.

Examples

Run this code
# Artificial population of 50 568 business establishments and 5 business
# sectors (data from Valliant, R., Dever, J. A., & Kreuter, F. (2013).
# Practical tools for designing and weighting survey samples. Springer.
# https://doi.org/10.1007/978-1-4614-6449-5, Example 5.2 pages 133-9)

# See also https://umd.app.box.com/s/9yvvibu4nz4q6rlw98ac/file/297813512360
# file: Code 5.3 constrOptim.example.R

Nh <- c(6221, 11738, 4333, 22809, 5467) # stratum sizes

# Revenues
mh.rev <- c(85, 11, 23, 17, 126) # mean revenue
Sh.rev <- c(170.0, 8.8, 23.0, 25.5, 315.0) # standard deviation revenue

# Employees
mh.emp <- c(511, 21, 70, 32, 157) # mean number of employees
Sh.emp <- c(255.50, 5.25, 35.00, 32.00, 471.00) # std. dev. employees

# Proportion of estabs claiming research credit
ph.rsch <- c(0.8, 0.2, 0.5, 0.3, 0.9)

# Proportion of estabs with offshore affiliates
ph.offsh <- c(0.06, 0.03, 0.03, 0.21, 0.77)

budget <- 300000 # overall available budget
n.min  <- 100 # minimum stratum-specific sample size

# Matrix containing stratum-specific variance components
X_var <- cbind(Sh.rev**2,
               Sh.emp**2,
               ph.rsch * (1 - ph.rsch) * Nh/(Nh - 1),
               ph.offsh * (1 - ph.offsh) * Nh/(Nh - 1))
colnames(X_var) <- c("rev", "emp", "rsch", "offsh")

# Matrix containing stratum-specific totals
X_tot <- cbind(mh.rev, mh.emp, ph.rsch, ph.offsh) * Nh
colnames(X_tot) <- c("rev", "emp", "rsch", "offsh")

# Examples
#----------------------------------------------------------------------------
# Example 1: Assume we want to minimize the variation of estimates for
# revenue.
#
# The input \code{D} and \code{d} to \code{mosalloc()} can be calculated as
# follows:

D <- matrix(Sh.rev**2 * Nh**2, nrow = 1) # objective variance components
d <- sum(Sh.rev**2 * Nh) # finite population correction

# Using \code{constructDobjPrecisionSTRS()} this can also be done via
list <- list(list(stratum_id = 1:5, variate = "rev", measure = "VAR",
                  name = "pop"))
Dc <- constructDobjPrecisionSTRS(X_var, X_tot, Nh, list, fpc = TRUE)

# or equivalently by
list <- list(list(stratum_id = 1:5, variate = 1, measure = "VAR",
                  name = "pop"))
Dc <- constructDobjPrecisionSTRS(X_var, X_tot, Nh, list, fpc = TRUE)

# Evaluate output
Dc$D - D
Dc$d - d

# Example 2: Minimization of the maximum coefficient of variation of
# estimates for the total revenue, the number of employee, the number of
# businesses claimed research credit, and the number of businesses with
# offshore affiliates

# The input \code{D} and \code{d} to \code{mosalloc()} can be calculated as
# follows:

D <- rbind(Sh.rev**2 * Nh**2 / sum(Nh * mh.rev)**2,
           Sh.emp**2 * Nh**2 / sum(Nh * mh.emp)**2,
           ph.rsch * (1 - ph.rsch) * Nh**3/(Nh - 1)/sum(Nh * ph.rsch)**2,
           ph.offsh * (1 - ph.offsh) * Nh**3/(Nh - 1)/sum(Nh * ph.offsh)**2)
d <- as.vector(D %*% (1 / Nh)) # finite population correction

# Using \code{constructDobjPrecisionSTRS()} this can also be done via
list <- list(list(stratum_id = 1:5, variate = "rev", measure = "relVAR",
                  name = "pop"),
             list(stratum_id = 1:5, variate = "emp", measure = "relVAR",
                  name = "pop"),
             list(stratum_id = 1:5, variate = "rsch", measure = "relVAR",
                  name = "pop"),
             list(stratum_id = 1:5, variate = "offsh", measure = "relVAR",
                  name = "pop"))
Dc <- constructDobjPrecisionSTRS(X_var, X_tot, Nh, list, fpc = TRUE)

# Evaluation of the output
Dc$D - D
Dc$d - d

Run the code above in your browser using DataLab