Load the data from Table 1 in Section 4.1 into R.

Table1 <- read.csv("https://sullystats.github.io/Statistics6e/Data/Chapter4/Table1.csv")
head(Table1,n=4)
##   Speed Distance
## 1   100      257
## 2   102      264
## 3   103      274
## 4   101      266

Rather than reading the data from Github, we could manually enter the data into R.

Table1a=data.frame("Speed"=c(100, 102, 103, 101, 105, 100, 99, 105), "Distance"=c(257, 264, 274, 266, 277, 263, 258, 275))

Base R

golf_model <- lm(Distance ~ Speed,data=Table1)  # Name and find regression model. 
summary(golf_model)  # Use the *summary* command
## 
## Call:
## lm(formula = Distance ~ Speed, data = Table1)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.8136 -2.0195  0.3542  2.0619  3.6881 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -55.7966    48.3713  -1.154  0.29257    
## Speed         3.1661     0.4747   6.670  0.00055 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.883 on 6 degrees of freedom
## Multiple R-squared:  0.8811, Adjusted R-squared:  0.8613 
## F-statistic: 44.48 on 1 and 6 DF,  p-value: 0.0005498

There is quite a bit of information in the summary. The coefficient of determination, \(R^2\), is 0.881 (the second from last line of output following Multiple R-squared:).

Mosaic

library(mosaic)
golf_model <- lm(Distance ~ Speed,data=Table1)  # Name and find regression model.
rsquared(golf_model)  # Determine R-squared
## [1] 0.8811499

The coefficient of determination, \(R^2\), is 0.881.