In my article on hockey analytics, I answer how different are the rates of goals, shots, or hits from the NHL regular season to the playoffs (Playoffs are games played by the top 16 teams in the league after the conclusion of the regular season. Playoff games are much more competitive and intense because teams are closer to winning the championship once they reach the playoffs).
As stated in the piece, I used survival analysis:
the response variable is the time that has elapsed between events. Importantly, survival analysis deals with censoring-we might have incomplete information where the event of interest doesn’t occur in the duration of the game. I consider the treatment variable to be whether the game is played during the regular season or the playoffs.
The article contains scatterplots of hazard ratios by event types (Goals, Shots, Hits, Blocked Shots, etc).
After posting this online, I received a question that basically said if I could make period
the treatment variable (games are 60 minutes long and each period is 20 minutes each. Hence, there are three periods in a game). So, I'd like to get hazard ratios by event types where treatment variable is period_1
vs period_2
, period_2
vs period_3
.
I need help formatting the data for survival analysis so that I can just run
survival::coxph(formula = survival::Surv(time_diff, event_type) ~ period, data = df)
For my previous analysis, I managed to wrangle my data where Session
is the treatment variable (R
for regular season and P
for playoffs), Event Type
is 1 when event happens and 0 when it doesn't occur, and Time Difference
time elapsed between events (the last row equals the time to end of the game after the most recent event occured).
I ran the same code that wrangled my data in my article to format the same dataset (set the treatment variable as period_1
vs period_2
and look at rate of goals):
This just doesn't seem right to me. Is this table in a good format for survival analysis?