Turn models fit to simulated data (from fit) into a tidy tibble of model estimates (via broom::tidy).

tidy_fits(obj, ..., .progress = FALSE, .options = furrr_options())

Arguments

obj

a simpr_tibble with fitted models, from fit

...

Additional arguments to the broom::tidy method.

.progress

A logical, for whether or not to print a progress bar for multiprocess, multisession, and multicore plans .

.options

The future specific options to use with the workers when using futures. This must be the result from a call to furrr_options().

Value

a tibble with the output of the

broom::tidy method applied to each model fit and then bound into a single tibble.

Details

This the fifth step of the simulation process: after fitting the model with fit, now tidy the model output for further analysis such as evaluating power. All model objects should be supported by broom::tidy. See apply_fits for applying any arbitrary function to the data, including other tidiers.

The output of this function is quite useful for diagnosing bias, precision, and power. For looking at overall features of the model (e.g., R-squared), use glance_fits.

See also

glance_fits to view overall model statistics (e.g. R-squared), apply_fits to apply an arbitrary function to the fits

Examples

simple_linear_data = specify(a = ~ 2 + rnorm(n),
          b = ~ 5 + 3 * x1 + rnorm(n, 0, sd = 0.5)) %>%
  define(n = 100:101) %>%
  generate(2)
#> Warning: Simulation produced errors.  See column '.sim_error'.

## Can show tidy output for multiple competing models,
compare_degree = simple_linear_data %>%
  fit(linear = ~lm(a ~ b, data = .),
      quadratic = ~lm(a ~ b + I(b^2), data = .)) %>%
  tidy_fits
#> Warning: fit() produced errors.  See '.fit_error_*' column(s).

compare_degree
#> # A tibble: 8 × 6
#>   .sim_id     n   rep .sim_error                                  Source .fit_…¹
#>     <int> <int> <int> <chr>                                       <chr>  <chr>  
#> 1       1   100     1 "\u001b[1m\u001b[33mError\u001b[39m in `ma… linear "Error…
#> 2       1   100     1 "\u001b[1m\u001b[33mError\u001b[39m in `ma… quadr… "Error…
#> 3       2   101     1 "\u001b[1m\u001b[33mError\u001b[39m in `ma… linear "Error…
#> 4       2   101     1 "\u001b[1m\u001b[33mError\u001b[39m in `ma… quadr… "Error…
#> 5       3   100     2 "\u001b[1m\u001b[33mError\u001b[39m in `ma… linear "Error…
#> 6       3   100     2 "\u001b[1m\u001b[33mError\u001b[39m in `ma… quadr… "Error…
#> 7       4   101     2 "\u001b[1m\u001b[33mError\u001b[39m in `ma… linear "Error…
#> 8       4   101     2 "\u001b[1m\u001b[33mError\u001b[39m in `ma… quadr… "Error…
#> # … with abbreviated variable name ¹​.fit_error

## Models can be anything supported by broom::tidy.
cor_vs_lm = simple_linear_data %>%
  fit(linear = ~lm(a ~ b, data = .),
      cor = ~ cor.test(.$a, .$b)) %>%
  tidy_fits
#> Warning: fit() produced errors.  See '.fit_error_*' column(s).

cor_vs_lm # has NA for non-matching terms
#> # A tibble: 8 × 6
#>   .sim_id     n   rep .sim_error                                  Source .fit_…¹
#>     <int> <int> <int> <chr>                                       <chr>  <chr>  
#> 1       1   100     1 "\u001b[1m\u001b[33mError\u001b[39m in `ma… linear "Error…
#> 2       1   100     1 "\u001b[1m\u001b[33mError\u001b[39m in `ma… cor    "Error…
#> 3       2   101     1 "\u001b[1m\u001b[33mError\u001b[39m in `ma… linear "Error…
#> 4       2   101     1 "\u001b[1m\u001b[33mError\u001b[39m in `ma… cor    "Error…
#> 5       3   100     2 "\u001b[1m\u001b[33mError\u001b[39m in `ma… linear "Error…
#> 6       3   100     2 "\u001b[1m\u001b[33mError\u001b[39m in `ma… cor    "Error…
#> 7       4   101     2 "\u001b[1m\u001b[33mError\u001b[39m in `ma… linear "Error…
#> 8       4   101     2 "\u001b[1m\u001b[33mError\u001b[39m in `ma… cor    "Error…
#> # … with abbreviated variable name ¹​.fit_error