# Introducing: xW, xBABIP, xLOB%, xHR/FB, and more

Alright guys, prepare yourselves for stat overload. I’m about to introduce 12 new stats that will help us better understand pitchers. Now I know that 12 sounds like a lot, but don’t worry too much — most of them are related to stats you’re already familiar with and/or come in pairs. I’ll explain everything as plainly as I can (while leaving enough of the guts in there for people who care), and if you have any questions, I’ll be happy to answer them.

### Where we’re at

As it stands now, many fantasy analysts are starting to make use of stats like BABIP and HR/FB, but the analysis often goes something like, “Player A has a .315 BABIP and 15% HR/FB. He is getting unlucky and both will regress toward league average.” There’s nothing wrong with this — it will usually be correct — but I think we can take things a little further. After all, not all pitchers should be expected to post an exactly league average BABIP or HR/FB or LOB%.

For example, a pitcher’s home park will effect his HR/FB, so a guy throwing half his games in Coors should be expected to have a higher HR/FB than a guy who plays in PETCO. We also know that ground balls become hits at a higher rate than fly balls, so groundball pitchers should be expected to have a higher BABIP than flyball pitchers. These are the kinds of things that my new stats will try to account for. So, without further ado, here they are:

### 12 new pitching stats

xBABIP: While we often say that a pitcher has little control over his BABIP — and this is true — they do not relinquish all control. Most importantly, we know that a pitcher has a lot of control over his groundballs and flyballs, a good amount of control over his pop-ups, and little control over his line drives. To calculate xBABIP, we first neutralize line-drive rate and adjust the other three rates accordingly (like we do to calculate xGB%). Then we assume a league average rate of hits on all types of batted balls. Add up those hits, and we can calculate an expected BABIP.

What we’ll see is that extreme GB pitchers have higher xBABIPs and extreme FB pitchers have lower xBABIPs (while also realizing that guys who induce a lot of pop-ups will have low xBABIPs too). This past season, for example, GB’er Aaron Cook had a .314 xBABIP while FB’er Jered Weaver had a .291 xBABIP.

xHR/FB: This is calculated very simply by using park factors. We assume a 50/50 home/road split for the pitcher, a neutral road schedule (HR/FB park factor of 1.00), and account for the pitcher’s home ballpark’s HR tendencies. It is very important to note, as I have in the past, that even if a pitcher calls an extreme HR park home, his expected HR/FB will still remain pretty close to neutral. The xHR/FB for Rockies pitchers, for example, was just 12.39 percent in 2009 (with a league average of 11.18 percent).

Analysts often like to credit deviation further from the mean than this to a pitcher’s home park, but that simply is not the case (unless the pitcher has thrown a disproportionate number of games at home, and even if he has, that shouldn’t be expected to continue going forward). Simply put, HR park factors are not quite as extreme as most seem to believe.

xLOB%: Of the three main ‘luck indicators,’ LOB% has the most room for skill-based variation. This is because LOB% is actually an exponential function. To put it simply, if Pitcher A allows hits at a 24 percent rate and Pitcher B allows hits at a 30 percent rate, once men reach base, more of them will score on Pitcher B because he is more likely to give up hits to begin with. His hits will be clumped closer together. As such, LOB% has a fairly strong relationship with the rate at which batters reach base.

xLOB% is calculated using a regression formula derived from BAA and BB%. Now, of course, BAA is subject to extreme variation since it is largely comprised of BABIP. So instead of using actual BAA, we use xBAA, which accounts for the pitcher’s actual K rate (as with hitters, the more Ks, the fewer opportunities for hits) and his xBABIP. What we end up seeing is that good pitchers end up leaving more runners on base (Tim Lincecum: 75.6 percent) while bad pitchers let more score (Jeremy Sowers: 68.1 percent) than league average (71.9 percent).

R/HR and xR/HR: HR/FB has become a common stat for measuring a pitcher’s luck with home runs, but it doesn’t tell us everything. For example, a pitcher can have a seemingly lucky 4 percent HR/FB but could actually have experienced bad luck with HRs if he was unfortunate enough to have given up all of his HRs while the bases are loaded. On average, about 1.4 runs score per HR, but not all pitchers allow them at this rate (some justifiably, some as a result of luck). R/HR tells us how many runs actually scored per home run allowed while xR/HR tells us how many runs should have scored (the process for this is a little complicated, but I’d be happy to explain for anyone interested).

Home Run Runs per Fly Ball (HRR/FB) and expected Home Run Runs per Fly Ball(xHRR/FB): Absolutely my favorite of this new crop of stats. A mixture of HR/FB and R/HR, HRR/FB tells us how many runs scored on home runs per outfield fly. xHRR/FB, naturally, tells us how many should have scored. You can consider this a super-powered HR/FB since it not only accounts for how many HRs are allowed but also the total damage done by the HRs, which is what truly matters. Ten solo home runs do just as much damage as five two-run homers, which is something HR/FB doesn’t capture on its own.

Run Support (RS) and xRun Support (xRS): These two stats are just what they sound like. Run Support is the number of runs that a starting pitcher’s offense scores in games that he pitches. xRun Support is the number of runs per game the pitcher’s team scores in all games during a season. Since pitchers have little influence over how well their offense performs in games that they pitch, we should expect the offense to perform at its usual level each time the pitcher takes the mound.

Bullpen Support (BS) and xBullpen Support (xBS): Very similar to the Run Support stats. BS measures how well the pitcher’s bullpen performs in games he pitches and xBS measures the bullpen’s performance during all games.

xWins (xW): While many fantasy analysts call Wins a fickle stat — and they’re right — they aren’t wholly unpredictable. Axioms like “don’t chase wins” or “draft skills” are thrown around often, and while one can be successful by simply following this advice, I feel as though we can do a little bit better. And if we can do better, why shouldn’t we?

Essentially, xW uses Bill James’s Pythagorean Theorem to estimate the expected number of games a pitcher should have won. Using this formula, I plug in the pitcher’s LIPS RA (weighted by his IP per game), his xBS (weighted by the IP the starter doesn’t pitch per game), and his xRS.

This gives us the number of games the SP’s team will win on days he pitches, and from there we calculate the percentage of those games he should get credited for the Win based upon how deep into games he goes (pitchers who last into the eighth inning are far more likely to receive a win than those who only last four or five innings — there’s more time for his offense to score runs. The small problem here is that unlucky pitchers won’t go as deep into games as they should, and visa-versa for lucky pitchers, but I haven’t accounted for this yet).

### Concluding thoughts

Now I’m not saying that all of these stats are perfect, and they all assume randomly sequenced events (which may or may not be a 100 percent fair assumption) but I do think that they largely serve our purposes and are certainly better than making mental estimations (as we all currently do) or simply assuming everyone will be league average. Again, if you have any questions, absolutely feel free to let me know. Tomorrow, be on the lookout for an article centered around Ricky Nolasco that will make use of these stats, so you can see them in action.

### Prior work done on the subject

EDIT: Thanks to Will Larson for bringing to my attention that prior work has been done on some of these topics. Will created his own versions of xW, xBABIP, and xLOB% that can be found here.

THTF’s own Paul Singman also did work on the link between BAA and LOB% here.

David Appleman also created a basic xBABIP formula here.

0000
« Previous: The nickname game: all nicknames all the time
Next: Historic Comparables (Volume 2) »

1. Andrew said...

I’ve been waiting a long time for those first three, especially.  That said, I’m waiting for further refinement of HR/FB% rather than assuming that all pitchers regress to the mean equally.

2. Josh said...

Formulas would be *super*.

3. Skip said...

Derek,

I missed “Advanced Baseball Stats 101”… do you have a similar guide, or short summary page, for stats such as BABIP, HR/FB, etc?

4. dan said...

Will these stats be posted/updated somewhere?

5. Guy said...

Awesome. Can’t wait to see what you do with this.

6. Cubs Stats said...

Very interesting, Derek. I very much like where you’re going.

Also, I heartily second Josh’s request for formulas.

7. Dale said...

Once again Derek you make this one of the best sites, great post !!

8. Dan Turkenkopf said...

@bender:

The THT one is HRs per fly ball, the ESPN is just home runs.

So the THT one is the one closer to what Derek is identifying here with xHR/FB.

9. Will Larson said...

Derek, we exchanged emails about this last year. I asked you if you wanted me to write about these stats and you declined. You need to cite my work, especially with regard to xLOB, xBABIP, and xW. I shared my work with you in good faith.

Google “luck adjusted pitching” and you’ll see my work as the top search result.

10. Ryan C. said...

I am familiar with Will’s work, use it on occasion, and recall a conversation I had with him some months ago regarding his lengthy correspondence with you. This is gross plagiarism and an obvious theft of intellectual property.

11. Will Larson said...

Derek,

Thank you very much for your thoughtful response. In the byline at the bottom of your article, I see that you’re 22, and probably don’t have much experience with academic research. You do great work here on this site, but you need to learn some of the rules of research and intellectual property.

Let’s talk about this for a second: ”  I can assure you I came up with these things independently, but it is generally good practice to cite prior work done in a particular area.  But just because David Gassko comes up with LIPS ERA or Graham MacAree comes up with tRA – which have a similar premise to Voros McCracken’s DIPS – doesn’t mean that they grossly plagiarized or stole his intellectual property.  Heck, Clay Dreslough came up with DICE around the same time as Tom Tango came up with FIP (if memory serves), and the two are nearly identical.”

It is ESSENTIAL that you cite prior work if you built on their methodologies. It is best practice to reference ALL of them somewhere in your article; in a list at the bottom is good enough. If you look at anything due to patenting or publication, it is against the law to not do so. Unfortunately, you don’t have a patent examiner who will fill in missing citations for you, so you need to do this yourself. Because THT is a for-profit site, you are directly profiting from others’ prior work and intellectual property. This is fine, but citation must be given. (Plus, from a science perspective, citation is the best way to actually improve our knowledge on the subject.)

Now, on to my issue.

1) we had correspondence about my advanced metrics on LOB%, HR%, and BABIP last year. 2) after this occurred, several months later, you published under your own name metrics that are nearly identical. 3) I coined the term “luck adjusted pitching” and you used terms like “pitcher’s luck” and “luck adjustment.”  4) I used regression methodology, as did you.

Imagine you’re in my shoes. You come up with all of these cool metrics, publish them on your web site and approach THT about writing articles about them. Next, a few months later, nearly identical versions of your metrics end up on the site under someone else’s name.

I realize it was probably just an oversight on your part not to cite my work. However, you (whether or not you like it) are now a researcher for profit. It is therefore your necessity to cite others’ work. Ignorance is not a defense, unfortunately. Common practice is for a citation to be recommended and accepted by the author if reference is omitted.

Now, on to what I want out of all of this. I’ve never planned on making any money out of all of this. Frankly, I just put my metrics out there for someone to find interesting and improve on—which is exactly what you’ve done! Kudos to you! It is now your duty as a researcher to cite my work and any others’ whom you build on. I would recommend you reference David Appelman as well, at http://www.fangraphs.com/blogs/index.php/expected-babip-for-pitchers/

These citations belong somewhere in your article, and if these stats ever make it into a database, your article here should be referenced in that glossary. That way YOU get credit when someone uses your work, and they can follow the paper trail back to me and David, and Tango and Gassco and all of those other innovators who you will also put somewhere in your article.

Anyway, best of luck to you. You do great work, and I look forward to what’s next from you.

—Will

12. Will said...

What I think you really sharply pointed out is that park effect is not so much nonexistent as it is WAY overstated. How else could Jimenez and Marquis be amongst the 10 lowest SP in HR/9?

More important than each being a Rockie is that they are 3rd and 4th lowest in SP FB%. And if you look closer at Marquis, for example, every year from ‘04-‘06, his FB% and HR/9 both rose, and every year from ‘07-‘09, they both fell, all the while pitching for three different teams.

A question, though: what is it that makes this example (Marquis), see the HR/FB% fall each and every year he has been a starter? I can’t find a single other stat of his that has such a consistent trend…

13. Derek Carty said...

Thanks for the kind words guys.  Before I answer most of the questions, though, let me address Will Larson and Ryan C.

First, Will, you have my apologies if this seems to overlap with some of your work.  I can assure you no foul play was intended.  Before we start throwing around terms like “gross plagiarism” and “an obvious theft of intellectual property,” though, we should probably understand the two methodologies better.  After reviewing Will’s, I can say that we are definitely doing different things (in most cases), even if there are some similarities.

xW: We both use pitcher skill and run support, although I’m using ‘expected’ versions of both while Will uses actual.  Also, for anyone who has read my work over the past several years, I have long said that if we’re trying to project wins, 1) run support and 2) the skill of the pitcher are the two most important factors (in that order).  I don’t believe this kind of thinking is anything groundbreaking – it’s basic logic that pitching and offense have a large impact on who wins the game.  I also include bullpen support in mine, which Will’s doesn’t.  Furthermore, I use the Bill James’s Pythagorean Theorem to calculate mine while Will uses regression.  Finally, if need be, I have e-mails dating back over two years ago with David Gassko discussing different ways to create an xW stat (these predate Will’s work).

xBABIP: Similarities include use of GB%, OF FB%, and IF FB%.  Mine also makes use of LDs and takes a step further by normalizing LD%.  As with xW, Will uses linear regression whereas I do not.  Will simply uses the percentages in his regression equation whereas I calculate the actual hit percentages on each type of batted ball and create expected hit data from there.  Finally, I have been utilizing a stat called DIPS WHIP since before Will’s work came out, and all my version of xBABIP has ended up doing is strip the BABIP portion out of that stat.

xLOB%: Here there is a lot more overlap, and I probably should have referenced Will’s work (though its exclusion was purely unintentional – in all honesty, I hadn’t even remembered it).  Still, it is not identical.  He uses K% and BABIP in his regression equation.  I use BAA (which is a combination of K% and BABIP but a little more theoretically sound, in my opinion) and BB%.  Still, they are similar, and you have my apologies.  I will amend the post.  Now that my train of thought is on this, I actually recalled reading an article about predicting LOB% somewhere a couple years ago, and digging around, found it here: http://www.mlbfrontoffice.com/2008/06/safe-or-stranded-on-base-part-i.html, so I probably should have included that too.  Turns out it was written by our own Paul Singman, so I certainly didn’t mean to rip off anyone’s ideas here.  References probably should have been in place, though, and they are now.

xHR/FB: This is nothing like Will’s aHR9, so there should be no confusion here.

To set the record straight on a couple other smaller things, I never had a “lengthy correspondence” with Will.  My only correspondence was in the comments section of the referenced article, and from my own comments in that article, it’s clear that I didn’t agree with everything Will was saying and that we had our own independent thought processes.  I’d also said in the comment section that I had independently developed my own preliminary versions of xBABIP and xLOB%.  They were still in developmental stages at the time (there were some different things I was contemplating and messing around with), but what I’ve presented today are essentially improved/cleaned up versions of these stats.

Again, I offer my sincerest apologies for any misunderstandings.  Anyone who has read my work over the years or knows me personally knows that I would never intentionally rip off someone’s work.  Never.  I am constantly coming up with new stats and new ways of thinking about things, and I think some of the ideas presented here (some of which overlap with some of Will’s thoughts) are good ideas.  As with all good ideas, it’s certainly possible to stumble upon them independently.  I will add a bit to the article where it merits it — I’m not out to steal anyone’s thunder or take credit for something that I didn’t do.  I can assure you I came up with these things independently, but it is generally good practice to cite prior work done in a particular area.  But just because David Gassko comes up with LIPS ERA or Graham MacAree comes up with tRA – which have a similar premise to Voros McCracken’s DIPS – doesn’t mean that they grossly plagiarized or stole his intellectual property.  Heck, Clay Dreslough came up with DICE around the same time as Tom Tango came up with FIP (if memory serves), and the two are nearly identical.

Hopefully this clears things up, and again, I apologize for the misunderstanding.

14. Derek Carty said...

Alright, on to some of the questions, but first, I don’t think the Nolasco post will be ready by tomorrow.  Look for it on Wednesday, and then probably a third post utilizing these stats on Thursday or Friday.

To all those asking, I will be making available the full set of numbers some point soon.  More info on that later, though.

Skip,
I’d recommend checking this out to start familiarizing yourself with these kinds of stats: http://www.hardballtimes.com/main/fantasy/article/stats-reference/  They can be so powerful once we understand them, and I’m always happy to help anyone who wants to understand them (especially those who are new to things).  That article is a little older, but it should still hopefully lay out the basics.  If you have any additional questions after reading it, just let me know.

15. Will (Hatheway, not Larson!) said...

Will Larson – as an academic myself, and as a fan of this work (but not, as with you and Derek, someone with the skills to develop it), I applaud your response.

What has really disturbed me (and this in no way includes Derek, who himself comes across as even-tempered, even if you two disagree) is that some sabermetric-minded authors are responding in ways that really don’t do justice to the professionalism of the analyses themselves. There seems—sometimes, not even most of the time—a defensiveness that is really just upsetting to me.

I like that Derek gave you his honest response, and that you put your emphasis on an equally honest attempt to help make his and others work more grounded in the more established areas of analysis that this type of work is certainly entering into.

16. Derek Carty said...

bender,
To add to what Dan said, the easiest answer is because park factors are all created using different methods.  ESPN uses single year park factors, which quite honestly aren’t very good.  Sure, they’ll tell you what *actually happened*, but they won’t be very useful for predicting the future (which is what we care about in fantasy baseball).

Dan’s factors will be better than ESPN’s because he uses multiple years worth of data.  The general rule of thumb is that it takes three years for PFs to stabilize, although that is *very* general and can differ greatly depending on what stat you’re looking at.

The factors that I use, I believe, are better still.  They are essentially David Gassko’s that he introduced here: http://www.hardballtimes.com/main/article/batted-balls-and-park-effects/  That was done two years ago, though, and I’ve created an updated set through 2009.  Mine included four years worth of data and include regression to the mean, an important component that I’ve never seen in park factors before David’s.

I also weight each year the same.  Dan weights them differently, but for me, I think we’re better off not.  If the park stays the same from 2006 to 2009 and all that differs is the sample of games that occur in any particular year, why should 2009 be any more important than 2006?

Just my reasoning, although I’d be curious to hear why Dan used different weights (he said he just copied the method from Baseball Reference, so maybe that’s the only reason why, but if you think that’s a better way to do it Dan, I’d love to hear your reasoning).

17. Derek Carty said...

Will,
On Marquis, you can probably chalk it up to regression and random variation.  The only reason the trend has a chance to begin is because it started high, and any time a stat is too far removed from the mean it should be expected to heavily regress.  Marquis’s did from 2004-2006.  Then it went the other way, which I think could just be due up to random variation.  If you look at his career HR/FB, it’s right in line with league average at 11.8%.  He’s had years where it was close to his career average and years where it was far removed; it just so happens to form a pretty pattern.

Perhaps there’s more to it than that, but without deeper analysis, we’re generally better off not trying to read too far into things like this.

Very interesting to note, though, so thanks for bringing it up.

18. Will H. said...

Derek -

Thank you for responding to my query, and you are right: Marquis’ career avg. is, as you said, league average “even though there is a pretty pattern” to his individual years’ marks.

Getting ahead of myself (and I sure don’t expect any reply in this thread), I wanted to post another question regarding your next subject, since this neophyte (um, me) felt his first sure thing was that Nolasco would be my draft-day steal this coming season. Now, I don’t know which way you’ll go, but I initially flagged him as a buy because my amaturish analysis discovered that a combination of > avg. BAPIP and < avg. xFIP and tRA* gave a pretty good set of candidates for improvement (relative as well to ADP) the next year.
But, having read your cautions against just accepting such measures as sure-thing luck indicators, I looked at him again. Are these potential problem signs?:

He throws a lot of SFs, but few FBs and CFs (of the five highest SF% starting pitchers, four ranked in the top-20 in HR/FB%, with only Zambrano—with an anamolous 75% of his other pitches being fastball-varients—having a low rate.

Taking those two (Zambrano and Nolasco) further, I also saw that, in addition to having a plus FB versus a minus one, Zambrano threw very few pitches in the zone while Nolasco has typically thrown a ton.

So, I guess I am now concerned that we shouldn’t expect a pitcher who is at once flyball-oriented and, at the same time, reliant on off-speed stuff that, moreover, ends up more often than not in the zone, to do better because popular metrics point to him as having been, so far, unlucky…

19. Derek Carty said...

Will Hatheway,
Thank you for your input.  I can’t speak to what other analysts in the field are doing, but for me, I would never intentionally try to take credit for someone else’s work.  This here was an honest misunderstanding – I didn’t even realize that I was building on what others had done, though looking back, Will clearly had been doing similar things that were brought to my attention; I just didn’t recall them – and I appreciate Will Larson speaking up.  As you noted, Will (Larson), I am relatively young and don’t have much experience with academic writings.  I do usually try to link to other work that’s been done in an area if I’m aware of it or when I’m knowingly building upon it, so I apologize for the oversight here.

I do get where you’re coming from and, from what I now understand, that in academia it’s proper to cite prior work that’s been done on a particular topic, even if it didn’t directly influence your own work.  I will try to make a habit of this going forward.

Anyway, hopefully we’re all good here.  I’ve added the citations at the bottom (including the David Appelman piece), and again, I apologize for the misunderstanding.

20. Derek Carty said...

Interesting, Dan.  I’m kind of surprised that Colin didn’t think it was necessary, although I bet the context he said it in was important.  I think with just about anything, ever, in life, what we actually see is just a sample of the true nature of that thing.  In this case, we see a one-year (or four-year) sample of how a park affects various stats.  To get a truer estimation of these effects, I believe you should regress to the mean.

If you really wanted to, theoretically, you could regress any event in life to the mean (given that you know what that mean should actually be), and this is especially true in baseball.  There was actually a good article by Sal Baxamusa here (http://www.hardballtimes.com/main/article/radar-gun-readings-sabermetric-building-blocks/) that discussed the importance of regressing things to the mean (even something as simple/physical as fastball velocity, in his example).  It’s just that some things need to be regressed more and others less.

If I were to guess, I would guess that Colin meant that he didn’t think regression would have a significant effect on the numbers, or that he didn’t believe they’d need to be regressed very far.  For a park like Citi or New Yankee Stadium, though, where we only have one year, it absolutely does.  As an example of this, unregressed Yankee had a 1.33 HR/FB.  Regress it, and you get 1.21.  That’s a big difference.

As an example from a park with four years of data (instead of just one), Milwaukee had a 1.088 BB park factor.  BB park factors are very unstable, though, so it got regressed all the way to 1.028 (also, Colin was likely only talking about HR/FB factors, which are definitely more stable than BB park factors).

As to weighting, I’m still not convinced that 2009 is more relevant than 2006 when we’re talking about park effects for a park that has remained exactly the same during that time frame.  If everything is held constant, all we’re seeing in any individual year is simple random variation.  It shouldn’t matter which happened most recently.  You could maybe make a case regarding weather, that 2009 weather is a better predictor of 2010 weather than 2006 weather is, although I’ve never seen a study on this and don’t know if it’s true (and if it is, to what extent).

Also, I should note that the factors I use don’t lump both Old Yankee and New Yankee together – they are run as separate parks.  Any time a team changes parks, it gets a new factor (although small changes to an existing park get ignored – some would disagree with this approach – but that’s mostly a matter of me not having a comprehensive list of tweaks made to parks and also not knowing the best way to account for them).

Good discussion, though, Dan.  I love talking these kinds of things out.

21. Derek Carty said...

Ah, re-reading your post, Dan, it looks like I misunderstood your point about Yankee Stadium – that it would alter the ‘Away’ environment for all the other stadiums.  This is certainly true, although I think 5/3/2/1 seems awfully heavy to account for this.  I’d need to look into it more, but I think the effects would be negligible, or close to, for most parks.

22. pounded clown said...

“Now I’m not saying that all of these stats are perfect….”

Aren’t statistics by definition imperfect?

interesting stuff

23. Dan Turkenkopf said...

@Derek

I weighted my park factors for a few reasons.

First, I think most people do and I was following the crowd.

Second, I think most people do it because what happened more recently is more relevant.  For example, bringing in new Yankee Stadium is going to reduce all the other park factors.  Giving more weight to last season with Yankee Stadium is more correct than saying it’s the same as every other season.

On another point, I asked Colin Wyers about regressing my park factors to the mean and he didn’t seem to think it was necessary.  I’ll be interested to see how you regress the numbers.

24. Matt M said...

Can you post the formulas used?

25. Derek Carty said...

The problem is that most of these don’t really have formulas, per se.  I’ve create them with a series of SQL statements that draw from a bunch of different databases and tables.  Instead of trying to simplify them into statements, I think it’ll be easier just to run them myself for players (especially since a lot of the necessary data comes from Retrosheet, which is not the easiest thing in the world to work with).  I’ll have some more info on how I’ll be releasing the data soon.

26. Josh said...

Derek,

Some of us have Retrosheet databases ourselves, and it would be good to have others check and attempt to improve on the work.

A file with the SQL queries, or an outline of how they are generated would be really useful.