moderndive R Package

An R package of datasets and wrapper functions for tidyverse-friendly introductory linear regression used in

Demo

The following three get_regression_OUTPUT() functions are tidyverse-friendly wrapper functions meant for the novice regression user. They have more intuitive/verb-like function names than the corresponding broom package commands:

Furthermore

  • get_regression_table() returns confidence intervals (not just p-values) by default
  • The outputs are returned as tibbles
  • It cleans the output format by eliminating all information not pertinent to novice regression users
  • You can set the output to be in knitr::kable() markdown format, suitable for printing in R Markdown documents, via print = TRUE
## # A tibble: 2 x 7
##   term      estimate std_error statistic p_value lower_ci upper_ci
##   <chr>        <dbl>     <dbl>     <dbl>   <dbl>    <dbl>    <dbl>
## 1 intercept   30.1        1.63     18.4        0   26.8     33.4  
## 2 hp          -0.068      0.01     -6.74       0   -0.089   -0.048
get_regression_table(mpg_mlr_model, digits = 4, print = TRUE)
term estimate std_error statistic p_value lower_ci upper_ci
intercept 37.2273 1.5988 23.2847 0.0000 33.9574 40.4972
hp -0.0318 0.0090 -3.5187 0.0015 -0.0502 -0.0133
wt -3.8778 0.6327 -6.1287 0.0000 -5.1719 -2.5837
## # A tibble: 32 x 6
##       ID   mpg    hp cyl   mpg_hat residual
##    <int> <dbl> <dbl> <fct>   <dbl>    <dbl>
##  1     1  21     110 6        20.0    0.962
##  2     2  21     110 6        20.0    0.962
##  3     3  22.8    93 4        26.4   -3.62 
##  4     4  21.4   110 6        20.0    1.36 
##  5     5  18.7   175 8        15.9    2.78 
##  6     6  18.1   105 6        20.2   -2.06 
##  7     7  14.3   245 8        14.2    0.06 
##  8     8  24.4    62 4        27.2   -2.76 
##  9     9  22.8    95 4        26.4   -3.57 
## 10    10  19.2   123 6        19.7   -0.526
## # ... with 22 more rows
## # A tibble: 3 x 6
##      ID   mpg    hp cyl   mpg_hat residual
##   <int> <dbl> <dbl> <fct>   <dbl>    <dbl>
## 1     1  21     110 6        20.0    0.962
## 2     2  21     110 6        20.0    0.962
## 3     3  22.8    93 4        26.4   -3.62
## # A tibble: 1 x 8
##   r_squared adj_r_squared   mse  rmse sigma statistic p_value    df
##       <dbl>         <dbl> <dbl> <dbl> <dbl>     <dbl>   <dbl> <dbl>
## 1     0.602         0.589  14.0  3.74  3.86      45.5       0     2
r_squared adj_r_squared mse rmse sigma statistic p_value df
0.60244 0.58919 13.98982 3.740297 3.86296 45.4598 0 2

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.