Baseball attendance model, and the input that made it look too good

A group assignment. We built a regression for attendance at Atlanta Braves home games. One input contained the attendance value, and the fit is lower without it.

Role
Group member (coursework)
Period
2022
Stack
Python, pandas, statsmodels, OLS regression
Evidence
Published
Question
Which game and weather factors help to predict attendance at a home game?
Data
461 home games from 2011 to 2016, joined to daily weather data on the game date.
Method
We built new variables, such as a weekend flag and ticket ratios. We fitted OLS models on the seasons before 2015 and tested them on the 137 games of 2015 and 2016.
ResultPublished
The model that we chose had an R² of 0.991 on the training seasons and 0.985 on the test seasons. One input divided tickets sold by attendance. Without that input, the R² is about 0.95.

Coursework output from a group assignment. The model that the group submitted used an input that contains the attendance value. The fit without that input comes from a rerun in November 2026. This page makes no causal claim about attendance or revenue.

461Home games
137Test games (2015 and 2016)
0.991R², with the leaked input
0.95approx.R², without it

1 · Business context

A baseball team plans staff, stock and prices for each home game. A forecast of attendance helps with each of these decisions. The assignment asked for a regression that predicts attendance at Atlanta Braves home games.

2 · Data

  • Game table: 461 home games, 2011 to 2016, with tickets sold, resale tickets, payroll, rank, win percentage, weekday and start time.
  • Weather table: 2,126 daily records with the weather type and the mean temperature.
  • We joined the two tables on the game date. The result has 461 rows and 20 columns, with no missing values.

3 · New variables

  • Time: the month, and a weekend flag for Friday and Saturday games.
  • Team strength: the difference in win percentage and in rank between the two teams.
  • Money: the payroll ratio and the payroll difference.
  • Tickets: the resale ratio, and the log of tickets sold divided by attendance.
  • Weather: a rain flag and a hot-day flag.

4 · Model comparison

We fitted six OLS models on the 324 games before 2015. The values are the adjusted R² and the AIC on those games.

  • All variables (51 parameters): 0.952, AIC 5,909.
  • The model that we chose (4 variables): 0.991, AIC 5,326.
  • Tickets and start time, no weekday (18 parameters): 0.945, AIC 5,924.
  • Weather type only: below zero, AIC 6,848.
  • Temperature only: below zero, AIC 6,846.
  • Weather type and temperature: below zero, AIC 6,849.

5 · The model that we chose

The model has four inputs: tickets sold, the weekend flag and two log variables. All four are significant.

Each ticket sold adds about 1.16 to the predicted attendance. A Friday or Saturday game has about 300 more guests (coefficient 300.29, p = 0.02).

One variable has the wrong name in the notebook. It is called log_tickets_resale, but it holds the log of tickets sold.

6 · Test on the 2015 and 2016 seasons

On the 137 test games, the R² is 0.985. The root mean squared error is 1,062 guests and the mean absolute error is 636 guests.

These values include the leaked input of section 8, so they are too good. Read them together with that section.

7 · Weather had no effect

The three weather models explain less than 1% of the variation in attendance (R² 0.002, 0.001 and 0.002). No weather variable is significant: each p-value is above 0.4.

A forecast for this team does not need the weather. Ticket sales carry much more information.

8 · The input that contained the answer

One input was the log of tickets sold divided by attendance. Attendance is the value that the model predicts, so this input gives the model a part of the answer.

A rerun without that input gives an R² of about 0.95 on the training seasons and on the test seasons. That is the fit to quote for this model.

9 · What a team can use

  • Use tickets sold as the first signal for staff and stock plans. It explains most of the attendance.
  • Plan for more guests on Friday and Saturday games.
  • Do not change the forecast for the weather.
  • Track the resale ratio for each game as a sign of demand.

10 · Limits and next steps

  • Home games of one team, 2011 to 2016. The model does not apply to other teams or stadiums without a new fit.
  • No data on promotions or on star players of the opponent.
  • A linear model does not show interactions between variables.
  • Next steps: add promotion days, fit the model without the leaked input from the start, and compare with a tree model.

Model fit (R²) with and without the leaked input

Model fit (R²) with and without the leaked input
ItemValue
With the input, training0.991
With the input, test0.985
Without the input, training0.953
Without the input, test0.955
Join, split by season and fit (from the assignment notebook)
df = baseball.join(weather.set_index('date'), on='event_date', how='left')

df['is_weekend'] = df['weekday'].apply(lambda d: 1 if d in ['Friday', 'Saturday'] else 0)
df['ticket_ratio'] = df['tickets_sold'] / df['attendance']   # contains the target
df['log_ticket_ratio'] = np.log(df['ticket_ratio'])
df['log_tickets_resale'] = np.log(df['tickets_sold'])        # name is wrong: log of tickets sold

df_train = df.query('season < 2015')
df_test = df.query('season >= 2015')

model_2 = smf.ols(
    data=df_train,
    formula='attendance ~ log_tickets_resale + tickets_sold + is_weekend + log_ticket_ratio',
).fit()