fit_multiverse() applies a fitting function to each row of a specification
grid and returns a tidy tibble with one row per returned model term per
specification. Because the fits are independent, they can run in parallel via
furrr when .parallel = TRUE.
Arguments
- specs
A specification grid, for example from
spec_grid()oradjuster_sets().- .f
A function (or a purrr-style formula) applied to each specification. It receives one row of
specsas a one-row tibble; access columns withspec$col, for examplespec$adjusters[[1]]for the output ofadjuster_sets(). It should return a tibble, for example frombroom::tidy().- ...
Additional arguments passed on to
.f.- .parallel
Logical; fit across cores with furrr. Set a plan first with
future::plan().- .seed
Optional integer seed for reproducible parallel fits.
Value
specs with the tidy model output unnested: one row per returned
term per specification, in the original grid order.
Examples
if (FALSE) { # \dontrun{
specs <- adjuster_sets(c("age", "sex", "bmi"))
fit_multiverse(specs, function(spec) {
f <- reformulate(c("exposure", spec$adjusters[[1]]), "outcome")
broom::tidy(lm(f, data = df), conf.int = TRUE)
})
} # }