Exercises: Home Field Advantage
Exercise 1: Basic HFA Calculation
A season had 272 games with these results: - Home wins: 148 - Away wins: 120 - Ties: 4
Calculate: - Home win percentage - Away win percentage - Implied HFA in points (use 0.5% ≈ 0.35 points approximation)
Exercise 2: Point Margin HFA
Season point data: - Total home points: 6,120 - Total away points: 5,850 - Games: 272
Calculate: - Average home points per game - Average away points per game - HFA in points
Exercise 3: Era Comparison
Compare HFA across eras:
| Era | Home Wins | Total Games |
|---|---|---|
| 2005-2009 | 710 | 1,280 |
| 2015-2019 | 695 | 1,280 |
| 2020-2023 | 540 | 1,080 |
Calculate home win percentages and identify the trend.
Exercise 4: COVID Analysis
2020 season with limited fans: - Home wins: 128 - Away wins: 126 - Total games: 256
Compare to 2019 (pre-COVID): - Home wins: 148 - Away wins: 108
What does this suggest about the role of fans?
Exercise 5: Travel Distance Effect
Away team performance by travel distance:
| Distance | Games | Away Wins |
|---|---|---|
| 0-500 mi | 120 | 55 |
| 500-1500 mi | 180 | 78 |
| 1500+ mi | 80 | 30 |
Calculate away win percentage for each category. Is there a pattern?
Exercise 6: Timezone Analysis
Games by timezone direction:
| Direction | Games | Away Wins |
|---|---|---|
| West→East | 85 | 36 |
| East→West | 85 | 42 |
| Same TZ | 102 | 49 |
Which direction of travel is most difficult for away teams?
Exercise 7: Team-Specific HFA
Team A's results: - Home: 7-2 (avg margin +8.5) - Away: 4-5 (avg margin -2.1)
Team B's results: - Home: 6-3 (avg margin +4.2) - Away: 5-4 (avg margin +1.5)
Calculate HFA for each team. Which has stronger home field advantage?
Exercise 8: Penalty Differential
Season penalty data: - Home team false starts: 285 - Away team false starts: 345 - Home team delays: 120 - Away team delays: 155
Calculate the ratio differences. What does this suggest about crowd noise effect?
Exercise 9: Altitude Effect
Denver's home results vs away: - Home: 8-1, avg margin +12.5 - Away: 5-4, avg margin +1.8
League average HFA: +2.5 points Calculate Denver's HFA. How much might be attributed to altitude?
Exercise 10: Spread Prediction
Build a spread prediction for KC hosting BUF: - KC power rating: +4.5 - BUF power rating: +3.0 - KC home field advantage: 3.0
What's the predicted spread?
Exercise 11: Playoff Value
If home field is worth 2.5 points per game, calculate the total value of the #1 seed if they: - Play 3 home playoff games - Win probability = 50% + (spread × 3%)
How much does home field increase championship probability?
Exercise 12: Weekly HFA Variation
HFA by game type:
| Game Type | Home Win % |
|---|---|
| Early Sunday | 54% |
| Late Sunday | 56% |
| Sunday Night | 52% |
| Monday Night | 58% |
| Thursday | 55% |
Is there significant variation? Which games favor home teams most?
Exercise 13: Dome vs Outdoor
Compare HFA: - Dome stadiums: 58% home win rate - Outdoor stadiums: 53% home win rate
Calculate the difference in implied points. Why might domes have higher HFA?
Exercise 14: Weather Impact
Cold weather games (< 40°F): - Home wins: 65 - Away wins: 45
Moderate weather (40-70°F): - Home wins: 85 - Away wins: 75
Calculate HFA for each. Does cold weather amplify home advantage?
Exercise 15: Model Calibration
Your model predicts without HFA that Team A beats Team B 52% of the time on neutral field. The game is at Team A's home.
If HFA = 2.5 points and each point ≈ 3% win probability: - What's the adjusted win probability for Team A?
Programming Exercises
Exercise 16: HFA Calculator
Write a function to calculate comprehensive HFA:
def calculate_hfa_metrics(schedules: pd.DataFrame, season: int = None) -> dict:
"""
Calculate HFA metrics.
Returns:
- home_win_pct
- home_margin
- implied_points
- penalty_differential (if PBP available)
"""
pass
Exercise 17: Team HFA Ranker
Build a team-specific HFA calculator:
def rank_team_hfa(schedules: pd.DataFrame, min_games: int = 16) -> pd.DataFrame:
"""
Rank teams by home field advantage.
Returns DataFrame with:
- team
- home_record
- away_record
- hfa_win_diff
- hfa_margin_diff
"""
pass
Exercise 18: Travel Effect Analyzer
Create a travel distance analysis function:
def analyze_travel_effect(schedules: pd.DataFrame, team_locations: dict) -> pd.DataFrame:
"""
Analyze away team performance by travel distance.
Returns:
- distance_bucket
- games
- away_win_pct
- avg_away_margin
"""
pass
Exercise 19: HFA Trend Visualizer
Build a visualization of HFA over time:
def plot_hfa_trend(schedules: pd.DataFrame, start_year: int, end_year: int) -> None:
"""
Plot HFA trends over multiple seasons.
Include:
- Home win percentage by season
- Home point margin by season
- Trend line
- COVID year marker
"""
pass
Exercise 20: Prediction Model with HFA
Build a complete prediction model:
def predict_game(
home_team: str,
away_team: str,
team_ratings: dict,
team_hfa: dict = None,
default_hfa: float = 2.5
) -> dict:
"""
Predict game outcome including HFA.
Returns:
- predicted_spread
- home_win_prob
- confidence
"""
pass
Challenge Exercises
Challenge 1: HFA Decomposition
Decompose HFA into its components: 1. Calculate overall HFA 2. Estimate crowd effect (compare to COVID) 3. Estimate travel effect (by distance) 4. Estimate timezone effect 5. Calculate residual (unexplained HFA)
Challenge 2: Dynamic HFA Model
Build a model where HFA varies by: 1. Time of season (early vs late) 2. Weather conditions 3. Playoff vs regular season 4. Prime time vs day games 5. Division vs non-division opponent
Challenge 3: HFA Prediction Value
Test whether incorporating HFA improves predictions: 1. Build baseline model (no HFA) 2. Add fixed HFA (2.5 points) 3. Add team-specific HFA 4. Compare accuracy (ATS, straight up) 5. Determine optimal HFA values
Challenge 4: Venue-Specific Analysis
For a specific stadium (e.g., Seattle): 1. Calculate historical HFA 2. Analyze false start rates 3. Track overtime noise levels 4. Compare to league average 5. Estimate value in points
Challenge 5: Future HFA Projection
Project HFA for next season: 1. Analyze recent 5-year trend 2. Account for any stadium changes 3. Consider roster factors 4. Build confidence interval 5. Compare to betting market HFA
Solutions
Solutions are available in code/exercise-solutions.py