R/stats.R
make_regression_table.Rd
Turns regression results in a data.frame for easy conversion to a table
make_regression_table(model, coefficients_only = TRUE)
A `lm` object made from making a model using `lm()`.
If TRUE (default), returns only the coefficients,standard error, t-value, p-value, and confidence intervals. Else also returns the r-squared, the adjusted r-squared,f-stat, p-value for the f-stat, and the degrees of freedom.
A data.frame with the regression results
make_regression_table(lm(mpg ~ cyl, data = mtcars))
#> variable estimate standard_error t_value p_value
#> 1 (Intercept) 37.88458 2.0738436 18.267808 8.369155e-18
#> 2 cyl -2.87579 0.3224089 -8.919699 6.112687e-10
#> confidence_interval_lower_95 confidence_interval_upper_95
#> 1 33.649223 42.119930
#> 2 -3.534237 -2.217343
make_regression_table(lm(mpg ~ cyl, data = mtcars), coefficients_only = FALSE)
#> New names:
#> • `value` -> `value...1`
#> • `value` -> `value...2`
#> variable estimate standard_error t_value p_value
#> 1 (Intercept) 37.88458 2.0738436 18.267808 8.369155e-18
#> 2 cyl -2.87579 0.3224089 -8.919699 6.112687e-10
#> confidence_interval_lower_95 confidence_interval_upper_95 r_squared
#> 1 33.649223 42.119930 0.72618
#> 2 -3.534237 -2.217343 0.72618
#> adjusted_r_squared f_statistic f_statistic_p_value degrees_of_freedom
#> 1 0.7170527 79.56103 6.112687e-10 30
#> 2 0.7170527 79.56103 6.112687e-10 30