"?But we deserved to win..."?
Image credit: Sky Sports

"But we deserved to win..."

It's the 93rd minute, 0-0 away from home despite enjoying the lion's share of possession, tackles and touches in the final third. Your 76th-minute substitute loses the ball in midfield, the opposing winger breaks away and rattles the ball into the top corner. You lie down in distress at the final whistle, ignoring your half-drunk beverage and What's App messages. Sound familiar?

With my recent downtime between contracts, exploring R in a topical manner has punctuated Thomas Tuchel's Chelsea, 3-4-2-1 and Roy Keane's Sky Sports punditry. I will show you how to build a post-game analysis worthy enough to silence any pundit, except Roy. It only takes five minutes, two functions, someone French (not Giroud!), RStudio IDE and base-level knowledge.

"In statistics, a Poisson distribution is a probability distribution that can be used to show how many times an event is likely to occur within a specified period of time?. In other words, it is a count distribution. Named after Siméon Denis Poisson."

The key to a "quick win today" is the assumption of random occurrence, independence and probability of an event occurring in a given interval do not vary with time (debatable with fatigue, but can work for the purpose of the post). David Sumpter, Professor and author of Soccermatics considers it to be random and that's good enough for today.

What is xG in football & how is the statistic calculated? It's even used by data and tech guru, Nate Silver! xG for a match is available on various websites, but I find FiveThirtyEight a good source with a couple of options:

  • Adjusted goals take into account that not all goals are created equal: A team’s final score is reduced if a goal comes late in a game that it’s leading or when an opponent is a man down. (Meanwhile, goals that are scored in regular situations are adjusted upward to balance out the total number of goals across a league.)
  • Shot-based expected goals (xG) is an estimate of how many goals a team could have scored given the location of its shots and the players who took them.
  • Non-shot expected goals is an estimate of how many goals a team could have scored given their nonshooting actions in and around their opponent’s penalty area."

I'm happy for you to pick whatever:

  1. Load your packages: All fairly standard - load as below.
No alt text provided for this image

2. Building the Grid function:

No alt text provided for this image

3. Building the Map function:

No alt text provided for this image

4. Run the script and input your teams, goals and source to the console via the Map function:

No alt text provided for this image

When inputting shot-based and non-shot xG from Sunday's Manchester derby, we can analyse that despite losing 2-0, Pep Guardiola had some grounds to feel the result flattered United.

No alt text provided for this image

When inputting non-shot xG from Sunday's Manchester derby:

No alt text provided for this image

Maybe Big Sam was right after all?


Currently available for contract roles using R and Python in the data analytics and science space across the UK. If you're interested in learning what this can bring to your business or client, contact me on [email protected] for more information.

Joe Headland

Head of UK Operations at Spokesafe

3 年
回复

要查看或添加评论,请登录

Colin Berry的更多文章

  • Bottling It, Or Bad Math?

    Bottling It, Or Bad Math?

    The shift of the 2024 World Series to Yankee Stadium for Game 3 did nothing to impede the momentum of the Los Angeles…

    3 条评论
  • Machiavelli's Blade

    Machiavelli's Blade

    Let’s explore a fresh analysis of the Tory leadership contest, with a focus on Stages 2, 3, and 4, using mathematical…

  • Professor Lugo

    Professor Lugo

    In his first start as a Kansas City Royal, Seth Lugo delivered six scoreless innings. In his second outing, he pitched…

  • The Garrett Crochet Effect

    The Garrett Crochet Effect

    The "Garett Crochet Effect" is unmistakably influencing the upcoming clash between the White Sox and the Dodgers on…

  • London Calling to the Faraway Towns

    London Calling to the Faraway Towns

    The historic rivalry between the New York Mets and the Philadelphia Phillies has been filled with memorable moments and…

  • Things Can Only Get Slugger!

    Things Can Only Get Slugger!

    Juan Soto showcased his power at the plate, belting two home runs, including a crucial go-ahead shot in the ninth…

  • Yu Darvish: Unveiling the Pitching Maestro of the San Diego Padres

    Yu Darvish: Unveiling the Pitching Maestro of the San Diego Padres

    Yu Darvish, who hadn't allowed a run in 25 consecutive innings and had only surrendered two home runs all season—none…

  • Was Shohei Ohtani's $700 Million Deal Worth It for the LA Dodgers?

    Was Shohei Ohtani's $700 Million Deal Worth It for the LA Dodgers?

    The signing of Shohei Ohtani by the Los Angeles Dodgers for a historic $700 million contract has sparked immense…

    4 条评论
  • Game Theory and 'The Worst Team in Major League Baseball'

    Game Theory and 'The Worst Team in Major League Baseball'

    During a recent trip to Chicago, I had the opportunity to attend my first baseball game. As someone intrigued by the…

    3 条评论
  • Thomas Tuchel's High Flying Blues? Using R To Predict Chelsea in the UCL.

    Thomas Tuchel's High Flying Blues? Using R To Predict Chelsea in the UCL.

    Okay, okay, Tuchel's Chelsea might not be the most entertaining, but they're certainly effective. 13 games undefeated…

    1 条评论

社区洞察

其他会员也浏览了