Learn R Programming

MOSAlloc (version 1.2.3)

constructDobjCostSTRS: Constructor for cost objective components

Description

A helper function for generating cost matrix D and fixed cost vector d under stratified random sampling (STRS) as input to the multiobjective allocation function mosalloc().

Usage

constructDobjCostSTRS(X_cost, X_fixed, list)

Value

The function constructDobjCostSTRS() returns a list containing

$D (type: matrix): the cost coefficient matrix for cost objectives and

$d (type: vector): the vector of fixed costs
useable as input to the multiobjective allocation function mosalloc().

Arguments

X_cost

(type: matrix) A matrix containing stratum- (rows) and type- (columns) specific cost coefficients associated with fixed cost. Types of cost might be, e.g. '$ US', 'minutes', 'sample size', etc.

X_fixed

(type: matrix) A matrix containing stratum- (rows) and type- (columns) specific cost coefficients associated with fixed cost.

list

(type: list) A list of lists taking subpopulation- (domain/area) specific arguments. Elements are lists containing the following components corresponding to one specific cost type:
..$stratum_id (type: numeric) A vector containing the indices of the strata considered for the current objective. The indices must coincide with the row numbers of X_cost.
..$c_type (type: character or numeric) The column name or column index of X_cost to be addressed.
..$name (type: character) The name of the subpopulation (domain/area).

Examples

Run this code
# Assume we are given two regions stratified into three strata each. We now
# might balance the cost of surveying between both regions.

# Stratum-specific variable cost
ch <- c(25, 40, 33, 18, 53, 21)
names(ch) <- c("R1_S1", "R1_S2", "R1_S3",
               "R2_S1", "R2_S2", "R2_S3")

# Stratum-specific fixed cost
cf <- c(55, 50, 55, 50, 55, 50)
names(cf) <- c("R1_S1", "R1_S2", "R1_S3",
               "R2_S1", "R2_S2", "R2_S3")

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

D <- matrix(c(ch[1:3], rep(0, 6), ch[4:6]), 2, 6, byrow = TRUE)
d <- as.vector(c(sum(cf[1:3]), sum(cf[4:6])))

# Using \code{constructDobjCostSTRS()} this can also be done via

X_cost <- matrix(ch, ncol = 1)
colnames(X_cost) <- "$ US"

X_fixed <- matrix(cf, ncol = 1)
colnames(X_fixed) <- "$ US"

list <- list(list(stratum_id = 1:3, c_type = "$ US", name = "R1"),
             list(stratum_id = 4:6, c_type = "$ US", name = "R2"))
Dc <- constructDobjCostSTRS(X_cost, X_fixed, list)

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

Run the code above in your browser using DataLab