A convenience function for use with a regression model or list of regression models.
Returns a named list of models, where the names are the models' respective dependent variables.
If the dependent variables are labelled, the labels are used as names.
Pass your list of models to dvnames before sending to modelsummary to automatically get dependent variable-titled columns.
Arguments
- models
A regression model or list of regression models
- number
Should the models be numbered (1), (2), etc., in addition to their dependent variable names?
- strip
boolean FALSE returns the dependent variable names as they appear in the model. TRUE returns the dependent variable names as they appear in the data, without transformations.
- fill
If
insight::find_response()cannot find a response, the column title to use in its place. Set to' 'to leave blank.
Examples
m1 <- lm(mpg ~ hp, data = mtcars)
m2 <- lm(mpg ~ hp + wt, data = mtcars)
# Without dvnames, column names are (1) and (2)
modelsummary(list(m1, m2))
#>
#> +-------------+---------+---------+
#> | | (1) | (2) |
#> +=============+=========+=========+
#> | (Intercept) | 30.099 | 37.227 |
#> +-------------+---------+---------+
#> | | (1.634) | (1.599) |
#> +-------------+---------+---------+
#> | hp | -0.068 | -0.032 |
#> +-------------+---------+---------+
#> | | (0.010) | (0.009) |
#> +-------------+---------+---------+
#> | wt | | -3.878 |
#> +-------------+---------+---------+
#> | | | (0.633) |
#> +-------------+---------+---------+
#> | Num.Obs. | 32 | 32 |
#> +-------------+---------+---------+
#> | R2 | 0.602 | 0.827 |
#> +-------------+---------+---------+
#> | R2 Adj. | 0.589 | 0.815 |
#> +-------------+---------+---------+
#> | AIC | 181.2 | 156.7 |
#> +-------------+---------+---------+
#> | BIC | 185.6 | 162.5 |
#> +-------------+---------+---------+
#> | Log.Lik. | -87.619 | -74.326 |
#> +-------------+---------+---------+
#> | F | 45.460 | 69.211 |
#> +-------------+---------+---------+
#> | RMSE | 3.74 | 2.47 |
#> +-------------+---------+---------+
# With dvnames, they are "mpg" and "mpg"
modelsummary(dvnames(list(m1,m2)))
#>
#> +-------------+---------+---------+
#> | | mpg | mpg |
#> +=============+=========+=========+
#> | (Intercept) | 30.099 | 37.227 |
#> +-------------+---------+---------+
#> | | (1.634) | (1.599) |
#> +-------------+---------+---------+
#> | hp | -0.068 | -0.032 |
#> +-------------+---------+---------+
#> | | (0.010) | (0.009) |
#> +-------------+---------+---------+
#> | wt | | -3.878 |
#> +-------------+---------+---------+
#> | | | (0.633) |
#> +-------------+---------+---------+
#> | Num.Obs. | 32 | 32 |
#> +-------------+---------+---------+
#> | R2 | 0.602 | 0.827 |
#> +-------------+---------+---------+
#> | R2 Adj. | 0.589 | 0.815 |
#> +-------------+---------+---------+
#> | AIC | 181.2 | 156.7 |
#> +-------------+---------+---------+
#> | BIC | 185.6 | 162.5 |
#> +-------------+---------+---------+
#> | Log.Lik. | -87.619 | -74.326 |
#> +-------------+---------+---------+
#> | F | 45.460 | 69.211 |
#> +-------------+---------+---------+
#> | RMSE | 3.74 | 2.47 |
#> +-------------+---------+---------+