2025-10-19

Introduction

This presentation explores Linear Regression using Formula 1 racing data from the 2024 season.

Research Question: Does starting grid position predict finishing position?

Linear Regression Model

\[Y = \beta_0 + \beta_1 X + \epsilon\] - \(Y\) = Finishing position

  • \(X\) = Starting grid position

  • \(\beta_0\) = Intercept

  • \(\beta_1\) = Slope

  • \(\epsilon\) = Error term

Load Data

# Load the F1 2024 season race results
f1 <- read_csv("Formula1_2024season_raceResults.csv")
head(f1)
## # A tibble: 6 × 11
##   Track  Position    No Driver Team  `Starting Grid`  Laps `Time/Retired` Points
##   <chr>  <chr>    <dbl> <chr>  <chr>           <dbl> <dbl> <chr>           <dbl>
## 1 Bahra… 1            1 Max V… Red …               1    57 1:31:44.742        26
## 2 Bahra… 2           11 Sergi… Red …               5    57 +22.457            18
## 3 Bahra… 3           55 Carlo… Ferr…               4    57 +25.110            15
## 4 Bahra… 4           16 Charl… Ferr…               2    57 +39.669            12
## 5 Bahra… 5           63 Georg… Merc…               3    57 +46.788            10
## 6 Bahra… 6            4 Lando… McLa…               7    57 +48.458             8
## # ℹ 2 more variables: `Set Fastest Lap` <chr>, `Fastest Lap Time` <time>

Prepare Data

f1_clean <- f1 %>%
  select(grid = `Starting Grid`, finish = Position, team = Team) %>%
  filter(!is.na(grid), !is.na(finish), 
         !is.infinite(grid), !is.infinite(finish),
         grid > 0, finish > 0) %>%
  mutate(grid = as.numeric(grid), finish = as.numeric(finish))

top_teams <- c("Red Bull Racing Honda RBPT", "Ferrari", "Mercedes", "McLaren Mercedes")
f1_clean <- f1_clean %>%
  filter(team %in% top_teams)

head(f1_clean)
## # A tibble: 6 × 3
##    grid finish team                      
##   <dbl>  <dbl> <chr>                     
## 1     1      1 Red Bull Racing Honda RBPT
## 2     5      2 Red Bull Racing Honda RBPT
## 3     4      3 Ferrari                   
## 4     2      4 Ferrari                   
## 5     3      5 Mercedes                  
## 6     7      6 McLaren Mercedes

Plot 1: Scatter Plot

Plot 2: Boxplot

3D Plot

Regression Results

model <- lm(finish ~ grid, data=f1_clean)
summary(model)
## 
## Call:
## lm(formula = finish ~ grid, data = f1_clean)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -8.3487 -1.8030 -0.5303  0.8742 16.3789 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   2.8575     0.3875   7.375 6.00e-12 ***
## grid          0.3818     0.0545   7.006 4.86e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.192 on 178 degrees of freedom
##   (12 observations deleted due to missingness)
## Multiple R-squared:  0.2162, Adjusted R-squared:  0.2118 
## F-statistic: 49.09 on 1 and 178 DF,  p-value: 4.857e-11

Hypothesis Test

Question: Does starting position actually matter for your final result? \[H_0: \beta_1 = 0 \text{ (starting position doesn't matter)}\] \[H_a: \beta_1 \neq 0 \text{ (starting position does matter)}\]

How I interpret: Since the p-value is 4.857e-11 which is 0.00000000004857

  • Since p-value < 0.05: Starting position matters!

Conclusion

What we found:

  • Starting position and finishing position are strongly related
  • If you qualify well, you’ll probably finish well too
  • The statistical test confirms this isn’t just random luck

Bottom line: Where you start really matters in F1 racing!