fit_all_data_and_wire
Fit marginal distributions and copula dependence from a data block, then wire the correlated simulation-ready model into the workbook in one reversible pass.
Instructions
ModelRisk: Fit BOTH the marginal distributions and the copula dependence from a data block, then wire the whole correlated, simulation-ready model into the workbook in one reversible pass. For each variable column it fits+ranks the best marginal (AIC/SIC/HQIC); across the columns it fits the best copula (fit_copula_to_data) and writes the correlated-U block at copula_anchor; each marginal is wired to its copula U so the inputs are dependent, not independent — capturing the tail co-movement a single correlation coefficient discards. Optionally runs a validating simulation. Defaults to dry_run=True (returns the exact planned formulas without writing). On any mid-build failure the whole change-set is rolled back. This is the data→model step no advisory agent can perform.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| run | No | Run a validating simulation after wiring. Default False. | |
| seed | No | ||
| sheet | Yes | Sheet holding the data and target cells. | |
| columns | Yes | One entry per data column, in column order: {'input_name': 'Demand', 'target_cell': 'F2'}. | |
| dry_run | No | Preview the planned formulas without writing. Default True. | |
| samples | No | ||
| workbook | Yes | Workbook file name. | |
| criterion | No | Fit criterion: 'SIC' (default), 'AIC', or 'HQIC'. | SIC |
| data_range | Yes | Rectangular data block, one column per variable, e.g. 'A2:C500'. | |
| uncertainty | No | Fit with parameter uncertainty. Default False. | |
| target_sheet | No | Sheet holding the target cells and the copula block. Defaults to `sheet` (the data sheet) — pass this when the model lives on a different sheet than the data, e.g. data on 'Data', wired inputs on 'Model'. | |
| copula_anchor | No | Top cell for the correlated-U block. Omit to skip correlation. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| note | Yes | ||
| sheet | Yes | ||
| steps | Yes | Ordered log of what happened. | |
| columns | Yes | ||
| dry_run | Yes | ||
| workbook | Yes | ||
| simulated | Yes | Whether a validating simulation was run. | |
| rolled_back | No | True if a mid-build failure triggered a full rollback. | |
| copula_anchor | No | Range where the correlated-U block was written. | |
| copula_family | No | Best-fit copula family wired across the columns, if any. | |
| achieved_correlation | No | Rank correlation of the wired inputs from the validating run. |