Learning Check 6.2

Skim summary statistics
 n obs: 463 
 n variables: 4 

-- Variable type:factor ----------------------------------------------------
 variable missing complete   n n_unique                top_counts ordered
   gender       0      463 463        2 mal: 268, fem: 195, NA: 0   FALSE

-- Variable type:integer ---------------------------------------------------
 variable missing complete   n   mean    sd p0   p25 p50   p75 p100
      age       0      463 463  48.37   9.8 29  42    48  57     73
       ID       0      463 463 232    133.8  1 116.5 232 347.5  463
     hist
 <U+2585><U+2585><U+2585><U+2587><U+2585><U+2587><U+2582><U+2581>
 <U+2587><U+2587><U+2587><U+2587><U+2587><U+2587><U+2587><U+2587>

-- Variable type:numeric ---------------------------------------------------
 variable missing complete   n mean   sd  p0 p25 p50 p75 p100     hist
    score       0      463 463 4.17 0.54 2.3 3.8 4.3 4.6    5 <U+2581><U+2581><U+2582><U+2583><U+2585><U+2587><U+2587><U+2586>

Credit card debt is more correlated to credit rating than age.

Learning Check 6.3

# A tibble: 3 x 7
  term          estimate std_error statistic p_value lower_ci upper_ci
  <chr>            <dbl>     <dbl>     <dbl>   <dbl>    <dbl>    <dbl>
1 intercept      -270.      44.8       -6.02       0  -358.    -181.  
2 credit_rating     2.59     0.074     34.8        0     2.45     2.74
3 age              -2.35     0.668     -3.52       0    -3.66    -1.04

The do not match up well because age and credit rating are not closely related.

Linear Regression Exercises

1.

a.
# 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    39.9       0.717      55.7       0   38.5     41.3  
2 horsepower   -0.158     0.006     -24.5       0   -0.171   -0.145
i.

Yes, horsepower and mpg are correlated.

ii.

Strong, considering the intercept is so low at 39.936.

iii.

Negative

iv.
# 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             23.5      0.396    59.3     0         22.7    24.2 
2 "horsepower == \"~    -3.21     5.54     -0.580   0.562    -14.1     7.68
b.

2.

a.

b.
                mpg cylinders displacement horsepower weight acceleration
mpg           1.000    -0.778       -0.805     -0.778 -0.832        0.423
cylinders    -0.778     1.000        0.951      0.843  0.898       -0.505
displacement -0.805     0.951        1.000      0.897  0.933       -0.544
horsepower   -0.778     0.843        0.897      1.000  0.865       -0.689
weight       -0.832     0.898        0.933      0.865  1.000       -0.417
acceleration  0.423    -0.505       -0.544     -0.689 -0.417        1.000
c.
# A tibble: 6 x 7
  term         estimate std_error statistic p_value lower_ci upper_ci
  <chr>           <dbl>     <dbl>     <dbl>   <dbl>    <dbl>    <dbl>
1 intercept      46.3       2.67     17.3     0       41.0     51.5  
2 cylinders      -0.398     0.411    -0.969   0.333   -1.20     0.409
3 displacement    0         0.009    -0.009   0.993   -0.018    0.018
4 horsepower     -0.045     0.017    -2.72    0.007   -0.078   -0.012
5 weight         -0.005     0.001    -6.35    0       -0.007   -0.004
6 acceleration   -0.029     0.126    -0.231   0.817   -0.276    0.218

Yes, the results are consistent.

3.

a.
# A tibble: 3 x 7
  term       estimate std_error statistic p_value lower_ci upper_ci
  <chr>         <dbl>     <dbl>     <dbl>   <dbl>    <dbl>    <dbl>
1 intercept    33.3       1.06      31.4        0   31.2      35.4 
2 horsepower   -0.133     0.007    -19.9        0   -0.146    -0.12
3 origin        2.58      0.321      8.04       0    1.95      3.21
b.

c.

4.

a.
# A tibble: 4 x 7
  term              estimate std_error statistic p_value lower_ci upper_ci
  <chr>                <dbl>     <dbl>     <dbl>   <dbl>    <dbl>    <dbl>
1 intercept           26.8       1.70      15.8        0   23.5     30.1  
2 horsepower          -0.059     0.017     -3.57       0   -0.092   -0.027
3 origin               7.87      1.14       6.91       0    5.63    10.1  
4 horsepower:origin   -0.063     0.013     -4.83       0   -0.089   -0.038
b.

c.