# 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