luxuryvast.blogg.se

Baseball with r
Baseball with r






baseball with r baseball with r

Next, we’ll use the splancs package-and specifically the areapl function-to measure the area inside the contours. Once you’ve downloaded it on your machine, go ahead and load it into R, then load the libraries as shown below:Ĭl 50% Strike Calls", col="black", cex=1.2) This data is an abridged version of all called pitches for Joe West from 2008 through 2013 from my personal Pitch f/x database (leaving out pitch-outs and intentional balls). For now, go and get the data set from my website. In going through this exercise, we’ll need to use four new packages to our library: mgcv, parallel, PBSmapping, and splancs.

#Baseball with r code

This uses some modified code from this working paper, with the same types of GAM models, and we’ll reproduce a figure similar to Figure 13 (on page 57). We’ll think about this from a few perspectives: 1) What is the area of the zone for a given strike probability contour, 2) How much of that contour area resides within the rulebook strike zone (a specificity-like measure), and 3) How much of the rulebook strike zone is filled with our strike zone contour (a sensitivity-like measure).

baseball with r

Today, I’m going to take things a step further, and talk about measuring the area of contours that we create from a Generalized Additive Model (GAM) of the strike zone. Aaron has helped out with defining the way we think about the zone, and Carson has provided great tools in R through pitchRx that allow us to do this work smoothly. We’ve talked a good bit about Pitch f/x data on this site, and particularly with strike zones.








Baseball with r