3 Enumerating the Decision Space
The first verb turns analytic choices into data. Each row of a specification grid is one complete, defensible analysis, and every column records one decision.
3.1 A grid of choices
spec_grid() takes named choices and returns their Cartesian product, one row per combination, with a .spec_id key.
library(forkflow)
spec_grid(
adjust_age = c(TRUE, FALSE),
transform = c("identity", "log"),
missing = c("complete", "impute")
)Adding a choice is one more argument, and the grid grows on its own.
3.2 Adjustment sets
A common epidemiological multiverse varies which covariates adjust a target association. adjuster_sets() returns every subset of a covariate pool, from the empty set to the full set.
adjuster_sets(c("age", "sex", "bmi"))The result carries a list column of covariate names and an n_adjusters count, so later steps can fit each set and can colour figures by model size. A pool of seven covariates yields two to the seventh power, or one hundred twenty-eight, adjustment sets.
3.3 Bounding a large grid
When the pool is large, the full power set becomes unwieldy. The min_size and max_size arguments bound the subset size, and for grids too large to enumerate in full, a random sample of specifications gives an unbiased picture of the distribution. Chapter 9 discusses when sampling is appropriate.