fieldopt fieldopt hex logo

R-CMD-check Codecov Lifecycle: experimental

Area-frame and dual-frame survey design under real field cost. Survey samples are usually designed for precision alone; the cost that actually decides whether a survey happens is the field work: travelling between sampling units and interviewing. fieldopt puts that cost next to the variance of the estimator so that both are visible when the design is chosen, and provides the pieces an agricultural survey with an area frame (grid cells, points inside them) and a list frame needs.

The numerical engine is the Rust crate fieldopt-core, usable on its own from Rust or from other languages.

Installation

The development version needs a Rust toolchain (cargo and rustc 1.70 or later, from https://rustup.rs):

# install.packages("pak")
pak::pak("castlaboratory/fieldopt")

Example

library(fieldopt)
library(dplyr)

set.seed(1)
frame <- tibble(
  unit = c("depot", paste0("s", 1:40)),
  x = c(5, runif(40, 0, 10)), y = c(5, runif(40, 0, 10))
) |>
  mutate(crop = if_else(unit == "depot", NA_real_, 20 + 3 * x + rnorm(n())))

model <- field_cost_model(
  per_travel = 2, per_unit = 30, per_interview = 10,
  interviews_per_unit = 4, currency = "BRL"
)

# one design: select, route, price, estimate
s <- frame |>
  filter(unit != "depot") |>
  select_units(n = 12)
r <- s |>
  travel_matrix(bases = frame |> filter(unit == "depot"), method = "euclidean") |>
  route_fieldwork(units = s, depot = "depot", max_stops = 5, cost_model = model)
r
design_variance(s, y = "crop")

# the frontier across sample sizes
f <- cost_variance_frontier(
  frame,
  depot = "depot", cost_model = model,
  n_grid = c(8, 12, 16, 24), y = "crop",
  method = "euclidean", max_stops = 5, n_rep = 10
)
autoplot(f)

How it works

Life cycle of a field survey with fieldopt and the packages it talks to

Architecture of fieldopt: R package, extendr bindings and the fieldopt-core Rust crate

Workflow of fieldopt: frame, travel matrix, selection, routing and the schedule, cost and variance, and the frontier

Area-frame workflow of fieldopt: cells, points, hits, multiplicity estimator, design effect, routed cost, the dual-frame allocation and the dual-frame estimate

Spatially balanced sampling and its variance estimator follow Grafström, Lundström and Schelin (2012) and Grafström and Schelin (2014), as implemented in BalancedSampling; the allocations are Cochran’s (1977) cost-optimal allocations and Hartley’s (1962, 1974) dual-frame design; the dual-frame estimators (Hartley, Fuller-Burmeister, Kalton-Anderson, pseudo-maximum likelihood, calibration) are in Frames2. What fieldopt adds is the design side with the routing and the cost model, so that the field cost of a design is computed instead of approximated by the sample size.

Authors

André Leite (UFPE), Raydonal Ospina (UFBA) and Cristiano Ferraz (UFPE), CAST Lab. Licence GPL (>= 3).

mirror server hosted at Truenetwork, Russian Federation.