Skip to contents

Fits each component's data with its own model through fit_cached(), so a second call reuses the saved fits while nothing that determines them has changed.

Usage

fit_components(sim_set, dir, prior = NULL, ..., .fitter = NULL)

Arguments

sim_set

A bmmtools_simulation_set from simulate_components().

dir

The directory the fits are saved in, one file per component, named after it (<dir>/<name>.rds, with its cache key next to it).

prior

NULL, or a named list with a prior for some of the components, such as list(sdm = <brmsprior>). A component not named is fitted with bmm's default priors.

...

Passed to fit_cached() and on to the fitter, for every component: refit, and sampler arguments such as chains, iter or backend. When the set was simulated with a seed and ... has no seed, the set's seed is passed as seed, the same for every component.

.fitter

The fitting function, bmm::bmm() by default; see fit_cached().

Value

A named list of fits, one per component, of class bmmtools_fit_set, which extract_correlations(), recover_correlations() and subject_table() read as one set.

Details

A component fitted without a formula uses recovery_formula(), with the task column when the component has tasks.

Examples

if (FALSE) { # \dontrun{
fits <- fit_components(set, dir = "fits", chains = 4, iter = 2000)
fits
} # }