Archive for Baseball

TechGraphs Report: On Deck Sports and Technology Conference

Earlier this week, NYC’s Bohemian National Hall played host to hundreds of sports executives, entrepreneurs, and others looking to learn about the very latest in sports technology. Since 2013, the On Deck Sports and Technology Conference (organized and presented by SeatGeek) has provided a forum to showcase what products are “on deck” to help fans follow, analyze, and participate in sports.

On Deck has a slight bent towards sports startups, so a decent amount of the conference was geared more towards raising capital, scaling businesses, etc. Still, there were plenty of fascinating talks, panels and interviews for anyone interested in straight sports tech.

Statcast And Beyond

Possibly the most entertaining talk of the day was Joe Inzerillo’s (CTO, MLBAM) update on MLB’s Statcast, which is finally getting its moment in the sun this season. For those who needed a refresher on how Statcast operates, Inzerillo discussed its missile-technology radar system, its stereoscopically-placed cameras, and how these allow each Major League ballpark to track the movements of every player on the field (plus the ball) at any given time.

Once Statcast has this information, as Inzerillo pointed out, it can then provide real-time data on pitch velocity (actual and perceived), player velocity and reaction time, and a horde of other quantitative metrics, plus more advanced data on a 12-second delay, like fielding route efficiency. This data is just inherently cool (as you likely know if you’ve seen a Statcast-enhanced game or highlight on television), but it’s also already being used to both question and confirm existing baseball strategies.

For an example of the latter, Inzerillo looked at the fallacy of sliding into first using Statcast to plot Eric Hosmer’s 1B slide in Game 7 of the last World Series. Hosmer hit a peak speed of 20.9 MPH before sliding and being out by less than a tenth of a second. If he had just kept running, Statcast found, he would have been safe by nearly a foot. Statcast is already getting noticed by clubs, and even players — batters like to talk smack, apparently, over who has the highest exit velocity.

During questions, Inzerillo was slightly cautious about committing to the future of Statcast, but he did mention that minor league stadiums were a natural next step, and that there was plenty of work being done on developing new metrics. Statcast already tracks ‘defensive range’ for fielders, for example, but since a player doesn’t travel the same speed in every direction, there’s a need to find the more amorphous ‘effective defensive range’ and how it changes–such as during defensive shifts.

On the football side of things, Sportradar’s Tom Masterman talked about the NFL’s NGS (Next Gen Stats) platform, which is collecting data on every single game in 2015 to track, analyze, and visualize how players are moving on the field. NGS is already being distributed to clubs, media, and health and safety personnel; the long-term goal is to have X,Y,Z coordinates for every player and official, plus the ball.

Go Bucks

On Deck’s attendees weren’t just league officials and startup managers–the conference started with a live interview of Wes Edens, who became co-owner of the NBA’s Milwaukee Bucks in 2014. Much of the conversation focused on the new Bucks arena, which was being voted on by the Milwaukee city council literally as the interview was ongoing. As it’s currently planned, the presently-unnamed arena will focus heavily on keeping fans digitally connected — giving attendees plenty of WiFi, for example. At the same time, Edens noted, they want to avoid fans using technology to become distracted from the game going on in front of them. (Edens used the phrase “Instagram culture”, specifically, though he noted that he himself has had these sorts of problems before.)

Edens was similarly balanced when the discussion turned to analytics. One of the first things Edens did after buying the Bucks was to build their analytics program — bringing on employees, consultants and even discussing methodologies with other owners. There’s definitely a “golden age” of analytics in basketball going on.  Edens even thinks the NBA will end up surpassing the MLB as the leader in sports technology. But when he was asked about how the players feel?

“It’s a good question,” Edens replied. “There’s definitely lines that can be crossed” with having too much data being made public, at least when it can affect the privacy of the players (such as rest/injury issues).

Edens also briefly discussed the role of the referees and the potential benefits of replay and “the new center across the river“. Could we see yet more referee technology, even an Oculus Rift-type headset for NBA officials, in the future? “Totally possible.”

Era of Mobility

When it came time to look at how fans themselves were interacting with sports, technologically, it became clear that mobile is “it.” In that panel about growing sports startups I mentioned earlier, representatives from SeatGeek, FanDuel and Krossover all praised the importance of the mobile web for their companies–SeatGeek’s rep described it as a “tale of two companies”, pre- and post-mobile, and Krossover’s founder mentioned they’re considering dumping their web app altogether in lieu of just being on smartphones and tablets. When Yahoo Sports’ VP of engineering presented a chart showing their fantasy football traffic from this season’s Week 1, the fraction of non-mobile data was a pretty small sliver at the top.

Yahoo fantasy data graph
Trust me, it’s there.

Even companies you might never expect to get in the mobile game are joining and succeeding. Jeremy Strauser had 20 years of gaming experience at EA Sports and Zynga before joining one of the most loved and enduring brands in the sports industry, Topps. Yep, they’re digital playing cards.

Topps first got into the digital game 4 years ago and how has three top-selling sports card apps, plus a newly launched Star Wars-themed set. Why should you be interested in buying trading cards on your phone? One starting point is the capabilities the digital platform provides — literally hundreds of thousands of different designs, the ability to create all manner of rare and unique cards, etc.

Topps is also rolling out a daily fantasy sports feature (DFS was a major topic of conversation at On Deck) that allows you to compete using the players in your card deck and swapping them in and out in real time as they go up to pitch or bat. It probably doesn’t hurt, either, that they won’t take up space under your bed or get thrown out by your mom when you’re away at college.

Topps conference talk

Coming To Your Hometown

If you want to look for the next wave of sports technology, though, look to your neighborhood.

Rather than providing new tools or analytics for MLB, the NFL or the NBA, the newest sports apps want to help you participate in sports in your own town. On Deck wrapped up with a “Startup Pitch Contest” a la Shark Tank where teams had four minutes to present their groundbreaking app to a group of judges. The six competitors included:

  • Wooter – a search engine for finding and joining sports and activities like local rec leagues. Wooter provides profiles for leagues looking to form teams, players looking to join them, and the tools to process payment and set up other logistics.
  • NextPlay – helping youth coaches conduct tryouts and league drafts. For $15/month, instead of taking a stopwatch, a bunch of handwritten notes, and an Excel spreadsheet to put together youth rosters, NextPlay handles all the data collection and analytics itself. Their beta has been used by “a couple hundred organizations” and over 10,000 athletes.
  • ScoreStream – filling a gap in local journalism by crowdsourcing reports on high school sports.

With a really impressive presentation, broad coverage (10,300 HS games covered last week alone) and the #1 iOS app for high school sports, I really thought Scorestream would walk away with the prize, but it ended up going to…

  • SidelineSwap, a P2P marketplace for sporting goods. SidelineSwap has over 43,000 registered users who’re interested in trading out sporting gear just collecting dust in their basement or garage. They’re working on building partnerships with youth organizations and promoting used college-branded material, which should play very well with their chief audience of high school students.

On the whole, On Deck was a whirlwind experience for learning about cutting-edge sports tech. This report only covers part of everything I caught there. Watch for further updates and profiles soon!


MLB is Cracking Down on Your Twitter GIFs

Our days of posting our favorite baseball highlights on Twitter might be coming to an end, if they haven’t already. Recently, it appears as if MLB Advanced Media has been requesting that Twitter remove GIFs (technically, GIFs uploaded to Twitter are converted into video files, but the idea remains) that they believe violate copyright laws. It’s a move that’s both within the rights of MLBAM, yet still slightly confusing from a fan-engagement standpoint. If this is a harbinger of things to come, then our days sharing sports GIFs with our friends and followers might soon be over.

I first heard of the new policy via FanGraphs writer Jeff Sullivan. He had created a GIF of Felix Hernandez and tweeted it, but later got an email alerting him that it had been taken down.

twittergiftakedown

As it happens, MLB had a video of the same highlight on their site. Now, Jeff’s GIF would be in violation of copyright whether MLB had their own highlight posted or not, it just seems like more than a coincidence. In the full email the above picture is referencing, there were other reported tweets from different Twitter users — notably @cjzero, who posts many videos of various sports through the social media platform. Sullivan believes this to be a mistake.

“Weirdly, in the same email, I saw notice of identical complaints filed about @cjzero and @megrowler. I probably wasn’t supposed to see those but multiple people responsible for this are stupid,” he said.

However, it shows that he is not the only one being targeted in this new development.

The idea is simple. MLB sees a GIF of a play or highlight and notices that they have the same video hosted on their web site. However, when the video is viewed on their web site, an ad is played beforehand. On Twitter, it’s not. MLB loses a (probably very tiny) source of revenue. MLB asks Twitter to take it down, Twitter complies.

(Note, I am not a lawyer. The following is simply my speculation based on the fact that I am a reasonable human adult)

Is it a violation of copyright laws? Yes. Well, probably. It all depends on your (or a judge’s) take on what’s fair use. There was actually a big decision in the courts recently about media takedowns and fair use. In what’s now known as the dancing baby case (no, not that dancing baby), a parent was instructed by YouTube to take down a video they had posted of their baby because the radio in the background was playing a song by Prince. The video taker, Stephanie Lenz, along with the Electronic Frontier Foundation sued Universal Music Group (the copyright holder) claiming that Universal did not consider fair use before ordering the video’s removal. Eventually, the United States Court of Appeals for the Ninth Circuit ruled in Lenz’s favor. The gist is that Lenz didn’t just post a Prince music video, but a video in which the song happened to be playing. It falls under the umbrella of fair use.

There are four basic factors of fair use:

  • the purpose and character of your use
  • the nature of the copyrighted work
  • the amount and substantiality of the portion taken, and
  • the effect of the use upon the potential market.

Lenz’s claim most likely falls under the first. Lenz did not post the video with the intent of allowing people to listen to Prince for free. If Jeff Sullivan (or anyone else effected by MLBAM’s new attitude) wanted to contest their treatment, they might have some ground to stand on, but it would be shaky. Number three seems plausible if you take the length of a clip against the length of a whole game, but as I’m sure MLBAM considers a highlight to be just as much copyrighted as an entire game.

In the long run, fighting a copyright claim probably isn’t worth it. It is worth it, however, to question just who is being served here. Major League Baseball is worth over $30 billion. Are they really going to cry “poor” when some people don’t have to watch a T-Mobile ad before a highlight of a home run? And, to me, the chance to screw over MLB isn’t in most poster’s interests either. The point is simple — GIFs play right in the browser when scrolling through Twitter. Sure, people can link the MLB clip, but it would involve extra clicking. Is it a big deal? Not really. But the immediacy of it all is what makes Twitter Twitter.

Let us not forget that nearly every baseball GIF people post enhances MLB’s brand. The NBA figured this out early. They let anyone with iMovie and some time post highlights, mash-ups, parodies, etc. to YouTube, Twitter, Facebook, and the like. If you want to find a baseball clip on YouTube, you better hope that MLB has posted it themselves. Otherwise, there are no others to be found.

Because of my experience as a baseball writer, I immediately wondered about MLB’s new stance impacting baseball sites and blogs. A lot of writers use GIFs for analysis or to drive home a point. Are we to believe that this practice will be in jeopardy? Sullivan doesn’t think so, at least for right now.

“I’ve never heard of MLBAM complaining about gifs used at FanGraphs,” he said in an email correspondence. “Similarly, I don’t recall ever getting a complaint about gifs I used at SB Nation or Lookout Landing. Maybe something just slipped my mind, but there’s never been anything systematic. It seems they’re mostly okay with gifs used in the context of analysis, but viral stuff on Twitter — that gets their attention. Maybe because they’re trying to establish their own social presence and they want something approximating a monopoly of coverage. But this is speculation! I’m probably going to keep trying #pitchergifs because I’m a dangerous rebel who likes danger.”

I did reach out to MLBAM for comment, but have not heard back as of this writing. In the interest of full disclosure, my email provider did go down for about 20 minutes this morning. It’s unlikely that they tried to reach me then, but I mention it just in case. In truth Major League Baseball — a sports league that has a very large and powerful media empire named after it — has been fairly tone deaf when it comes to these types of things. Recently, they’ve made a big push with things like Cut4 and their Twitter account to promote their game. It’s a shame that they view other people, fans who want to help them out for free, simply as copyright violators. The fans are on MLB’s side on this one. At least for now. If this behavior continues, they might start losing some of their most connected and promotional fans. That would be a shame for both sides.


How David Ortiz Keeps Hitting Homers

On September 12, David Ortiz led off the top of the fifth inning by turning on a Matt Moore curveball, depositing it into the Tropicana Field bleachers for his second home run of the day and the 500th of his career. Ortiz became the 27th MLB hitter to reach the 500-homer milestone, and (at 39 years and 298 days) the fifth-oldest.

Ortiz didn’t get regular at bats until his age 24 season with Minnesota, and when he first came to the Red Sox, he shared the DH role with the immortal Jeremy Giambi. Contrast that with fellow Dominican and 500-homer man Albert Pujols, who had already played three full seasons by that age and collected 114 home runs as the Cardinals’ everyday left fielder. How has Ortiz managed to overcome this late start and defy the aging curve to hit dingers long after other sluggers have seen their power decline?

We can glean some extra insights from Ortiz’s relationship with Zepp’s baseball sensor. Because Ortiz is one of nine MLB players who endorse the Zepp baseball sensor, Zepp includes data and video from a couple of his swings with their app. And even when compared to the other professionals they’ve worked with, Ortiz’s swing impresses the Zepp scientists.

“Most of the athletes we work with are 25 years old, in the prime of their career,” Trevor Stocking, Zepp’s product manager for baseball and softball, said. “For him to have the kind of bat speed he does at age 38, 39, 40, it’s really special.”

David Ortiz Data - Total

Looking at his swing data (pictured above), we see Ortiz’s swing speed is in line with other Zepp athletes like Giancarlo Stanton, Mike Trout, and Hunter Pence. Ortiz’s time to impact (how early before contact the hitter starts his swing) is just above league-average. According to Zepp, most professional hitters’ time to impact is between .14 and .18 seconds; Ortiz was clocked at .138 seconds.

David Ortiz Bat Speed Impact

Viewing his swing path in the three-dimensional representation above, we see that Ortiz focuses on keeping his hands close to his body, ensuring the bat stays on a direct path to the ball with a minimal amount of wasted energy. This helps keep his bat fast and his swing quick.

But Ortiz is a giant of a man, listed at 6’4″ and 230 pounds. For younger players who use this technology to compare their swings to that of their heroes, it might not be a great idea (or even possible) to mimic his strategy without his strength. But Stocking says there are still lessons to be learned from his data.

“What you come away with each time you work with David Ortiz is a respect for how hard he works,” Stocking said. “He understands his swing and has a plan when he gets in the batter’s box. That’s something we can all strive to do.”

Apart from Ortiz’s successes, Zepp has had a few accomplishments of their own this summer. The company inked deals with the Angels, Diamondbacks, Padres, and Rays to provide sensors and data to hitters throughout those organizations. CEO Jason Fass said the four teams are additions to Zepp’s existing stable of MLB organizations, but declined to divulge how many or which teams, citing non-disclosure agreements.

Zepp also strengthened their existing relationship with Perfect Game, providing sensors for in-game use at this summer’s showcase events like the PG All-American Classic. The in-game data from such high-level talent provided a novel database for Zepp’s research.

“It’s the first time ever this kind of data has been recorded with pro-level talent,” Stocking said.

The Perfect Game data also hinted at a relationship between attack angle (or swing plane) and success. In the admittedly small sample gathered at the showcase, the average hit was associated with a slight uppercut, an attack angle of 12 degrees. Most outs, on the other hand, were produced by a nearly flat or slightly downward swing, having an average attack angle of -2 degrees.

“This would back up a lot of our MLB data that tells us most line drives occur when the attack angle is between five and 20 degrees,” Stocking said.

The Zepp sensor is a square, neon green device held in place by a flexible strap that goes over the knob of the bat. The sensor contains two accelerometers and one gyroscope, allowing Zepp to track the bat’s path through six degrees of freedom. Having two accelerometers allows the sensor to track the large, high-frequency accelerations that happen around impact while still accurately tracking the lower-frequency accelerations as the bat moves through the zone. The sensor connects via Bluetooth to an Android or iOS phone or tablet, where swing data (and simultaneous video) can be captured, stored, and compared to friends and professionals like Ortiz, Stanton, Trout, and others.


PSA: iOS 9 on iPad Allows Picture-in-Picture for MLB At Bat

One of the more heralded features of Apple’s new iOS 9 was a feature called picture-in-picture (available on iPad only). It allows users to shrink down a currently-playing video down to the corner of the iPad screen so they can use other apps while the video still plays. I certainly piqued my interests — could I finally watch MLB.tv on my iPad with the ability to shoot off a quick tweet or email? On the first day of iOS 9’s public availability, my questions were answered.

Given MLB’s long-standing partnership with Apple, I half expected the feature to be available from the get-go. As I played with the new OS, I found this to not be the case.

However, later that day, the fine folks at MLB Fan Support set me straight.

Once I updated the app this morning, I was able to take it for a test drive.

To enable the feature, one only needs to click thte PiP icon when the video is playing. It immediately pops into the corner. Users can then adjust the size of the video, restore to full screen, or close it all together. If you have a new-ish iPad, just update to iOS 9 (if you haven’t already) and update the At Bat app.

The whole experience was very slick during my testing. As someone who likes using my iPad to watch MLB.tv, I’m excited to finally get the ability to use other apps while I’m watching. I often use commercial breaks to send a couple emails or see what’s going on with Twitter.

iOS 9 also offers a feature called slide over, which allows users to bring a condensed view of an app (like Mail or Twitter) onto the screen while their main app remains. I tested this with At Bat as well, but the slide over brings focus to the new app and pauses playback of the video.

Now, when I want to use another app during a commercial or even during a slow part of the game, I can send my video down to the corner of the screen and do what I need to get done.

Yes, it’s a feature that computers could do forever — and almost any device that plugs into a TV can play MLB.tv, freeing up the hands for other applications, but for those of us who like to watch baseball while doing the dishes or cooking dinner, this new way to multitask will prove to be very helpful. MLB Advanced Media has a strong relationship with Apple. Let’s hope that other sports get in on the picture-in-picture action soon.


Kinduct Sports Offering Featured in Dodgers Accelerator Program

Kinduct Technologies made waves in the sports tech world when they were selected as one of ten companies in the Dodgers Accelerator program. But CEO Travis McDonough admits that his company is more mature than many of his fellow participants.

“We have 40 employees, we’ve got many many different clients, we’re across different industries, we have a mature operating system,” he said. “We have now 50 professional sporting organizations that are using our tool and it changes every day.”

The tool, which is known as the Athlete Management System, aggregates data from wearable, camera-based, and even more subjective systems into a single environment. The system includes visualization tools so teams can search for correlations between the data themselves, and a machine learning component to further guide organization training plans. The system gives vital help to organizations trying to understand the massive amounts of data they collect from games and practices.

“There’s been an explosion of ancillary tracking tools on the market today, everything from camera systems to GPS trackers to heart rate monitors to smart phones,” McDonough said. “And all those data sources, as valuable as they are, reside in siloed pockets.”

In addition to the Athlete Management System, Kinduct offers similar services in the health care, wellness, and human performance market (which covers military and law enforcement applications). Their experience in these other fields informs the algorithms behind their athletic products.

“Because we have had the opportunity to start to figure the machine learning side out on the health side, we’re able to cross-pollinate and apply it to the sports market,” McDonough said.

But the operating system and machine learning tools are only as effective as the data they can handle. McDonough said Kinduct works with their clients to incorporate both new and existing sources of data. Their web page lists relationships with camera-based systems including the NBA’s SportVu system, as well as wearable trackers like Polar Global and Catapult, among others.

“We’re very agnostic, and we love to pull in data from as many sources as possible,” he said. “So we are absolutely delighted at the new technologies that are coming out, and all these emerging data sources are exactly what make us more powerful.”

Kinduct counts dozens of sports organizations among its clients — including “more than half the NBA,” according to McDonough — and is working with a few unnamed leagues to manage data across all teams. The obvious differences are there, of course: basketball teams have different expectations for their relationship with Kinduct than hockey teams or baseball clubs. But the varying levels of sophistication across organizations provides an additional challenge, and Kinduct has to ramp up or scale back their offerings according to the client’s experience and comfort level.

“The NBA teams, they put their arms right around technology so we adopt what they use,” McDonough said. “When it comes to other organizations … they’re looking for recommendations by us to suggest ancillary technologies that can do the best job of tracking their players.

From a researcher’s perspective, the fact that Kinduct works with such a large percentage of the NBA is exciting. Deep in their databases is tracking and data, across games and practices, on dozens of elite athletes. McDonough estimated that the average NBA team spent $10 million on players sidelined with “preventable” injuries, repetitive stress injuries arising from flawed biomechanics that he likened to a stone cutter chipping away at a rock. And while McDonough was more than happy to describe how an individual team could combine their various data sources to find potential injury markers, he also stressed his company’s respect for the “firewall” that protects not only each team’s raw data, but also any metrics they build on top to analyze those data.

“It’s almost like we provide a technological apartment building, but each and every team moves their specific furniture and wallpaper in it, and the keys to the front door are locked down so no one can go in it but that organization,” he said.

Still, he agreed that a league-wide approach would be more effective, allowing coaches and staff to spot trends in a wider sample of data that could keep players off the trainer’s table.

“The right thing in the future is for leagues to be able to analyze the data and intervene to make sure the players are playing at their best and reducing injury as best as they can,” McDonough said.

Nevertheless, Kinduct is still dealing with health care data, which is subject to a wide range of safeguards to protect patient confidentiality. On top of that, athletes and the players associations that represent them remain leery about biomechanical data being used against them during contract negotiations. Players associations also objected to earlier iterations of the system that tracked athlete workouts during the off-season as excessive. As a result, Kinduct has worked to produce a system that provides the data front offices are after while remaining as unobtrusive as possible to players.

“For a player, they just want to win games, they want to win a championship,” McDonough said. “And a level of surveillance [during the season] seems to be acceptable by both the players’ association, the players, and of course management and ownership.”

It was announced in August that Kinduct was one of the ten companies selected for the Dodgers’ first annual accelerator program, which will run through a “demo day” November 15. The Dodgers are running the accelerator in conjunction with advertising agency R/GA, who has successfully run a number of similar programs in the past. Described by McDonough as “almost like a business boot camp,” the program offers Kinduct mentoring from a who’s who of sports executives and a chance to get more exposure.

“What we have is a Ferrari in a garage,” he said. “This allows us to open the garage door and have more people see our Ferrari. And people want to drive it, and it’s exciting.”

For now, McDonough and his staff have moved to Los Angeles to participate in the accelerator, and plan to open an office in the U.S. after the program to expand into the American market, especially in the health care, fitness, and military areas that fall under the same “human performance” umbrella as the company’s Athlete Management System. Still, McDonough said the company would remain true to its Canadian roots regardless of its excursions south of the border.

“We’ll always have a home base in Halifax,” McDonough said. “But we need to have a bigger presence in the United States.”


On the Fairness of the PITCHf/x Box Being Shown on TV

Recently, yours truly was a guest on the Offspeed Podcast talking about the plausibility of robot umpires being used in baseball. Not humanoid robots, really — more like a system of lasers or cameras similar to what the San Rafael Pacifics used recently in a game/publicity stunt. I mentioned how PITCHf/x could be better utilized to monitor and grade umpires, bringing a level of accountability to the whole process. There are a lot of caveats that go into all that, and I would suggest you listen to the episode to get all my thoughts if you are interested, as I’m not keen on regurgitating all of them here. But as I was watching Monday’s Astros/Rangers game, my thinking started to change. There were some questionable calls, as there always are in any game. But we only knew they were really questionable because of the broadcast’s replay and the use of PITCHf/x technology. It got me wondering; is it fair that we as fans are the only people that get to see the strike zone in real time?

Criticisms of the home plate umpire are nothing new. Way back when, fans in the bleachers would argue over balls and strikes. Then TV came, and fans could yell at it over a call. A little later, instant replay was brought into the fold, further increasing the fans’ abilities to form opinions on where a pitch crossed the plate. High definition video did the same. And recently, almost every network has utilized some form of PITCHf/x visualization on screen. Some do it in replays, others have it emblazoned on the screen for every pitch. Never before have we been able to criticize umpires, hitters, and pitchers over their respective opinions on the strike zone to such a degree. And the weirdest part as that we are the only people who can see it. That’s kind of nuts. In essence, we have a better understanding of the strike zone than those who are in charge of it, or whose successes or failures depend on it. It’s an odd situation we’ve put ourselves in. And I’m wondering if something doesn’t need to change.

The first option would be for MLB to enforce some sort of rule and abolish the PITCHf/x box in broadcasts all together. As complaining about home plate umpire calls is in the list of Top One Favorite Things for a Baseball Fan to Do, I don’t really see that happening. I would imagine most fans wouldn’t care (or would even applaud) if the permanent box went away, but it would certainly be missed on replays. FOX would get a slew of complaints during the postseason if our favorite umpire-measuring tool was to go away. Like $10 beer and God Bless America, it’s part of the game now, like it or not.

The second option would be to figure out a way to have the strike zone represented in real life — some sort of hologram displaying the dimensions for the pitchers, hitters, umpires, and fans to see. I understand that this would be SUPER WEIRD. But it would be effective. In all honesty, if we went through all the trouble of installing this system, we could probably do away with the home plate umpire all together and have a laser/camera setup make the decisions for us. This is the premise of the #RobotUmpsNow movement. It would be extremely accurate, and honestly would give a solid foundation to one of the more important dimensions of the game.

This seems foreign, because until very recently, it wasn’t possible. Baseball is full of lines, but strike zone lines (with the exception of the actual home plate) were never available. But it’s 2015, and it is possible now. So why hasn’t baseball adopted it?

Every other sport has lines painted where the boundaries of the game lie. This lets the players and officials know when that boundary has been crossed. We wouldn’t dream of playing a football game on a field without the goal lines. Though ball placement by officials in the NFL can leave things to be desired, the first down line is still represented by a movable arrow on the sidelines. Hockey, tennis, EVERY OTHER SPORT has visible lines depicting what’s in play and what’s out. Yet, in baseball, the strike zone — the area where every play begins — does not.

Except if you are watching at home, that is. Umpires (allegedly) get graded on their interpretation of a strike zone that they cannot see. There are dimensions written in the rules, certainly. But remember that the whole balls/strikes thing was invented when pitchers threw underhand and curve balls were illegal. Dudes are humping it up over 100 MPH and dropping nasty breaking balls in our current game. Isn’t it a little unfair to ask the human eye to interpret that data on the spot?

Yes, it takes away certain aspects of the game — I’ve even argued this myself. Some pitchers possess the ability to widen the strike zone over the course of the game. Some catchers have the ability to frame pitches to make them look like strikes. These are tangible skills that would be reduced should a concrete strike zone be put in place. But sometimes you have to break a few eggs, especially when the fairness of the sport is in question.

I doubt any of this will change in my lifetime. I’m not even sure it should. Baseball is a sport built on and respectful of tradition — some times to a fault. That doesn’t erase the fact that it’s still being played with an ostensibly-invisible boundary that we certainly have the capability of representing visually. When the fans have access to slow-motion replays at 60 frames per second of pitches traveling over a superimposed strike zone, and everyone actually involved in the game has to just kind of guess and wing it, it creates a strange dichotomy. Science and technology have created bigger and stronger athletes, faster pitches, and a system that can track a ball’s position in a split second. And for the most part, we’re asking umpires to just eyeball it. I’m not quite sure in whose interests that serves. The fans are better equipped to calls balls and strikes than the umpires now. Perhaps it’s time that everyone on the actual field of play are afforded the same luxuries that we are.

(Image via ESPN)

Behind the Code: Sports-Reference Founder Sean Forman

Behind the Code is an interview series centered around the sports-related web sites we use every day. The first installment features Sports-Reference founder Sean Forman.

For the first century of sports, newspapers, almanacs, and baseball cards were the medium of choice for communicating statistics. But the world of sports statistics has gone from paper to electric in less than two decades — and the Sports-Reference family of websites has been a key component in that transition.

We caught up with Sean Forman, founder of the Sports-Reference network — which includes Baseball-Reference.com, Pro-Football-Reference.com, and Basketball-Reference.com — and talked about the genesis and future of his family of stats sites.

Bradley Woodrum: What inspired you to start the site back in 2000? I know David Appelman started FanGraphs to help his fantasy team. Did B-Ref have equally humble beginnings? Or was the expectation to become, essentially, the modern almanac for sports statistics?

Sean Forman: I had a similar creation story. There was really nobody doing an online encyclopedia and I thought it would be a great medium for that work. You could hyperlink between pages. So rather than leafing through a book (sounds crazy now) to hunt down Joe DiMaggio’s teammates you could just click a link and see them all. I didn’t expect it to do much. I worked hard on it for two months (while I was in grad school and should have been working on my dissertation) and got the basic site done.

BW: What was the online sports statistics scene back in 2000? What were your go-to resources for stats before Sports-Reference and before the Lahman database?

SF: The Lahman DB was the first bones of the site. It wouldn’t have happened without Lahman’s DB and the work of Pete Palmer that the Lahman DB is based upon. There was no historical content really online in 2000. TotalBaseball.com had a site, but it was barely usable. I was a disciple of Jakob Nielsen at that time, so my focus on usability and ease of use really paid off initially as there was so much cruft out there in web design. Splash pages, flash sites, image maps, blink and marquees.

While TotalBaseball.com had a pretty nifty biography section for major players back in 2000, it lacked the meat of a more statistically rigorous site.
While TotalBaseball.com had a pretty nifty biography section for major players back in 2000, it lacked the meat of a more statistically rigorous site.

BW: I understand you were previously a teacher before working on Sports-Reference full time. What was that transition like? And how did you finally make the decision to go full time?

SF: I was a full-time math/CS professor for six years. I actually completed the site before taking that job. During that time, I did B-R in my free time. One mitigating factor is that we weren’t updating in-season at that time, so the stress was a lot lower and we didn’t need to be as on top of things. I could leave it for a week and not worry about it.

BW: The Sports-Ref family is famous for its Spartan design — outside of the player pictures on B-Ref, there’s, what, a single PNG on the whole site, and that’s the logo. Even the interactive charts and graphs have a minimalist design. Has this aesthetic lasted the test of time for its functionality, or is it more just the site’s personality at this point?

SF: [It has a] few more [pictures] than that, but not many. We are trying to reduce them further.

It’s both our personality and for functionality reasons. I’ve heard some people call it the Craigslist of baseball stats. I like to think one of our strengths is that we can view the site from the user perspective better than most. That is really hard to do. We have 250 MB internet connections and gigantic phones and use the latest chrome browser and know internally how the site is put together, but a new user has none of that. They may be on an old windows machine with a 1200×800 resolution with a slow internet connection. Basically you’ve got to make things more obvious than you can even imagine being necessary.

We had a good example of this last week. We launched a new “register” section to combine the minors, Japan, NLB, Cuba and KBO stats into one area. Larry Doby is our test case for this. We called it register because we’ve got 70+ Sporting News Baseball Registers on our shelves and those showed the stats pretty much in the way we are doing it now. Within 20 minutes of launching, we got complaints that we’d taken away the minor league stats, asking are were expecting people to “sign-up” (read register) for the site. We should have caught that on our end, but we were able to fix it quickly and improve the clarity in the process.

Larry Doby's page shows the new layout and links for the stats register. Even small changes like this can cause big waves with users.
Larry Doby’s page shows the new layout and links for the stats register. Even small changes like this can cause big waves with users.

BW: Speaking of the lesser known stats, the B-Ref Bullpen has developed into a go-to resource for baseball fans and writers, oftentimes trumping player’s actual Wikipedia pages. What inspired you to add this feature? Do you expect the basketball and football sites will eventually get their own wiki’s too?

SF: I started it because 1) I love Wikipedia. Wikipedia may be the greatest human accomplishment of all time. I’m not joking. Think about how valuable having all of that knowledge in one place is. (DONATE!). 2) For good reason Wikipedia starts their baseball articles with info like “Ty Cobb is an American baseball player…” and I thought that it would be interesting to put together pages for players that were more in depth and baseball oriented than wiki would want. The funny thing is that the star players get almost no treatment on our site, but we have 1000’s of words on Japanese players, Negro Leaguers and early players. It makes sense as there is a need to know about those players.

As for the other sites, we probably should have just done it by now. I’ve been skeptical we’d get any traction with them, but it would have been a good idea to start them.

BW: Baseball, basketball, football, hockey, and Olympics. Is there any area remaining that you might want to add? Maybe prep / high school stats?

SF: The great frontier is soccer (fbref.com). It makes the history of professional baseball look like child’s play. We have a great dataset and hope to get something launched this winter. My favorite stat I’ve discovered is that the English Wikipedia has more pro soccer clubs listed than there have been players in Major League Baseball history.

BW: Oh wow. I can’t even conceptualize that many teams. I’m looking forward to see how you handle that!

A big thanks to Sean for taking the time to talk with us! Be sure to give him a follow on Twitter at @Sean_Forman.


Blast Motion, Easton Collaborate to Produce Easton Power Sensor

The Easton Power Sensor, produced through the partnership between wearable sensor manufacturer Blast Motion and baseball equipment manufacturer Easton, was recently released. The sensor was the result of a collaboration first announced in January 2014, and has been in the works since before the official launch of the Blast Baseball Replay.

The product, which will go on the market this fall, is largely a re-branding of the existing Blast Baseball Replay sensor. For the first time, however, Blast will expand its offerings to support Android devices. Donovan Prostrollo, Blast Motion’s senior director of marketing, says that current users will also benefit from future software changes that will come out of this partnership.

“There has been a lot of infrastructure work that has gone on behind the scenes,” Prostrollo said. “We will be providing a free software upgrade to Blast Baseball Replay customers, allowing them to gain all the benefits of the Easton Power Sensor and the new features that are on the way.”

Now that the sensor has been officially released, Easton plans to incorporate it into its traveling Hit Lab, which combines video capture and Trackman radar systems to help players learn more about their swings.

“[The Hit Lab] offers an unmatched opportunity for players to experience the science of hitting,” said Henry Fitzgerald, a member of Easton’s performance sports group. “The Easton Power Sensor will have a central role in this.”

Plans to further improve sensor performance are currently being discussed, but Fitzgerald was understandably reluctant to divulge specific improvements.

“Our R&D department is always searching for ways to improve our bats and any relevant technology,” Fitzgerald said.

The announcement coincided with the start of the 2015 Little League World Series, which ended this past Sunday. As the official equipment sponsor of the event, Easton brought the Power Sensor to Williamsport (shown above) to demonstrate its capabilities for the second straight year.

“It’s exciting to see the kids when they get their hands on the sensor and see their metrics,” Prostrollo said. “By combining the science of hitting with innovative technology, we’re able to give players of all ages and skill levels the insights they need to improve their swing.”

Like Major League Baseball, Little League Baseball currently does not allow wearable senors like the Easton Power Sensor on the field during competitions. But Fitzpatrick says Easton has been lobbying for these groups to lift this ban.

“The sensor as it is today does not offer any sort of performance advantage,” he said. “It’s simply an attachment.”

Like the Blast Baseball Replay, the Easton Power sensor is driven by a “tactical-grade” inertial measurement unit (IMU), which combines more precise sensors, more processing power, and on-the-fly calibration to improves the device’s accuracy and consistency. Both the Blast and Easton apps revolve around video, typically captured by setting the device on a tripod and automatically clipped so that only the events of interest are included. Users can view their swings in adaptive slow-motion, which automatically adjusts the playback speed around key moments in the swing. In an earlier interview, Prostrollo said Blast Motion’s focus on video allows Blast’s Baseball Replay — now re-branded as the Easton Power Sensor — to give users insights into more than just bat path alone.

“Because we approached it from the natural motion capture side, we knew that it was going to be a lot more about what is your entire body doing,” Prostrollo said. “The metrics are really only half the story. You really need to put that in context, you need to make it personal.”


MLB Fan Lawsuit Seeks Technological Remedy

Last month, Oakland A’s fan Gail Payne filed a class-action lawsuit against Major League Baseball in an effort to compel the league to provide more protective netting at all ballparks, including minor-league parks:

The Plaintiff and the Class are entitled to injunctive relief requiring Defendants, among other things, to adopt corrective measures regarding the implementation of: (1) a rule requiring all existing major league and minor league indoor and outdoor ballparks to be retrofitted to extend protective netting from foul pole to foul pole by the beginning of the 2016-2017 MLB season; (2) a rule requiring any newly constructed ballpark intended to house major or minor league baseball games, to include at a minimum this amount of netting; and (3) a program to study injuries and the rates of injuries amongst spectators, including the type and manner of injury and at what locations in ballparks they occur, in an effort to continually reevaluate whether additional measures should be taken, so that precautionary measures can continue to evolve as the sport continues to evolve.

As Nathaniel Grow wrote for FanGraphs, Payne’s lawsuit has a relatively low likelihood for success, due to the “several strong legal defenses” available to MLB and the possible applicability of “the so-called ‘Baseball Rule,’ a doctrine historically shielding MLB teams from legal liability for injuries incurred by fans from foul balls or broken bats.” (Payne attached to her complaint a “sample list of injuries suffered to spectators located in the unprotected areas along first and third base between the foul poles, during official play” that identifies about eighty-five such injuries since the early 1900s.)

If the case does go forward, though, it could present a few interesting questions. One is whether the U.S. District Court for the Northern District of California, where Payne’s case is pending, will apply the Baseball Rule. Last summer, the Georgia Court of Appeals refused to do so, affirming a trial judge’s rejection of a request by the Atlanta Braves (joined by the office of then-MLB Commissioner Bud Selig) to apply the rule and dismiss a lawsuit brought on behalf of a child whose skull was shattered by a foul ball at a Braves game.

A second question arises out of the procedural nature of Payne’s complaint, which seeks class-action treatment, and involves the means available to dissenters in the proposed class for challenging Payne’s position. Unlike the more popularly familiar “opt-out” class-action lawsuits, for which you may have received a coupon because you purchased overpriced energy drinks or music CDs, Payne’s proposed class action will proceed, if at all, under a different rule as a “mandatory” class action. Practically, this means that, if the court certifies Payne’s case as a class action, the final result of the case will bind every member of the class, which Payne broadly defines as all MLB season-ticket holders with seats “in any unnetted/uncovered area between home plate and the foul plates [sic] located at the end of the right and left field lines . . . .” As Grow suggested in his FanGraphs post, if the court grants her request for class certification, Payne could find herself with some unhappy fellow class members, as it seems likely that many MLB season-ticket holders with seats in what Payne’s complaint dubs “the Danger Zone” prefer their completely unobstructed views of the action and do not agree with Payne that the league should extend netting all the way to each foul pole. Because the proposed class is of the mandatory variety, though, dissenting class members could not simply opt out and control their own legal destinies. While yet another rule may allow those season-ticket holders who don’t want additional netting requested to intervene in the case and make their objections known, they must take affirmative steps to do so, and they must act in a timely fashion. A possible alternative, which Grow mentioned, is that MLB itself may point to this probable intra-class division in the course of its anticipated argument that the court should not allow the class action to proceed, thus relieving the dissenting class members from the need to do so. (On this point note that, on Monday, MLB filed a routine Disclosure of Interested Entities, which listed only the league’s thirty teams and their owners as among those entities having “a financial interest in the subject matter in controversy [or] having a non-financial interest in that subject matter . . . that could be substantially affected by the outcome of this proceeding.”) MLB’s answer to Payne’s complaint is due on October 2, 2015.

Third, and the reason for taking a look at this case over here at TechGraphs, Payne’s complaint raises a question of practical technology: How can we keep baseball fans safe while affording them the best available opportunity to enjoy baseball games? While the response from Payne’s legal and ideological opponents is that the fans themselves (and alone) bear the burden of ensuring their safety, an increase in fan-protection measures of some sort seems likely. MLB teams, including the aforementioned Braves, already employ extended netting during pregame activities, and further severe fan injuries could mobilize popular sentiment and personal injury lawyers to target MLB’s pockets, rather than merely its conscience.

To some, the pushback against increased safety netting should sound as a cry for technological innovation. As attitudes about netting change, a manufacturer who could produce stadium nets with reduced visual obtrusiveness seemingly would find himself or herself well-positioned to enter the market. (I contacted representatives for multiple MLB teams and netting manufacturers in connection with this story. None offered substantive comment, although one, Tex-Net, Inc. owner John Scarperia, indicated that he thought that the nets in use today already were as unobtrusive as possible while still providing the requisite degree of protection.)

And attitudes are likely to change. In 2002, thirteen-year-old Brittanie Cecil died as a result of injuries sustained when a deflected hockey puck struck her in the head during the course of an NHL game between the Calgary Flames and Columbus Blue Jackets. Three months later, the league, having completed a study of the issue, decided to significantly expand fan safety measures in its arenas by installing large safety nets at each end of the ice.

Image via Wikipedia
Image via Wikipedia

As Yahoo! hockey blogger Greg Wyshynski recalled in a post marking the tenth anniversary of Cecil’s death, negative fan reaction to the netting in 2002 was substantial and precisely in line with the remarks from 2015’s opponents to increased baseball netting. From the article announcing the new nets: “Some Blackhawks season ticket-holders said during the season that they would oppose having netting installed because it would interfere with their view of the game.” From a (oddly illuminated) contemporary editorial:

If spectators paid attention to the game, safety wouldn’t be a concern.

At the MCI Center in Washington, D.C., 122 fans were injured in 127 games, most of them weren’t serious, according to a report by two emergency room doctors. Meaning spectators were trying to be heroes by catching the puck and cutting their hand or something minor.

Don’t try to be heroes when the puck is traveling at 100 miles per hour; just duck.

The nets are good news to some people, such as the architects that build new arenas and stadiums. Now, with the nets, spectators will be able to see ice rinks where there are only 15-20 rows of seats behind the end zones and the rest near center ice. Taller and wider stadiums will be built as soon as the word gets out that no one can see through the nets.

Even Doug MacLean, then the general manager for– of all teams, the Blue Jackets– received angry mail: “It was shocking to me. When we put the nets up in Columbus [where Cecil was killed], I had some unbelievably nasty letters from season ticket-holders asking me how I could do that to their sight-lines.”

Wyshynski, who admitted he too was an early opponent of the netting, revisited the story ten years later not so much to chide or mock those early opponents but to observe just how much of an afterthought the netting had become since the initial outcry over its installation: “The purists bristled at the end of a tradition. Debates raged … and then a decade later, yesterday’s hot-button debate is today’s societal norm.” Should MLB ultimately follow the NHL in mandating new safety netting, it isn’t too difficult to imagine that, ten years down the road, your favorite baseball writer on whatever future version of TechGraphs exists at that time will have something similar to note.

(Header image via Rob Bixby)

How To Use R For Sports Stats, Part 3: Projections

In this series, we’ve walked through how exactly you can use R for statistical analysis, from the absolute basics of R coding (in part 1) to visualizing data and correlation tests (in part 2).

Since you’re reading this on TechGraphs, though, you might be interested in statistical projections, so that’s how we’ll wrap this up. If you’re just joining us, feel free to follow along, though looking through parts 1 and 2 first might help everything make more sense.

In this post, we’ll use R to create and test a few different projection systems, focusing on a bare-bones Marcel and a multiple linear regression model for predicting home runs. I’ve said a couple times before that we’re just scratching the surface of what you can do — but this is especially true in this case, since people write graduate theses on the sort of stuff we’re exploring here. At the end, though, I’ll point you to some places where you can learn more about both baseball projections and R programming.

Baseline

Let’s get everything set up. We’ll have to start by abandoning –well, modifying– that test data set that served us so well in Parts 1/2; we’ll add another two years of data (2011-14), trim out some unnecessary stats, and add a few which might prove useful later on. It’s probably easiest just to download this file.

Then we’ll load it:

fouryr = read.csv("FG1114.csv")

convert some of the percentage stats to decimal numbers:

fouryr$FB. = as.numeric(sub("%","",fouryr$FB.))/100
fouryr$K. = as.numeric(sub("%","",fouryr$K.))/100
fouryr$Hard. = as.numeric(sub("%","",fouryr$Hard.))/100
fouryr$Pull. = as.numeric(sub("%","",fouryr$Pull.))/100
fouryr$Cent. = as.numeric(sub("%","",fouryr$Cent.))/100
fouryr$Oppo. = as.numeric(sub("%","",fouryr$Oppo.))/100

and create subsets for each individual year.

yr11 = subset(fouryr, Season == "2011")
colnames(yr11) = c("2011", "Name", "Team11", "G11", "PA11", "HR11", "R11", "RBI11", "SB11", "BB11", "K11", "ISO11", "BABIP11", "AVG11", "OBP11", "SLG11", "WAR11", "FB11", "Hard11", "Pull11", "Cent11", "Oppo11", "playerid11")
yr12 = subset(fouryr, Season == "2012")
colnames(yr12) = c("2012", "Name", "Team12", "G12", "PA12", "HR12", "R12", "RBI12", "SB12", "BB12", "K12", "ISO12", "BABIP12", "AVG12", "OBP12", "SLG12", "WAR12", "FB12", "Hard12", "Pull12", "Cent12", "Oppo12", "playerid12")
yr13 = subset(fouryr, Season == "2013")
colnames(yr13) = c("2013", "Name", "Team13", "G13", "PA13", "HR13", "R13", "RBI13", "SB13", "BB13", "K13", "ISO13", "BABIP13", "AVG13", "OBP13", "SLG13", "WAR13", "FB13", "Hard13", "Pull13", "Cent13", "Oppo13", "playerid13")
yr14 = subset(fouryr, Season == "2014")
colnames(yr14) = c("2014", "Name", "Team14", "G14", "PA14", "HR14", "R14", "RBI14", "SB14", "BB14", "K14", "ISO14", "BABIP14", "AVG14", "OBP14", "SLG14", "WAR14", "FB14", "Hard14", "Pull14", "Cent14", "Oppo14", "playerid14")

(We’re renaming the columns for each subset because the merge() function has some problems if you try to merge too many sets with the same names. If you want to explore the less hacked-together way of reassembling data frames in R, take a look at the dplyr package.)

Anyway, we’ll merge these all back into one set:

set = merge(yr11, yr12, by = "Name")
set = merge(set, yr13, by = "Name")
set = merge(set, yr14, by = "Name")

Still with me? Good. Thanks for your patience. Let’s start testing projections.

Specifically, we’re going to see how well we can use the 2011-2013 data to predict the 2014 data. For simplicity’s sake, we’ll focus mostly on a single stat: the home run. It’s nice to test with–it’s a 5×5 stat, it has a decent amount of variation, it gives us experience with testing counting stats while being more player-controlled than R/RBI… and, come on, we all dig the long ball.

Now when you’re testing your model, it’s nice to have a baseline–a sense of the absolute worst that a reasonable model could do. For our baseline, we’ll use previous-year stats: we’ll project that a player’s 2013 HR count will be exactly what they hit in 2014.

To test how well this works, we’ll follow this THT post and use the mean absolute error–the average number of HRs that the model is off by per player. So if a system projects two players to each hit 10 homers, but one hits zero and the other hits 20, the MAE would be 10.

(If you end up doing more projection work yourself, you may want to try a more fine-tuned metric like r² or RMSE, but I like MAE for a basic overview because the value is directly measurable to the stat you’re examining.)

To find the mean absolute error, take the absolute value of the difference between the projected and actual stats, sum it up for every player, then divide by the number of players you’re projecting:

sum(abs(set$HR13 - set$HR14))/length(set$HR14)
> [1] 6.423729

So the worst projection system possible should be able to beat an average error of about six and a half homers per player.

Marcel, Marcel

Now let’s try a slightly-less-than-absolute-worst model.

Marcel is the gold standard of bare-bones baseball projections. At its core, Marcel predicts a player’s stats using the last 3 years of MLB data. The previous year (Year X) gets a weight of 5, the year before (X-1) gets a weight of 4, and X-2 gets a weight of 3. As originally created, Marcel also includes an adjustment for regression to the mean and an age factor, but we’ll set aside such fancies for this demonstration.

To find Marcel’s prediction, we’ll create a new column in our dataset weighing the last 3 years of HRs. Since our weights are 5 + 4 + 3 = 12, we’ll take 5/12 from the 2013 data, 4/12 from the 2012 data, and 3/12 from the 2011 data. Then we’ll round it to the nearest integer.

set$marHR = (set$HR13 * 5/12) + (set$HR12 * 4/12) + (set$HR11 * 3/12)
set$marHR = round(set$marHR,0)

Voila! Your first (real) projections. How do they perform?

sum(abs(set$marHR - set$HR14))/length(set$HR14)
> [1] 5.995763

Better by nearly half a home run. Not bad for two minutes’ work. 6 HR per player still seems like a lot, though, so let’s take a closer look at the discrepancies. We’ll create another column with the (absolute) difference between each player’s projected 2014 HRs and actual 2014 HRs, then plot a histogram displaying these differences.

set$mardiff = abs(set$marHR-set$HR14)
hist(set$mardiff, breaks=30, col="red")

Histogram of Marcel HR errors

Not as bad as you might have thought. Many players are only off by a few home runs, some off by 10+, and a few fun outliers hanging out at 20+. Who might those be?

set = set[order(-set$mardiff),]
head(set[c(1,72,90,91)], n=10)

(In that last line, we’re calling specific column names so we don’t have to search through 100 columns for the data we want when we display this. You can find the appropriate numbers using colnames(set).)

List of players with largest Marcel HR errors

A list headlined by a season-ending injury and two players released by their teams in July; fairly tough to predict in advance, IMO.

While we’re here, let’s go ahead and create Marcel projections for the other 5×5 batting stats:

set$marAVG = (set$AVG13 * 5/12) + (set$AVG12 * 4/12) + (set$AVG11 * 3/12)
set$marAVG = round(set$marAVG,3)
set$marR = (set$R13 * 5/12) + (set$R12 * 4/12) + (set$R11 * 3/12)
set$marR = round(set$marR,0)
set$marRBI = (set$RBI13 * 5/12) + (set$RBI12 * 4/12) + (set$RBI11 * 3/12)
set$marRBI = round(set$marRBI,0)
set$marSB = (set$SB13 * 5/12) + (set$SB12 * 4/12) + (set$SB11 * 3/12)
set$marSB = round(set$marSB,0)

And, for good measure, save it all in an external file. We’ll create a new data frame from the data we just created, rename the columns to look nicer, and write the file itself.

marcel = data.frame(set$Name, set$marHR, set$marR, set$marRBI, set$marSB, set$marAVG)
colnames(marcel) = c("Name", "HR", "R", "RBI", "SB", "AVG")
write.csv(marcel, "marcel.csv")

Before we move on, I want to quickly cover one more R skill: creating your own functions. We’re going to be using that absolute mean error command a couple more times, so let’s create a function to make writing it a bit easier.

modtest = function(stat){
 ame = sum(abs(stat - set$HR14))/length(set$HR14)
 return(ame)
}

The ‘stat’ inside function(stat) is the argument you’ll be including in the function (here, the column of projected data we’re testing); the ‘stat’ shows up inside the bracketed text where your projected data did when we originally used this command. The return() is what your function outputs to you. Let’s make sure it works by double-checking our Marcel HR projection:

modtest(set$marHR)
> [1] 5.995763

Now we can just use modtest() to find the absolute mean error. Functions can be as long or as short as you’d like, and are incredibly helpful if you’re using a certain set of commands repeatedly or doing any sort of advanced programming.

Hold The Line

With Marcel, we used three factors–HR counts from 2013, 2012, and 2011–with simple weights of 5, 4, and 3. For our last projection model, let’s take this same idea, but fine-tune the weights and look at some other stats which might help us project home runs. This, basically, is multiple linear regression. I’m going to handwave over a lot of the theory behind regressions, but Bradley’s how-to from last week does a fantastic job of going through the details.

Remember back in part 2, when we were looking at correlation tests in r² and we mentioned how we were basically modeling a y = mx + b equation? That’s basically what we did with Marcel just now, where ‘y’ was our projected HR count and we had three different mx values, one each for the 2013, 2012 and 2011 HR counts. (In this example, ‘b’, the intercept, is 0.)

So we can then use the same lm() function we did last time to model the different factors that can predict home run counts. We’ll give R the data and the factors we want it to use, and it’ll tell us how to best combine them to most accurately model the data. We can’t model the 2014 data directly in this example–since we’re testing our model against it, it’d be cheating to use it ‘in advance’–but we can model the 2013 HR data, then use that model to predict 2014 HR counts.

This is where things start to get more subjective, but let’s start by creating a model using the last two years (2013/2012) of HR data, plus the last year (2012) of ISO, Hard%, and Pull%. In the lm() function, the data we’re attempting to model will be on the left, separated by a ‘~’; the factors we’re including will be on the right, separated by plus signs.

hrmodel = lm(set$HR13 ~ set$HR12 + set$HR11 + set$Hard12 + set$Pull12 + set$ISO12)
summary(hrmodel)

Screenshot of initial linear model

There’s a lot of stuff to unpack here, but the first things to check out are those “Pr(>|t|)” values in the right corner. Very simply, a p-value less than .05 there means that that factor is significantly improving your model. (The r² for this model, btw, is .4611, so this is accounting for roughly 46% of the 2013 HR variance.) So basically, ISO and Pull% don’t seem to add much value to this model, but Hard% does.

It’s generally a good practice to remove any factors that don’t have a significant effect and re-run your model, so let’s do that:

hrmodel = lm(set$HR13 ~ set$HR12 + set$HR11 + set$Hard12)
summary(hrmodel)

Screenshot of R model with significant factors

And there’s your multiple linear regression model. The format for the actual projection formula is basically the same as what we did for Marcel, except your weights will take the coefficient estimates and you’ll include the intercept listed above them. Remember that “HR12”, “HR11”, etc., are standing in for “last year’s HR total”, “the year before that’s HR total”, etc., so make sure to increment the stats by a year to project for 2014.

set$betHR = (-5.3 + (set$HR13 * .32) + (set$HR12 * .13) + (set$Hard13 * 40))
set$betHR = round(set$betHR,0)

Survey says…?

modtest(set$betHR)
> [1] 5.95339

…oh. Yay. So that’s an improvement of, uh…

modtest(set$marHR) - modtest(set$betHR)
> [1] 0.04237288

1/20th of a home run per player. Isn’t this fun? Some reasons why we might not have seen the improvement we expected:

  • We probably overfit the data. Since we ran the model on 2013 data, it probably did really well on 2013 data, but not as great on 2014. If we check the model on the 2013 data:
set$fakeHR = (-5.3 + (set$HR12 * .33) + (set$HR11 * .13) + (set$Hard12 * 40))
set$fakeHR = round(set$fakeHR,0)
sum(abs(set$fakeHR - set$HR13))/length(set$HR13)
> [1] 4.877119

It runs pretty well.

  • We didn’t include useful factors we could have. We just tested a few obvious ones; maybe looking at Cent% or Oppo% would be more helpful than Pull%? (They aren’t, just so you know.) More abstract factors like age, ballpark, etc., would obviously help–but including these would also require a stronger model.
  • Finally, projections are hard. Even if you have an incredibly customized set of projections, you’re going to miss some stuff. Take a system like Steamer, one of the most accurate freely-available projection tools around. How did their 2014 preseason projections stack up?
steamer = read.csv("steamer.csv")
steamcomp = merge(yr14, steamer, by = "playerid14")
steamcomp$HR = as.numeric(paste(steamcomp$HR))
steamcomp$HR = round(steamcomp$HR, 0)
steamcomp$HR[is.na(steamcomp$HR)] = 0
sum(abs(steamcomp$HR - steamcomp$HR14))/length(steamcomp$HR14)
> [1] 4.892157

That said, the lesson you should not take away from this is “oh, our homemade model is only 1 HR/player worse than Steamer!” Our data set is looking at players for whom we have several seasons’ worth of data —   the easiest players to project. If we had to create a full-blown projection system including players recovering from injury, rookies, etc., we’d look even worse.

If anything, this hopefully shows how much work the Silvers, Szymborskis, and Crosses of the world have put in to making projections better for us all. Here’s the script with everything we covered.

This Is Where I Leave You

Well, that about wraps it up. There’s plenty, plenty more to learn, of course, but at this point you’ll do well to just experiment a little, do some Googling, and see where you want to go from here.

If you want to learn more about R coding, say, or predictive modeling, I’d definitely recommend picking up a book or trying an online class through somewhere like MIT OpenCourseWare or Coursera. (By the end of which, most likely, you’ll be way beyond anything I could teach you.) If there’s anything particular about R you’d still like to see covered, though, let me know and I’ll see if I can do a writeup in the future.

Thanks to everyone who’s joined us for this series — the kudos I’ve read here and elsewhere have been overwhelming — and thanks again to Jim Hohmann for being my perpetual beta tester/guinea pig. Have fun!