rna_rec: RNA - Recursive Implementation

View source: R/algorithms_1sided.R

rna_recR Documentation

RNA - Recursive Implementation

Description

[Experimental]

Usage

rna_rec(
  total_cost,
  A,
  bounds = NULL,
  unit_costs = rep(1, length(A)),
  check_violations = .Primitive(">=")
)

Arguments

total_cost

(number)
total cost c of the survey. A strictly positive scalar.

A

(numeric)
population constants A_1,\ldots,A_H. Strictly positive numbers.

bounds

(numeric or NULL)
optional lower bounds m_1,\ldots,m_H, or upper bounds M_1,\ldots,M_H, or NULL to indicate that there is no inequality constraints in the optimization problem considered. If not NULL, the bounds is to be treated either as:

  • lower bounds, if check_violations = .Primitive("<="). In this case, it is required that total_cost >= sum(unit_costs * bounds),
    or

  • upper bounds, if check_violations = .Primitive(">="). In this case, it is required that total_cost <= sum(unit_costs * bounds).

unit_costs

(numeric)
costs c_1,\ldots,c_H, of surveying one element in stratum. A strictly positive numbers. Can be also of length 1, if all unit costs are the same for all strata. In this case, the elements will be recycled to the length of bounds.

check_violations

(function)
2-arguments binary operator function that allows the comparison of values in atomic vectors. It must either be set to .Primitive("<=") or .Primitive(">="). The first of these choices causes that bounds are treated as lower bounds and then rna() function performs the LRNA algorithm. The latter option causes that bounds are treated as upper bounds, and then rna() function performs the RNA algorithm. This argument is ignored when bounds is set to NULL.

Note

this coded was not extensively tested.

Examples

A <- c(3000, 4000, 5000, 2000)
M <- c(100, 90, 70, 80) # upper bounds.
rna_rec(total_cost = 190, A = A, bounds = M)
rna_rec(total_cost = 312, A = A, bounds = M)
rna_rec(total_cost = 339, A = A, bounds = M)
rna_rec(total_cost = 340, A = A, bounds = M)

stratallo documentation built on Nov. 27, 2023, 1:07 a.m.