Skip to contents

Collate regression models into a standardised tibble

Usage

collate_models(models)

Arguments

models

list of regression models supported by {broom}

Value

A tibble with statistics for multiple models.

Examples

# Use the  R Swiss data for examples with a random treatment
set.seed(1234)
swiss <- dplyr::bind_cols(swiss,
                           treatment = rbinom(seq(nrow(swiss)),1, 0.5)) |>
         dplyr::mutate(Education = Education + 0.15 * treatment)

reg1 <- lm(formula = Education ~ treatment, swiss)
reg2 <- lm(formula = Education ~ treatment + Catholic, swiss)
reg3 <- lm(formula = Education ~ treatment * Catholic, swiss)

models <- list(reg1,
               reg2,
               reg3)
collate_models(models = models)
#> # A tibble: 9 × 20
#>   modelID term           estimate std.error statistic p.value conf.low conf.high
#>     <int> <chr>             <dbl>     <dbl>     <dbl>   <dbl>    <dbl>     <dbl>
#> 1       1 (Intercept)    10.1        2.02      5.02   8.70e-6    6.06    14.2   
#> 2       1 treatment       1.81       2.83      0.641  5.25e-1   -3.88     7.50  
#> 3       2 (Intercept)    11.6        2.42      4.77   2.05e-5    6.68    16.4   
#> 4       2 treatment       1.94       2.82      0.687  4.95e-1   -3.75     7.63  
#> 5       2 Catholic       -0.0364     0.0342   -1.06   2.93e-1   -0.105    0.0326
#> 6       3 (Intercept)    11.7        2.75      4.24   1.15e-4    6.12    17.2   
#> 7       3 treatment       1.72       4.05      0.425  6.73e-1   -6.44     9.89  
#> 8       3 Catholic       -0.0388     0.0468   -0.830  4.11e-1   -0.133    0.0555
#> 9       3 treatment:Cat…  0.00530    0.0695    0.0762 9.40e-1   -0.135    0.146 
#> # ℹ 12 more variables: r.squared <dbl>, adj.r.squared <dbl>, sigma <dbl>,
#> #   statistic_model <dbl>, p.value_model <dbl>, df <dbl>, logLik <dbl>,
#> #   AIC <dbl>, BIC <dbl>, deviance <dbl>, df.residual <int>, nobs <int>