Given a calibrated producer data set, this function:

  1. Creates a placeholder lookup rate by averaging rate_yield and calibrated_yield, then running the FCIP calculator rfcipCalcPass::fcip_calculator() to obtain revenue_lookup_rate.

  2. Joins in ADM parameters (beta IDs, price volatility factors, harvest prices, combo revenue factors).

  3. Computes adjusted mean and standard-deviation of yield, and log-mean of price.

  4. Retrieves 500 RMA beta draws and uses them to generate 500 simulated yields and prices per farm.

  5. Returns a data.table with one row per farm (grouped by farm_identifiers) containing lists of draws.

rma_500_revenue_draw(
  farmdata,
  farm_identifiers,
  control = rfcipPackage_controls()
)

Arguments

farmdata

A data.frame or data.table of observed or/and calibrated producer records. Must include at least:

  • rate_yield and calibrated_yield (for lookup rate)

  • approved_yield, mean_quantity, standard_deviation_quantity

  • commodity_year and all fields in rfcipCalcPass::FCIP_INSURANCE_POOL

farm_identifiers

column name(s) that uniquely identify each record/farm/producer. If NULL, a "producer_id" column is created.

control

a list of control parameters;continuous_integration_session set via control to determine the ADM source. see rfcipPackage_controls.

Value

A data.table with one row per unique farm identifier. Columns:

  • rma_draw_lookup_rate: Mean of the simulated lookup rate (should equal the pre-draw lookup rate)

  • rma_draw_number: List of 500 sequence numbers (1-500).

  • rma_draw_yield: List of 500 simulated yields (numeric).

  • rma_draw_price: List of 500 simulated prices (numeric).

Examples

if (FALSE) { # \dontrun{
library(data.table)
farmdata <- readRDS("data-raw/calibrated_producer.rds")
# Suppose each record has a column "producer_id"
results <- rma_500_revenue_draw(farmdata, "producer_id")
str(results)
} # }