Dataset:
Built-in mtcars dataset.
Variables:
Dependent variable is Miles Per Gallon (mpg).
Independent variable is Car Weight (wt).
2026-06-06
Dataset:
Built-in mtcars dataset.
Variables:
Dependent variable is Miles Per Gallon (mpg).
Independent variable is Car Weight (wt).
The model for simple linear regression:
\[y_i = \beta_0 + \beta_1 x_i + \epsilon_i\]
Where \(y_i\) is mpg and \(x_i\) is weight(‘wt’).
Difference between the observed values and the predicted values:
\[e_i = y_i - \hat{y}_i\]
R code used to create the scatter plot shown on slide 6:
ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point(color="blue", size=3) + geom_smooth(method="lm", formula=y~x, color="red") + theme_minimal()
Shows the relationship between car weight and miles per gallon.
Displays the residual error values for each specific car model.
Visualizes the relationship between weight and MPG.