SIMPLY COUNTING OVER 44 YEARS OF DATA
We have a father-in-law who likes baseball. Occasionally, he asks us to figure out things, which we are more than happy to do. The last request was to figure out:
If a team scores X runs, what’s the probability it will win the game?
Luckily, we had the data to solve this problem (as mentioned in past posts). Looking back over 44 years of baseball games, we looked at how often a home team scored 1 run, and counted how often the home team won. We then looked at 2, 3, 4 runs, up to 11 runs. We stop at 11 runs because we only wanted to compute relative frequencies when there’s a decent amount of data. In all our analyses here, we cut the x-axis when there are fewer than 500 observations per bin. We analyzed the visiting team’s scores separately, to see the effect of the home team advantage.
The result is shown above. If you consistently score 3-4 runs a game, you’re winning about half the games. It’s simply not good enough. Going from 2 runs a game to 6 runs a game means going from winning 25% of the time to winning 75% of the time–all the difference in the world.
Because we had the data handy, we couldn’t help but looking at the same thing for the other key statistics: hits, walks, and errors. Results below.
### Read in Data ###
#Data obtained from http://www.retrosheet.org/
#Go for the files http://www.retrosheet.org/gamelogs/gl1970_79.zip through
#http://www.retrosheet.org/gamelogs/gl2010_13.zip and unzip each to directories
#named "gl1970_79", "gl1980_89", etc, reachable from your working directory.
#Column headers, Can get from http://www.dangoldstein.com/flash/Rtutorial2/cnames.txt
#If you want all the headers, create from www.dangoldstein.com/flash/Rtutorial2/glfields.txt
#Loop to get together all data
for (baseyear in seq(1970,2000,by=10))
#string manupulate pathnames
#reading in datafiles to one big dat goes here
for (i in baseyear:endyear)
#Force feed in the last few years
for(mypath in c("gl2010_13/GL2010.TXT",
)] #relevant set
#dplyr awesomeness. so fast, so good.
srel_smart =rel %>%
filter(VisitorLeague=="NL" & HomeLeague=="NL") %>%
mutate(HW = HomeScore>VisitorScore,
VW = VisitorScore>HomeScore)
#Now with Runs
srel_runs = srel_smart %>%
#ggplot. so pretty. so good.
The post Baseball: Probability of winning conditional on runs, hits, walks and errors appeared first on Decision Science News.