View source: R/constructDobjCostSTRS.R
| constructDobjCostSTRS | R Documentation |
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().
constructDobjCostSTRS(X_cost, X_fixed, list)
X_cost |
(type: |
X_fixed |
(type: |
list |
(type: |
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
usable as input to the multiobjective allocation function
mosalloc().
# 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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.