Linear regression helps us model the relationship between shots and goals.
The regression equation is:
\[
\hat{y} = \beta_0 + \beta_1 x
\]
Where:
- \(\hat{y}\) = predicted goals
- \(x\) = number of shots
- \(\beta_0\) = intercept
- \(\beta_1\) = slope
A positive slope suggests that matches with more shots tend to have more goals.
cor(football$shots, football$goals)
## [1] 0.6330299
model <- lm(goals ~ shots, data = football)
summary(model)
##
## Call:
## lm(formula = goals ~ shots, data = football)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.50279 -0.64178 -0.05877 0.34020 2.49721
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.4213 0.5492 -0.767 0.449416
## shots 0.1480 0.0342 4.327 0.000174 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.95 on 28 degrees of freedom
## Multiple R-squared: 0.4007, Adjusted R-squared: 0.3793
## F-statistic: 18.72 on 1 and 28 DF, p-value: 0.0001739