Assigns datasets to groups such that the datasets within a group are
statistically poolable (via the poolability_test() likelihood-ratio test)
with one selected non-overlapping grouping. This does not imply that every
cross-group subset fails the pooling test. Grouping is performed per model,
because poolability can differ between the exponential and beta-Poisson
models.
Arguments
- datasets
A named list of dose-response data frames (accepted by
as_dose_response()) or already-standardized tibbles. Unnamed elements are nameddataset_1,dataset_2, and so on.- models
Character vector of models, a subset of
"exponential","beta_poisson", and"exact_beta_poisson".- alpha
Significance level for the chi-squared test.
- method
Grouping strategy.
"agglomerative"(default) starts from singletons and repeatedly merges the most compatible poolable pair until no pair is poolable; it scales to many datasets."exhaustive"enumerates all set partitions and picks the coarsest one whose every group is poolable; it is limited tomax_exhaustivedatasets.- max_exhaustive
Maximum number of datasets allowed for the exhaustive method (the number of set partitions grows super-exponentially).
Value
A long tibble with columns dataset, model, and integer group.
The per-model matrix of pairwise pooling p-values is attached as the
"pairwise" attribute. With method = "exhaustive", a per-model tibble of
every set partition is attached as the "partitions" attribute: partition
(a readable label), groups (a list column of dataset names per group),
n_groups, min_p_value (the smallest within-group pooling p-value),
all_groups_poolable, delta_aic, aic_weight, and selected. Neither
attribute is attached for a single dataset.
Details
Group numbers are labels within a model, not rankings. This function
returns assignments, not pooled datasets or fitted models. Use
poolability_combinations() to inspect overlapping candidate combinations.
Datasets must share one dose_unit when they carry one, as in
poolability_test(); hosts and endpoints are not checked.
The "partitions" AIC weights are a diagnostic, not the selection rule.
Each partition fits one parameter set per group, so its AIC is the summed
group deviance plus twice the number of parameters; aic_weight is the
relative support for that partition among all of them. A weight spread over
several partitions means the data do not single out one grouping. Selecting
by minimum AIC would split datasets more readily than the likelihood-ratio
rule: its penalty per extra group (2k) is a lower bar than the chi-squared
critical value at alpha (2 versus 3.84 for the exponential model at 0.05),
and the search gives it many partitions to choose from.
Examples
path <- system.file("extdata", "pooling-example.csv", package = "singlehit")
raw <- readr::read_csv(path, show_col_types = FALSE)
trials <- split(raw, raw$study_id)
groups <- group_datasets(trials, method = "exhaustive")
groups
#> # A tibble: 6 × 3
#> dataset model group
#> <chr> <chr> <int>
#> 1 A exponential 1
#> 2 B exponential 1
#> 3 C exponential 2
#> 4 A beta_poisson 1
#> 5 B beta_poisson 1
#> 6 C beta_poisson 2
# For both models, A and B share group 1; C is in group 2.
attr(groups, "pairwise")
#> $exponential
#> A B C
#> A 1.000000e+00 9.401151e-01 2.501644e-66
#> B 9.401151e-01 1.000000e+00 4.059272e-67
#> C 2.501644e-66 4.059272e-67 1.000000e+00
#>
#> $beta_poisson
#> A B C
#> A 1.000000e+00 9.253161e-01 9.596625e-62
#> B 9.253161e-01 1.000000e+00 4.309225e-62
#> C 9.596625e-62 4.309225e-62 1.000000e+00
#>
# A + B | C carries most of the AIC weight; A | B | C is the runner-up.
attr(groups, "partitions")$exponential[c("partition", "selected", "aic_weight")]
#> # A tibble: 5 × 3
#> partition selected aic_weight
#> <chr> <lgl> <dbl>
#> 1 A + B + C FALSE 1.04e-86
#> 2 A + B | C TRUE 7.31e- 1
#> 3 A + C | B FALSE 3.96e-65
#> 4 A | B + C FALSE 6.47e-66
#> 5 A | B | C FALSE 2.69e- 1
