R/rfcipPackage_controls.R
apply_default_policy_options.RdEnsures that a dataset contains a standard set of FCIP policy option and
coverage-related fields. For any requested fields that are missing from
data, the function adds them and assigns sensible default values.
This helper is intended to make downstream FCIP pricing and simulation pipelines robust to incomplete or partially specified inputs by enforcing a consistent schema.
apply_default_policy_options(fields = NULL, data)A data.table with all requested policy option fields present.
The following default values are applied when corresponding fields are
missing from data:
Coverage and scaling parameters:
reported_acres = 1
insured_share_percent = 1
price_election_percent = 1
damage_area_rate = 1
Policy option flags (all default to FALSE):
flag_trend_adjustment
flag_quality_loss
flag_yield_exclusion
flag_yield_cup
flag_floor_option_100_percent
flag_yield_adjustment_60_percent
flag_prevented_planting_buy_up
Only fields that are missing are added; existing columns are left unchanged.
Other helpers:
clear_rfcipCalibrate_cache(),
rfcipPackage_controls()
df <- data.frame(commodity_year = 2022L, reported_acres = 100)
apply_default_policy_options(
fields = c("insured_share_percent", "flag_yield_exclusion"),
data = df
)
#> commodity_year reported_acres insured_share_percent flag_yield_exclusion
#> <int> <num> <num> <lgcl>
#> 1: 2022 100 1 FALSE