R/rma_500_revenue_draw.R
rma_500_revenue_draw.RdGiven a calibrated producer data set, this function:
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.
Joins in ADM parameters (beta IDs, price volatility factors, harvest prices, combo revenue factors).
Computes adjusted mean and standard-deviation of yield, and log-mean of price.
Retrieves 500 RMA beta draws and uses them to generate 500 simulated yields and prices per farm.
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()
)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
column name(s) that uniquely identify each record/farm/producer. If NULL, a "producer_id" column is created.
a list of control parameters;continuous_integration_session
set via control to determine the ADM source. see rfcipPackage_controls.
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).
Other Yield/Revenue Calibration:
adjust_revenue_to_yield_equivalence(),
calibrate_yield(),
prepare_yield_calibration_data(),
rate_yield_optimizer()
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)
} # }