Featured post

Textbook: Writing for Statistics and Data Science

If you are looking for my textbook Writing for Statistics and Data Science here it is for free in the Open Educational Resource Commons. Wri...

Tuesday 21 June 2016

Thesis Defence Notes - Cricket Simulator

These are notes from the 'lost slides' on cricket that I didn't have time to cover in my PhD defense, which I completed two weeks ago.

The other half of the notes, on approximate Bayesian computation (ABC) for networks, is found here.


Cricket is a sport popular in the emerging economies of the Indian subcontinent. Most of my cricket work has focused on the Twenty20 format of Cricket, in which matches are designed to last only three hours, roughly the same time as matches in other popular team sports. This format has only been played professionally for about 10 years, and it growing quickly in terms of spectator and commercial interest. The intricacies of this format are also poorly understood, which provides many good research opportunities.

In the Twenty20 format, each team is allowed one innings to score runs. (Yes, 'innings', not 'inning') That inning is over if either...

1) 10 of the 11 players are dismissed (a dismissal is also called an 'out' or a 'wicket'), or
2) 120 'fair' balls are thrown. A group of 6 throws is called an 'over', making 20 overs per innings. Hence the name Twenty20.

A small number (typically fewer than 10) of throws per innings do not count against the limit of 120 because they were not thrown in a prescribed manner. A small number of throws also incur a one-run penalty that is added to the These cases are similar to 'balls' and 'hits-by-pitch' in baseball, respectively.

Each of these 120+ throws has a discrete result that we simplified into six categories: Wicket, 0 Runs, 1 Run, 2-3 Runs, 4-5 Runs (Ground Rule Double), and 6 Runs (Home Run).  Cases where 3 runs and 5 runs occurred were rare, so we treated them as a fixed proportion of 2-3 runs (~6.4%) and 4-5 (~1.5%) runs respectively. Likewise, throws not counting against the 120 limit, and those resulting in a penalty run, were treated as a fixed proportion of each of the six categories.

Here is table of a team's batting and bowling summaries of a recent T20I match from ESPN CricInfo.

All of these metrics, such as 'Strike Rate', are based solely on the number of events (e.g. balls faced,  times dismissed, runs scored), without respect to when they happened. The inherit weakness of all these metrics is that they treat each throw as an identical event, independent of the number of wickets and throws remaining. For the baseball crowd, consider the difference between overall batting average, and the batting average with runners in scoring position.

Reality is more complex. Consider this:

 This is a heat map of the empirical chance of any throw/ball/pitch ending as a six (a home run in baseball terms) as a function of overs and wickets taken. All games start in the upper-left corner, with 20 overs and 10 wickets remaining. From there, plausible game situations 'fan out', where games with situations following the top of the fan are those where relatively few batters are dismissed by the time most of the overs are used.

In these games, many sixes occur in the late game. Scoring a six involves hitting the ball with great power, which involves taking a greater risk of a dismissal. Since in these low-dismissal games, remaining throws are a more precious resource than remaining wickets, this high-risk, high-reward strategy is rational.

Here's the raw probability of scoring a four, which is similar to a ground rule double in baseball. This is a ball that touches the ground in bounds, but bounces or rolls out of bounds. As such, the fielders have an effect on the outcome that they cannot usually have on sixes. Notice that the general pattern of fours are similar to those of the sixes, except for the major drop at between the 6th and 7th overs. From the 7th over onwards, the players in the field are more restricted, and so more balls are able to roll out of bounds to score 4 runs

Likewise, the batting team gets really desperate in the last few overs, so they try reckless moves that frequently end in a wicket (a dismissal of a batting player). We also see wickets getting more likely when there are very few batters left. This seems counter to the intuitive strategy - that running out of batters would cause the remaining batters to be more cautious. Instead, you're seeing the effect of putting the worst batters on a team last in the batting order - they just get dismissed more often.

Here's the major confound: A batting player continues to bat until dismissed or until the innings ends. So a starting batter will rarely, if ever, see a situation where there are few wickets remaining. Likewise, a player batting late in the lineup will never enjoy the game situations with many wickets remaining. Therefore, a late-batting player has less opportunity to aim for those sweet, sweet, sixes.

We developed a system for estimating 'situational effects', which are the relative propensities towards a given outcome (i.e. wicket, 0, 1, 2-3, 4-5, 6) holding batter and bowler constant. These effects were estimated by first estimating odds ratios of events between 'adjacent' situations (those differing by one over or one wicket), within individual player records.

The data in these heatmaps are used to find these situational effects, which control for individual player effects.

Having these situational effects in place, we were able to estimate a great deal of additional parameters. First, we estimated the probability of any given player to produce a given outcome at some 'baseline' situation. To do this, we gave each ball faced, or ball thrown for bowlers, a weight. If a six happened in a situation when sixes were more likely (again, controlling for player difference), a small weight was given. If a six happened at a time when sixes were rare, a large weight was given. This way, we could compare batters and bowlers to each other, even we they played under very different situations.

To knit this all together into estimates of a players batting or bowling outcomes at a 'baseline' situation, we used a Metropolis-Hastings within Gibbs sampling method. More specifically, we draw a set of values from a Dirichlet distribution (an extension of the Beta distribution to multinomial cases), and propose those as a player's outcome probabilities at baseline. Then we compute the likelihood of these probabilities given the player's history and the estimated situational effects. Proposals that fit the data better have a higher likelihood, and these are given more weight in the final estimate. The final estimate for a player is an aggregate of thousands of these proposals.

I treated situational effects as normalized multiplicative effects on these baseline probabilities. in the following formula,

the situational effects are the tau owj's and pi70j is a player's ability at the baseline situation (7 overs, 1st wicket). The left-hand part, piowj, represents the probability of any player getting any outcome in any situation (o overs, w wickets). From here, making a simulation was just a matter of making a Markov Chain that followed the rules of the game.

This simulator has been the basis of five published or submitted papers, including the two in the first half of my thesis (bolded)

Davis, J., Perera, H., & Swartz, T. B. (2015). A simulator for Twenty20 cricket. Australian & New Zealand Journal of Statistics, 57(1), 55-71.
Davis, J., Perera, H., & Swartz, B. (2015). Player evaluation in Twenty20 cricket. Journal of Sports Analytics, (Preprint).

 Perera, H., Davis, J., & Swartz, T. B. (2016). Optimal lineups in Twenty20 cricket. Journal of Statistical Computation and Simulation, 1-13.

Perera, H., Davis, J., & Swartz, T. B. (2016). Assessing the impact of fielding in
twenty20 cricket. In submission.

Silva, R., Davis, J., & Swartz, T. B. (2016). Mismatches in Twenty20 cricket. In submission.

No comments:

Post a Comment