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).

enter image description here

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):

enter image description here

This just doesn't seem right to me. Is this table in a good format for survival analysis?


1 Answer 1


After a quick read of your question, I recommend you consider whether period would actually be a psuedoreplicate of match. Are periods independent of each other?

Also, it is unclear what your actual response variable is. Time between events seems more like an explanitory variable for whether the event occurs. Are you interested in whether the performace of a team or player is better during the season or pre-season? If this is the case, consider using performance (number of goals, probability of scoring, Event?, etc.) as the response variable.

You might try to test whether the seasons are actually different using logistic regression or a generalized linear mixed model. Using a mixed model would all you to incorporate random effects, such as team or stadium, etc. Once you have your model, you could test whether the parameter 'season' actually has an effect on the performance of the players using a liklihood ratio test.

Then if you determine 'season' is an important parameter (explanatory variable in this case), you can compare the (log) odds ratios of an event occurring.

  • $\begingroup$ Yes, I'd assume periods are independent of each other. And, I think you didn't understand my question completely. I don't want to incorporate season in my current analysis. That's in the past. I want to use survival analysis, like my past analysis, to see if moving from period_1 to period_2 has an effect on the rate of an event, such as goals, shots, hits, etc $\endgroup$
    – JayBaik
    Jan 8, 2019 at 22:31
  • $\begingroup$ I think my suggestion would work for period. If I understand correctly, you are still just interested in whether period has an effect on a response. You may be ok to assume periods are independent even if they came from the same game if you have event data for each period. If you only have event data for the entire game, then your experimental unit is the game. $\endgroup$ Jan 9, 2019 at 23:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.