Temporary helpers for rebuilding the spreadsheet summaries used in earlier list-experiment projects. The naming and interface are expected to change, so treat these as stopgaps rather than stable APIs.
Usage
lx_summary_for_cohort_set(models, cohort_set)
lx_summary_for_cohort_set_render(summary, drop_empty_components = TRUE)Arguments
- models
A list of
"lx_model"objects created withlx_fit(). List names are ignored.- cohort_set
Either a cohort set created with
g6tr.cohorts::create_cohort_set(), or a character vector passed through tolx_predict_for_cohorts()for each model (for example,"predictors").- summary
Output from
lx_summary_for_cohort_set().- drop_empty_components
Logical; when
TRUE(default), omit component columns for subgroup blocks where that component is absent fromsummary. Set toFALSEto keep empty component slots.
Value
lx_summary_for_cohort_set() returns a tibble with posterior summaries for
each cohort and component, plus reference deltas and tail probabilities.
lx_summary_for_cohort_set_render() returns an openxlsx workbook with the
formatted summaries.
Details
lx_summary_for_cohort_set() computes posterior summaries for every cohort in
cohort_set and then creates reference deltas using the first cohort in the
set (typically the full population row produced by
g6tr.cohorts::create_cohort_set()). Statement labels in downstream
spreadsheets are derived from model metadata:
use
statementwhen available,otherwise fall back to
experimentwith a warning.
If neither metadata field is available for any model, or derived labels are duplicated, the function aborts.
lx_summary_for_cohort_set_render() formats the summary into two worksheets
(within-cohort and population-comparison results) stored in an openxlsx
workbook.
By default, the rendered workbook omits component columns that are absent
for a particular subgroup block.
Examples
if (FALSE) { # \dontrun{
model <- lx_set_metadata(
example_lx_model,
statement = "Adopt a shelter pet this year."
)
models <- list(model)
cohort_set <- example_srv_lx |>
g6tr.cohorts::create_cohort_set(
id_col = response_id,
grp_cols = c(d_gender),
weight_col = weight
)
summary <- lx_summary_for_cohort_set(models, cohort_set)
wb <- lx_summary_for_cohort_set_render(summary)
} # }