Joins attributed unit experience (e.g. from identify_pp_units()) to calibrated yields, forms derived exposure quantities, and collapses units into pseudo-producers over the cell commodity_year x state_code x county_code x commodity_code x type_code x practice_code. The treatment of the (unit_structure_code, insurance_plan_code, coverage_level_percent) election differs by method: grid_free KEEPS the observed election mix (one producer per cell x election triple), while apportioned collapses each cell x grid to a single producer carrying the representative election – the triple covering the most probability-weighted reported acres in the cell; ties break by larger liability, then lowest codes/level. Amounts are summed within the grouping, so totals are conserved either way.

build_agent_panel(
  units,
  cal_yield,
  candidates = NULL,
  method = c("grid_free", "apportioned"),
  plans = c(1:3, 90)
)

Arguments

units

Attributed (or plain) unit experience.

cal_yield

Calibrated yields by unit definition, with simulation_weight and yield columns.

candidates

Candidate RI grids (long with grid_id + probability, or nested with an ri_candidates list-column); required for method = "apportioned".

method

"grid_free" or "apportioned".

plans

Insurance plan codes retained.

Value

data.table: one row per cell x election triple (grid_free) or per cell x grid with the representative triple (apportioned), with exposure, premiums, indemnities, per-acre yields, unit_structure_code, insurance_plan_code, coverage_level_percent, and (when available) the prevented-planting quantities and attribution shares.

Details

Attribution columns, when present, are collapsed to cell-level indemnity shares rather than kept as dimensions: pp_resolved_share_indem, pp_unresolved_share_indem, and is_pp_share_indem from the prevented-planting cascade, and col_resolved_share_indem, col_unresolved_share_indem, plus the representative primary_cause (indemnity-weighted mode within the cell) with its cell-level primary_cause_share from the general attribution. Prevented-planting quantities (acres by basic/buy-up election, PP indemnity) are computed when the attribution columns are present and skipped otherwise, so the panel builds from plain unit experience as well. Two variants share the pipeline:

  • method = "apportioned": each pseudo-producer is split fractionally across its county-commodity candidate RI grids by crop-cover probability (requires candidates); grid_id joins the panel dimensions and the representative election collapses the cell. Totals are conserved exactly; within-county placement risk is smoothed away.

  • method = "grid_free": pseudo-producers are NOT located on grids and retain their observed election triple; the panel carries a content-based agent_uid (built from the cell keys plus the election triple) so sampled whole-grid assignments from assign_ri_grids() can be joined per replication.