Skip to contents

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.

Usage

group_datasets(
  datasets,
  models = c("exponential", "beta_poisson"),
  alpha = 0.05,
  method = c("agglomerative", "exhaustive"),
  max_exhaustive = 6L
)

Arguments

datasets

A named list of dose-response data frames (accepted by as_dose_response()) or already-standardized tibbles. Unnamed elements are named dataset_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 to max_exhaustive datasets.

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.

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. Check metadata compatibility before grouping; it is not enforced here.

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
#>