Chapter 8 Modeling

8.1 Correlation

To compute the correlation between two variables, we use the ‘cor()’ function:

## Classes 'data.table' and 'data.frame':   30 obs. of  2 variables:
##  $ time : int  30 41 41 43 47 48 51 54 54 56 ...
##  $ score: int  100 84 94 90 88 99 85 84 94 100 ...
##  - attr(*, ".internal.selfref")=<externalptr>
## [1] -0.125

8.3 Linear Regression:

## 
## Call:
## lm(formula = score ~ time, data = df)
## 
## Coefficients:
## (Intercept)         time  
##     88.8751      -0.0996

8.4 Making predictions

## [1] "Score Prediction for time = 45 minutes"
##      1 
## 84.393
## [1] "Score Prediction for time = 70 minutes"
##      1 
## 81.904