Welcome! We’ll explore Simple Linear Regression (SLR) using the built-in mtcars data to study how car weight (wt) predicts fuel efficiency (mpg).
2025-11-08
Welcome! We’ll explore Simple Linear Regression (SLR) using the built-in mtcars data to study how car weight (wt) predicts fuel efficiency (mpg).
SLR model is a linear relationship between two variables: \[ y = \beta_0 + \beta_1 + \epsilon \] Where \(y\)=outcome (MPG), \(x\)=predictor (Weight), \(\beta_0\)=intercept, \(\beta_1\)=slope, and \(epsilon\)=random error.
The estimated regression equation from our model is:
\[ \hat{y}= \hat{\beta}_0 + \hat{\beta}_1 x \]
Plugging in our computed values: \[ \hat{y} = 37.285 - 5.344x \] This means: for every 1,000 lb increase in car weight, the MPG decreases by about 5.34.
Below is the R code used to create our regression model and show its summary:
model <- lm(mpg ~ wt, data = mtcars) s <- summary(model) results <- c( Intercept = round(s$coefficients[1, 1], 3), Slope = round(s$coefficients[2, 1], 3), R_squared= round(s$r.squared, 3), Adj_R2 = round(s$adj.r.squared, 3), p_value = signif(s$coefficients[2, 4], 3) ) results
## Intercept Slope R_squared Adj_R2 p_value ## 3.7285e+01 -5.3440e+00 7.5300e-01 7.4500e-01 1.2900e-10
-Simple Linear Regression helps quantify the relationship between two continuous variables. -In this example, we saw a negative correlation between car weight and fuel efficiency (MPG). -The fitted model equation was: \[ \hat{y} = 37.285 - 5.344x \] -This tells us that heavier cars tend to have lower MPG - specifically, each 1,000 lb increase in weight lowers MPG by about 5.34. -Our model explained about 75% of the variation in MPG, which is quite strong for a single predictor.
Thank you for viewing my presentation!