Formula 1 Performance Analytics

Colorful slides • Regression • Visual diagnostics • Interactive Plotly

Why Formula 1 is perfect for statistics 🏎️

Speed Tire wear Uncertainty

In F1, teams use data to:
  • predict lap time changes across a stint
  • estimate the cost of tire degradation
  • support strategy decisions (push vs manage)

Today: a small regression model + clean visuals + interactive Plotly.

The question

Question: How do average speed and tire wear relate to lap time?

We’ll build a reproducible dataset with:
  • Speed (km/h)
  • Tire wear (%)
  • Lap time (seconds)

Data (reproducible simulation)

n = 180 laps speed ≈ 220 km/h wear: 0–100%

Regression model (LaTeX)

We model lap time using multiple linear regression:

\[ Y = \beta_0 + \beta_1 X_1 + \beta_2 X_2 + \varepsilon \]

Where:
  • \(Y\) = lap time (sec)
  • \(X_1\) = speed (km/h)
  • \(X_2\) = tire wear (%)

Goal: estimate how much lap time changes when speed or wear changes.

Assumptions & uncertainty (LaTeX)

For inference (CIs / p-values), common assumptions are:

\[ E(\varepsilon)=0,\qquad Var(\varepsilon)=\sigma^2 \]

Sometimes also:

\[ \varepsilon \sim \mathcal{N}(0,\sigma^2) \]

Practical check: residual plots should look like random scatter.

Required: an R code slide

model <- lm(lap_time ~ speed + tire_wear, data = f1)
summary(model)
## 
## Call:
## lm(formula = lap_time ~ speed + tire_wear, data = f1)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.9528 -1.0828 -0.0938  1.0606  4.6001 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 122.092041   3.126371   39.05   <2e-16 ***
## speed        -0.167935   0.014259  -11.78   <2e-16 ***
## tire_wear     0.065538   0.004327   15.15   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.691 on 177 degrees of freedom
## Multiple R-squared:  0.6589, Adjusted R-squared:  0.655 
## F-statistic: 170.9 on 2 and 177 DF,  p-value: < 2.2e-16

Expected signs: speed coefficient negative; wear coefficient positive.

ggplot #1 — Lap time vs speed

ggplot #2 — Residuals vs fitted

Plotly (interactive) — Strategy view (GUARANTEED)

Hover to see detailed values. Zoom/pan with the mouse.

What the results mean

  • Speed coefficient < 0 → higher speed tends to reduce lap time.
  • Wear coefficient > 0 → tire wear increases lap time.
  • Diagnostics help check whether regression assumptions look reasonable.

Takeaways

Clear Visual Interactive

  • Regression converts racing intuition into numbers.
  • ggplot provides clean story-telling visuals.
  • Plotly adds interactivity (hover/zoom) for exploration.