Code Monkey home page Code Monkey logo

Comments (2)

rudeboybert avatar rudeboybert commented on July 29, 2024

Only at end of semester.

from moderndive_book.

rudeboybert avatar rudeboybert commented on July 29, 2024
library(moderndive)

# Evals data with correct factor levels
evals
#> # A tibble: 463 x 13
#>       ID score   age bty_avg gender ethnicity  language rank    pic_outfit
#>    <int> <dbl> <int>   <dbl> <fct>  <fct>      <fct>    <fct>   <fct>     
#>  1     1   4.7    36    5    female minority   english  tenure… not formal
#>  2     2   4.1    36    5    female minority   english  tenure… not formal
#>  3     3   3.9    36    5    female minority   english  tenure… not formal
#>  4     4   4.8    36    5    female minority   english  tenure… not formal
#>  5     5   4.6    59    3    male   not minor… english  tenured not formal
#>  6     6   4.3    59    3    male   not minor… english  tenured not formal
#>  7     7   2.8    59    3    male   not minor… english  tenured not formal
#>  8     8   4.1    51    3.33 male   not minor… english  tenured not formal
#>  9     9   3.4    51    3.33 male   not minor… english  tenured not formal
#> 10    10   4.5    40    3.17 female not minor… english  tenured not formal
#> # ... with 453 more rows, and 4 more variables: pic_color <fct>,
#> #   cls_did_eval <int>, cls_students <int>, cls_level <fct>

# Model of teaching score as a function of age
model_score <- lm(score ~ age, data = evals)

# Tidy regression table with confidence intervals & p-values stars removed:
get_regression_table(model_score)
#> # 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    4.46      0.127     35.2    0        4.21     4.71 
#> 2 age         -0.006     0.003     -2.31   0.021   -0.011   -0.001

# Outcome + explanatory/predictor variables, fitted/predicted values, and residuals:
get_regression_points(model_score)
#> # 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
#>  6     6   4.3    59      4.11    0.188
#>  7     7   2.8    59      4.11   -1.31 
#>  8     8   4.1    51      4.16   -0.059
#>  9     9   3.4    51      4.16   -0.759
#> 10    10   4.5    40      4.22    0.276
#> # ... with 453 more rows

# Scalar regression summaries with MSE & RMSE added:
get_regression_summaries(model_score)
#> # 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.011         0.009 0.292 0.540 0.541      5.34   0.021     2

Created on 2018-07-12 by the reprex package (v0.2.0.9000).

from moderndive_book.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.