Modeling with Data in the Tidyverse
Albert Y. Kim
Assistant Professor of Statistical and Data Sciences
library(ggplot2)
library(dplyr)
library(moderndive)
# Fit regression model using formula of form: y ~ x
model_score_1 <- lm(score ~ age, data = evals)
# Output regression table using wrapper function
get_regression_table(model_score_1)
# A tibble: 2 x 7
term estimate std_error statistic p_value lower_ci...
<chr> <dbl> <dbl> <dbl> <dbl> <dbl>...
1 intercept 4.46 0.127 35.2 0 4.21...
2 age -0.006 0.003 -2.31 0.021 -0.011...
# Fit regression model using formula of form: y ~ x model_score_1 <- lm(score ~ age, data = evals)
# Get information on each point get_regression_points(model_score_1)
# A tibble: 463 x 5
ID score age score_hat residual
<int> <dbl> <dbl> <dbl> <dbl>
1 1 4.7 36 4.25 0.452
2 2 4.1 36 4.25 -0.148
3 3 3.9 36 4.25 -0.348
4 4 4.8 36 4.25 0.552
5 5 4.6 59 4.11 0.488
Modeling with Data in the Tidyverse