Field cost per sampled unit at a given sample size, from the routing
Source:R/design.R
routed_unit_cost.RdSelects n units from the frame n_rep times, routes each sample from
the depot, prices it with the cost model and returns the mean cost per
sampled unit. This is the planning value of the cost of a primary unit
(c1 in two_stage_allocation()) or of an area-frame unit (cost_a in
dual_frame_allocation()); it depends on n because a larger sample is
denser and cheaper to reach per unit.
Usage
routed_unit_cost(
frame,
depot,
cost_model,
n,
size = NULL,
strata = NULL,
selection = c("lpm", "systematic", "srs"),
replicates = 1,
matrix = NULL,
method = c("haversine", "euclidean", "osrm"),
max_length = Inf,
max_stops = Inf,
n_rep = 10,
iterations = 100,
seed = 1,
contact_rate = 1,
max_calls = 1
)Arguments
- frame
Data frame of units as in
select_units(), including the depot row named indepot.- depot
Name of the depot unit in
frame$unit.- cost_model
- n
Sample size (a number, or a vector named by stratum).
- size
Optional size column for probability-proportional-to-size selection.
- strata
Optional stratum column, passed to
select_units().- selection
Selection method of
select_units():"lpm","systematic"or"srs".- replicates
Replicates of a
"systematic"selection.- matrix
Optional
travel_matrix()of the frame (computed from the coordinates otherwise).- method
Distance method of
travel_matrix()whenmatrixisNULL("osrm"queries the road network once for the whole frame).- max_length, max_stops
Route limits passed to
route_fieldwork().- n_rep
Replications per sample size.
- iterations
GRASP iterations per routing.
- seed
Seed.
- contact_rate
Probability that a visit completes a unit: a single number, or the name of a column of
framewith one probability per unit. Below 1, the field work is routed with call-backs (route_callbacks()).- max_calls
Maximum number of calls to a unit when
contact_rateis below 1 (1 for no call-backs: the units not completed at the first visit are lost).
Value
A one-row tibble: n, cost_per_unit, travel_per_unit,
cost_mean, routes_mean, n_rep; with call-backs (contact_rate
below 1) also visits_mean and completed_mean, and cost_per_unit
is the cost per unit completed.
Examples
set.seed(1)
frame <- data.frame(
unit = c("depot", paste0("s", 1:40)),
x = c(5, runif(40, 0, 10)), y = c(5, runif(40, 0, 10))
)
model <- field_cost_model(
per_travel = 2, per_unit = 30, per_interview = 10,
interviews_per_unit = 4
)
routed_unit_cost(frame, "depot", model,
n = 12, method = "euclidean", n_rep = 3,
iterations = 20
)
#> # A tibble: 1 × 6
#> n cost_per_unit travel_per_unit cost_mean routes_mean n_rep
#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 12 75.6 2.78 907. 1 3