NHS Patient Waiting Times, Part 3: Weighting the Formulas

12 Feb

Welcome back to the next installment of spreadsheet cubism, in which the same data task is imaged from multiple formulaic vantages.

We’ve already submitted the NHS patient waiting data to two such looks, and here comes the third, an arrestingly different one; arresting, both because of its startling simplicity, and because its workings have been hidden in plain sight from Excel users for some time.

Again, our interest is in learning the number of patients waiting for an identified number of weeks for treatment in one of 19 different medical specialties (and we’re continuing to work with the IncompProv tab). Our vantage begins to come into view when we select the F3:BG22 range that rectangulates (it’s a word; I checked) the week-waiting numbers, bordered by medical specialty.

Then perform a pair of identical finds and replaces, first on F4:F22 and then on G3:BG3 – or the ranges that carry medical speciality and week-wait headers respectively:


That is, replace every instance of a space among the earmarked cells with an underscore – yes, very much a to-be-explained step.

Re-select F3:B22 and turn next to an old Excel capability to which I’ve probably given rather short shrift, but have grown to appreciate of late – the Create Names from Selection feature, brought to you via the Defined Names button group in the Formula tab:


The default decisions above ascribe range names to every row and column in the selected range, the names coterminous with the labels in the range’s top row and left column – but you’ve probably figured that one out.

Our medical speciality dropdown-list menu remains in place in E1, and we’ll proceed to slot another dropdown in D1, this one comprising the week-wait labels in G3:BG3 (in fact the Treatment Functions Description in F3 likewise names its range, i.e. the medical speciality rubrics in F4:F22, but that name isn’t contributory to the process here). Then enter yet another dropdown in D2, referencing precisely the same range assigned to the menu in D1; and that apparent redundancy needs to be understood, of course (in fact you can simply copy D1 to D2; the menu will be duplicated).

And now, by the way – and this aside is far from incidental – we’ve learned why we needed to substitute the underscore for all those spaces a few paragraphs ago. Excel named ranges must comprise labels of contiguous text, and so when the spreadsheet meets up with a multi-worded header. it insists on exchanging a word-linking underscore for every space when it forges the range names. We thus had no choice but to do the same with the labels in F4:F22 and G3:B3, in order to anticipate and Excel’s range-naming mandate.

Now back to our budding formula. Say we want to learn the number of patients who have waited up to six weeks for treatment in oral surgery. Select that speciality in E1, and select Gt_00_To_01_Weeks_SUM in D1:


Tick Gt_05_To_06_Weeks_SUM in E2, because we’re counting patient numbers through week 6 for the oral surgery specialty.

Then, in a free cell, enter:


Which evaluates to 68,045, the number of oral surgery patients waiting up to six weeks for treatment.

That expression doubtless merits a to-be-explained as well. First, that is indeed a space insinuating itself between the first and second INDIRECT, and not a typo, begging in turn a rather pressing if rhetorical question: where does one find a space pushing its way inside an Excel formula?

You find it here. The space – and again, its functionality isn’t new to Excel – qualifies as an actual mathematical operator, of an operational piece with the traditional go-tos  +, -, /, *. The space performs an act of identification: that is, in its base mode pinpoints a value standing at the intersection of two ranges. (And thanks to Jordan Goldmeier’s and Purnachandra Duggirala’s Dashboards for Excel, which promotes and explains the space operator approach.)

By way of a more straightforward introductory example, consider this assortment of test scores lined by student names and subjects, say in A1:G11:


(Note the collapsed space in the polisci entry, in anticipation of the Create from Selection’s name-underscoring practice.) Dubbing ranges again via the Create from Selection protocol, this unnervingly spare formula:


returns 72, the value that stands at the confluence of ranges Maureen and Art.

The solution starkly pares the standard INDEX/MATCH solution to what is in effect this lookup task; indeed, so lean is the space-operator prescription that one is bidden to ask why it doesn’t predominate among users and commentators. I’m asking, but I don’t have the answer.

Now of course our denser formula departs from the above demo expression. For one thing it packs several instances of INDIRECT into the mix (see our discussion of that function here), because our three contributory dropdown-menu selections have returned merely textual references to the ranges with which we’re working, and these thus need to be synergized into actual, working range citations.

And the


half of the formula empowers it to find all the values dotting the intersections of the oral surgery specialty and all the columned ranges between and including the two we’ve actually identified in the formula; the space operator can do that, too (and note the placement of the parentheses, by the way).

And because the formula has sighted the multiple data points crossing their multiple intersections, the SUM function must gather these into a single total – our answer. Note that the standard INDEX/MATCH lookup can’t do carry out this additive step – at least I don’t think it can.

It’s probably worth your while, then, to learn more about the streamlining efficacy of the space operator. It’s been worth my while – and I’m lazier than you.

NHS Patient Waiting Times, Part 2: Weighting the Formulas

30 Jan

A certain type of spreadsheet bliss attaches to relative ignorance. Know just one formulaic way around a task, and your decision rule requires no deciding: write the formula.

But know at least a couple of ways to get where you want to go, and you’ll need to break out the map and plot your best-course scenario, or at least try to. Last week’s post described one means, driven in part by a teaming of the OFFSET and CELL functions, for totalling the number of patients having to wait up to a specified number of weeks for treatment in an identified medical speciality, those data emanating from the National Health Service spreadsheet upon which we drew in the post. But alternative means toward that end are available; and why you’d make use of this as opposed to that one stands as a good question, the answer to which has a lot to do with the confidence you can marshal toward the approach. Find one formula among the options the easiest to write and you’ll likely be magnetized in that direction – even if in some absolute, textbook-ish sense, some other formula comes best in show for elegance.

In any case we can, in the interests of informed choice-making, review two other formula possibilities, braced by the corollary concession that still others may be camouflaged in the brush. Remember we’re interested in learning the number of patients in a medical speciality who waited a maximum, stated number of weeks for treatment (we’re continuing to address the workbook introduced last week). We can begin to put our second option into play by retaining the dropdown menu of medical specialities in E1 (founded on cells F4:F22) we forged last week (look here for a precis of dropdown menu construction, if you’re new to the idea. You don’t really need to name the range, though, in spite of the linked discussion’s advisory – at least not in our case, as its contents won’t be augmented). Then enter a week-waited number in D2, say 12, and for illustration’s sake select ENT from the speciality dropdown in E1:


Thus we’ve declared in interest in discovering the number of individuals who had to wait up to 12 before receiving ENT treatment. Then, enter this expression, say in H1:


This formula likewise calls for an exposition, needless to say. SUMPRODUCT, Excel’s quintessential off-the-shelf array formula, is perhaps the deepest of the application’s functions, its diffident, user-familiar tip (i.e., it multiplies pairs of values and proceeds to add them all) transmitting the weakest of signals about the iceberg immured beneath.

Here, SUMPRODUCT combs F4:F22 for the medical speciality – ENT – we ticked in E1.  And you’ll observe that the search and find for ENT is pressed without any syntactical resort to the standard, conditional IF; that word is nowhere to be found in the formula. When it finds ENT – in F7 – the formula moves to examine row 7 for the values running across its contiguous, number-bearing cells, in columns G through BG (note too that the F4:F22=E1 phrase is couched in parentheses).

And that sweep through the columns takes us to the *(COLUMN(G3:B3)<=D2+6) piece of the formula. The star/asterisk reminds us that SUMPRODUCT continues to do what it’s been programmed to do –  assign a value of 1 to its successful sighting of the requested medical speciality ENT (a sighting that first imputes the name TRUE to the finding in F7 – and in the Boolean language of array formulas, TRUE is next quantified into a 1). In turn, the other non-complying entries in F4:F22 are deemed FALSE, and incur a 0 as a result. COLUMN identifies the absolute column number of any cell reference; thus =COLUMN(X34) returns 24, for instance.

Befitting its multi-calculation, array formula character, COLUMN(G3:BG3) flags the column number of each of the G3:BG3 entries, asking if any of these equal or fall beneath the value 18, that number a resultant of the 12 we entered in D2 – plus 6, a necessary additive that squares our formula with the fact that the first column we’re inspecting – G – has a column value of 7. Adding the 6, then, to the 12 in D2 – the week wait figure – transports us to the 18th column of the worksheet, R. And R contains the Gt 11 to 12 Weeks data that marks the outer bound of our search. And any column that satisfies our criterion – any week equal to or less than 12 – likewise receives a TRUE/1 evaluation.

Remember again that, convolutions notwithstanding, SUMPRODUCT is about multiplication – and here the 1 assigned F7 is multiplied (remember the asterisk) by all columns in receipt of a 1. All other cells – that is, all the other medical specialties in the F column, and all the weeks in excess of 12 – receive a zero, and their multiplications yield zero and drop out of the formula. The remaining 1’s, so to speak, are multiplied by the ENT values for week 12 and before in cells G4:BG22, and ultimately added – because that’s what SUMPRODUCT does.

Again, we’re counting the number of ENT patients needing to wait up to 12 weeks for treatment, and in this case I get 190,480. Type a different week number in D2 and/or select a different speciality from the dropdown menu in E1, and the sum should respond accordingly. And because SUMPRODUCT is a homegrown Excel function, it stores itself into its cell via a simple strike of the Enter key – and not the storied Ctrl-Shift-Enter in which customized array formulas are obliged.

Hope that’s halfway clear – though halfway probably won’t help you write the formula when and if you need to write something like it some other time. This application of SUMPRODUCT is a good deal more thought-provocative that its simpler implementations, but if it makes you feel any better I had to think about it, too.

The point again is that SUMPRODUCT has delivered us down an alternate formulaic route to our answer, and whether it’s to be preferred to the OFFSET-mobilized variant we explored last post remains a good question.

But there are still other possibilities.

NHS Patient Waiting Times, Part 1: Weighting the Formulas

22 Jan

Divide finite resources by a spiking demand and the quotient shrinks, a mathematical truism all too pertinent to the UK’s National Health Service nowadays. Evidence of a system in crisis commands the country’s media and political attention, and of course data contribute integrally to the debate. One testimony – an NHS cataloguing of hospital treatment waiting times distributed by hospital and medical specialty – is here:


The workbook’s front end comprises a Report tab, whose dropdown menus synopsize patient waiting time data for any user-selected hospital and treatment area. You may want to trace the contributory formulas, and note the lookups performed by the OFFSET function, about which we hope to say a bit more a bit later. Note as well the section topped by the Patients Waiting to Start Treatment reference data, vested in the IncompProv sheet; information about patients who completed their what the NHS terms their pathway and started treatment is displayed by the two recaps that follow, the first keyed to the AdmProv sheet, the second to NonAdmProv.

Those sheets – that is, the ones bearing the Prov term – are all comparably organized, each earmarking and cross-tabbing its first 19 records by medical speciality aggregates and waiting times, these expressed in one-week intervals. The next, 20th record then vertically sums the per-week totals; the remaining records break out the data by individual hospitals.

Those 20 aggregating rows loose a familiar complication upon the data sets, at for the pivot tablers among you. As per previous discussions, the rows in effect double-count the patient figures, by duplicating the hospital-by-hospital totals. And again, for the pivot-table minded, the weekly wait fields could have been more serviceably sown in a single field, for reasons which recalled numerous times.

But those impediments don’t daunt all efforts at analysis. You’ll observe the GT 00 to 18 Weeks SUM fields posted to the far reaches of the PROV sheets, these tabulating the numbers of patients obliged to wait up to 18 weeks for the respective attentions described in the sheets. I began to wonder, then, if an efficient formulaic way to measure patient waits for any number of weeks could be drawn up, and I came up with two (and there are others).

That is, I want to be able to learn for example how many General Surgery patients had to wait up to 14 weeks for treatment, by empowering the user to enter any medical specialty and week-wait duration (I’m assuming here that the wait is to be invariably measured from the inception of the wait – 0 weeks).

Assuming I’m looking at the IncompProv sheet – though what we do there should transpose pretty effortlessly to the other Prov data – I’d begin by instituting a dropdown menu of medical specialties, say in E1. I’d continue with another dropdown, this one unrolling the wait headers in set down row 3 (that is, the dropdown data – and not the menu itself – are to be found in row 3)..

I’d next select F3:B22, thereby spanning all the specialty aggregate names along with the week-wait values data. While the selection is in force I can muster an old but valuable option, Formulas > Create from Selection in the Defined Names button group. That run-through takes me here:


Click OK and each row and column in the selection receives a range name coined by the label to its left or immediately above its column (note that labels themselves are not enrolled in the range, and Excel’s reference to values in the above may mislead you. The ranges here are all textual). And by way of a final, preparatory touch, I’d consecutively number the weeks right above their columns in row 2, assigning 1 to 0-1 Weeks, 2 to 1-2 Weeks, and so on.

Remember we’re attempting to tally the aggregate number of patients awaiting treatment in a selected speciality for from 0 to a specified number of weeks. Per that agenda, I’ll enter the number of weeks – that is, the maximum specified week wait – in F2. Let’s say I enter 15, and then proceed to click on Ophthamology cell F8. I’m thus instructing the budding formula to calculate the number of patients who awaited treatment in that speciality for a period of up to 15 weeks. Next I’ll enter the formula, say in E2:


I sense an explanation is in order, so here goes. In the final analysis, of course, the above expression sums patient numbers for the given specialty across a variable number of weeks – in the example, 15; and the formulaic potential to confront those variables is realized here by the OFFSET function.

OFFSET offers itself in two syntactical varieties, one requiring three arguments, the other five. The lengthier version, applied here, serves to identify the coordinates of a range, which will in turn submit itself to the SUM. In our case, the first of OFFSET’s arguments gives itself over to the INDIRECT function, itself performing a cell-evaluational role upon the nested CELL(“address”) expression. CELL(“address”) will, upon a refresh of the spreadsheet (triggered by the F9 key or some data entry elsewhere on the worksheet), return the address of the cell in which the cellpointer currently finds itself. Thus, for example, if you enter =CELL(“address”) in A12 and proceed to enter a value in C32, the function back in A12 will return $C$32 – the cell reference, not the cell’s value. But $C$32 is a textual outcome, i.e., not =$C$32. INDIRECT then restores a bona fide cell-referring status to $C$32, and reports the value currently stored in that cell.

So what does this have to do with our task? This: click on any medical specialty in F3:F22 and refresh the sheet. The address of that specialty populates OFFSET. For example, click on the name Ophthalmology refresh, and OFFSET will turn up F8, for our purposes the first cell in the range we’re striving to define. The two zeroes that follow tell OFFSET to in fact to define the range precisely at the F8 inaugural point – that is, not to move any rows or any columns away from that F8 range anchor. The 1 next instructs the formula that the imminent range comprises but one row – the row on which the Ophthalmology data are resting; and the F2+1 measures the range’s width in number of columns – in our case 16, or 15 plus 1 – plus 1, because the data for week 15 stand in the 16th column from the medical speciality in which we clicked to initiate the formula.

The answer in this particular case, then, is 330,472, counting of the number of ophthalmology patients who had to wait up to 15 weeks to receive treatment; and you could divide that figure by the Ophthalmology patient total – VLOOKUP(CELL(“contents”),F4:BH22,55,FALSE) – to learn that about 86% of the patients were waiting up to 15 weeks for treatment. So again, by clicking on Ophthalmology in F8 and refreshing the spreadsheet, the formula is put to work.

But there are other formulas that will work, too.

The Guardian’s Top 100 Footballers: Rating the Rankings

8 Jan

You like to window shop, I like to Windows shop; and my curiosity-driven gaze through the virtual panes shone its beam on yet one more data set devoted to the ranking of athletes, this time of the football/soccer genus.

Wheeled into view by the Guardian in Google spreadsheet mode and attired anew here for you in Excel:


the data sort the results of the aggregated, columned (P through EI) judgements of 124 sportswriters, each of whom nominated up to 40 players assessing them a point evaluation ranging from a maximum of 40 downwards (you may want to consult Sky Sports’ differently-ordered top 100 here).

Heading the list – which highlights the top 100, though 380 players were presented to the judges – and unsurprisingly so, is Portugal’s. and Real Madrid’s. Cristiano Ronaldo, putting 68 points worth of distance between himself and the no-less-unsurprising Lionel Messi, he of Argentina and Barcelona. That three of the rankings’ top five players populate the same Barcelona front line. even as that team merely holds down second place in its league. is the kind of sporting discrepancy sure to give the sages something to think about, but I’m a spreadsheet guy. And the fact that only Ronaldo and Messi appeared on every sportswriter’s ballot – and that, as a consequence, some rather formidable players found no place at all among soe writers’ top 40 – is perhaps equally extraordinary. Indeed – the Algerian and Leicester City star Riyad Mahrez won one first-place vote – even as he was completely shunned by 16 other writers.

But what of the spreadsheet? Start at the beginning, with its header data walking on the sheet’s ceiling at A1:O1. Those identifiers need to be lowered into row 4, hard by their attendant field data; and by extension, the hyperlink to the judges’ names and rules for assigning rankings stretching across the merged cell P3 must be moved, or its contiguity to the dataset will commit an offside against any pivot table building from the records against the perpetrator.

I’m not sure why the sheet’s numbers were left aligned, either, though I’m not pressing any charges for that formatting decision. And because it’s clear that the Guardian has player birth dates – otherwise, the Age at 20 Dec 2016 data could not have been furnished – exactitude might have been slightly better served, and pretty easily at that, via the YEARFRAC function, and an age calculation extended to a couple of decimal points, e.g. 27.83.

But if all that qualifies as a nit-pick, the rankings themselves in column A could be more justifiably questioned. Players with equivalent ratings, e.g. Alex Teixeira and Anthony Modeste at 156, were enumerated thusly: 156=, an expression that strips the number of its quantitative standing. Why not assign a 156 to each player instead, as do the women’s and men’s tennis rankings we reviewed in our immediately previous posts?

Moreover, some apparently identical scores appear in fact to have been differentiated. Raphaël Varane and Serge Aurier both check in with 34 points and five sportswriter votes cast, the latter a rankings disambiguator for the Guardian; yet Varane earns a ranking of 118 to Aurier’s 119. The same could be said about Omar Abdul Rahman and William Carvalho, invidiously niched at 133 and 134. In any event, if you do want to numerate all the rankings, say by figuring average ranking by country and/or team, then point a find-and-replace at the data, finding every = and replacing these with nothing.

I’d also withdraw the blank, colored row 105 that hems the top 100 from the lesser-rated crew beneath; while the row means to delimit and frame the footballing elite, per the Guardian’s story, any analysis of the larger cohort of course would need to unify the data set – and that means dismissing its blank rows. In that spirit, then, you’d also want to disavow row 129; whatever informational service its text may perform, it isn’t a ranked player’s record. I also can’t explain why some of the country and club entries, e.g. cells G207 and H219, appear in blue, or why Antonio Candreva in row 213 is described as Italian when his countrymen are identified with Italy. In addition, Nani’s (row 83) nationality is ascribed to Portugal, but with a superfluous space, as is Paul Pogba’s France (row 21).

Also, the formulas cascading down the Up/down field in B that meter a player’s current movement through the rankings from his 2015 score could have simply read =C5-A5, for example, sans the SUM function and its parenthetical braces.

But note as well that players who went unranked in the preceding year received a hard-coded NEW classification for 2016 that in fact could have been subsumed formulaically, e.g.


You’ll also note that the formulas in O compiling the number of a player’s first-place votes look like this:

=COUNTIF(P5:EI5). “40”)

The quotes are superfluous, and I confess to surprise that the formula works. The entries in P5:EI5 are values, after all, not labels. But work it does.

And for another matter that warrants our scrutiny, consider the Highest Score Removed field in L. The Guardian determined that any player’s highest rank – or at least one instance thereof – be stricken from his final score as an outlier. That sort of decision rule isn’t unprecedented – figure skating and gymnastics judging protocols often drop highest and lowest scores – but in those sports the extremes at both the high and low end are ignored; the Guardian only points its thumb down at the high – again, just one high, even if others have been issued to the player. Ronaldo’s 63 first-place votes are thus contracted to 62, but those 62 of course exhibit precisely the same score as the ostensible outlier.

Moreover, and unlike other juried events, the number of judges who decided to score a given player here is very much a variable. Thus we need to account for the 76 players whose final score of 0 belies their receipt of an actual, if solitary, vote. That vote, of course, was barred as an outlier, leaving the player with nothing, so to speak. Along these exclusionary lines, it follows then that players named by exactly two sportswriters incurred the loss of their higher score – even though one could challenge the insistence that these are somehow more outlying than their other, lower score.

The matter of how to dispose of score extremes has been disputed (see this mathematical exploration)  – it would be difficult, for example, to imagine an even halfway-well-intentioned teacher dropping a student’s highest test score (though the classroom scenario features one judge of many test performances; in figure skating many judges arbitrate one performance) – but in the interests of pressing on we could, for example, learn something about the larger aggregate picture by approving a data set comprising the 254 players who received at least one Raw Total point, , i.e. prior to the removal of their highest score. If we’re provisionally satisfied with the makeup of that cadre, we could for starters simply pivot table a count of players by country and country raw point total:

Row: Nationality

Values: Nationality (by Count, of course; the data are textual).


RAW TOTAL (again, by Average, formatted to two decimals and with a comma)

I get, in excerpt:


We see that Spanish players win appearance honors, but among the more productive countries Argentina claims the highest average player score, and by quite a margin.

And if you’re wondering, there’s one American player in there, even as he didn’t make the screen shot cut above – Christian Pulisic, who plays for the German Borussia Dortmund squad and is ranked 138th, with 25 raw-totalled points. But he’s only 18 years old – and if we rank the players by age, he comes in at number 2.




Birth Month and Tennis Rankings: Part 2

30 Dec

We could precede any look at the birth-month data for women tennis players with a couple of variously obvious questions. The first asks, most evidently, how these data will compare with those of the men’s cohort. The second asks about those very suspicions; that is, why we’d bother to promote the sense that the women’s results might depart from the men’s. Why should they?

But we can’t begin to suspect without seeing the data, and those offer themselves up to us on the Women’s Tennis Association site here; but I’ve prepared a neat pre-packaged version here:


Those 1300 or so rankings (1313 in fact, that less-than-round number presumably reflective of equally-ranked players) come complete with player country of origin and (real) birth dates, just what we need (note however, that the player names have been freighted with a superfluous space that you’ll need to trim should you work with those data).

But I digress. Why, after all, might the women’s birth months vary from the men’s? A popular surmise maintains that women players are typically the younger, a nugget of popular wisdom worth mining, as it turns out; ranked women exhibit an average age of 22.52, while the men figure to 24.27. But a birth-month gender divergence thesis would leave popular wisdom out in the cold.

So let’s see. Paralleling the men’s inquiry, we could pivot table the women’s data thusly, for starters:

Rows: DOB

Values: DOB (Count, then % of Running Total against the DOB baseline). Turn Grand Totals off.

I get:


Again, a first-half-of the-year imbalance emerges, albeit somewhat less pronouncedly than the men’s 55.90%. If we pitch Rankings into the Columns area and group these by bins of 100, we get in excerpt:


Here the first-half predominance is striking, though again the universe’s 100 cases might throw up some interpretive cautions. If, per the men’s survey, we next group the rankings by tranches of 500:


(Remember, and unlike the men’s rankings, the women’s data comprise only 1313 players; and as such the 1001-1500 bin contains 312 records). We see a slow increment in first-half percentages across this coarser grouping, but the edge holds in each case.

For the American contingent, a country Slicer can again be put to work, to recreate last week’s result here for women:


Unlike the men, a US first-half effect does registers for the 114 women from the States.

I’m not sure what, if anything, that means –  particularly given the modal birth month for the American women of February – but we’re left to consider the import of the larger findings (while remembering of course that the first half of any year comprises fewer days, too); and again, the notable persistence of the first-half birth-month margin sets its explanatory challenge before us, and toughened by the data’s cosmopolitan demographics. 84 countries have provided the ranked women, and that variety doubtless bespeaks diverse recruitment and instructional programs, all aggregating to the above distributions. And the rough likeness of the men’s and women’s birth-month distributions may simply affirm a gender-invariant character to those programs these days. In any case, if you’ve been looking for some journalistic marching orders, perhaps you’ve found them here.

Now it was during these speculations that another means for assaying the birth-month phenomena came to mind. Instead of breaking out births by months – a wholly sensible recourse, to be sure – it occurred to me that a birth-month index of sorts could be developed by determining the percentage of days of any particular birth year elapsing from January 1 of a baseline year, divided into a player’s actual birth date. Thus, a player born around July 1 – more-or-less the year’s halfway point (there are leap years in the chronology, of course) – would exhibit a birth fraction, as it were, of .5.

The idea in turn would be to average all the players’ birth fractions, with the intention of learning how near or far from .5 the average might veer. A relatively low average – e.g. .45 – would signal a cohort average birth date prior to July 1, and thus offer another, finer reading of the birth-month data. By way of contrast, if one breaks outs births by month – as we have to date – then births on June 1 and June 30 are to be understood as equivalently June-occurring – even as the former date holder is of course older.

With that program in mind I can move into column H, title it YearPercentage are something like it, and enter in H2:


Then of course you’ll copy down the H column.

(Your formula labors here and elsewhere may profit by subjecting them to a durable, onscreen look in a free cell, by referencing the formula with the FORMULATEXT function.)

What is this formula doing? Something like this: it calculates the number of days a player’s birth date is distanced from January 1 of her birth year, and divides that number by the number of days appropriate to that year. In the case of the highest-ranked Angelique Kerber, born on January 18 (remember to send her a card) – the 18th day of the year: if we divide 18 by 366, (the day count of the leap year 1988), we get .049, the proportion of the elapsed year.

So let’s try to detail the workings of the formula.  The DAYS function counts the number of days spanning two dates, beginning here with E3, or Kerber’s birthday. The DATE(YEAR(E3),1,1))+1 segment returns January 1, 1988, by grabbing the year from E3, and then  posting 1 and 1, or the first day of the first month. Equipped with those three identifying bits, DATE then realizes the specified date, with the +1 tacked on to see to it that, for example, a January 1 birth date returns a 1, and not a 0.

Kerber’s numerator, then, should read 18, a figure divided in turn by either 365 or 366, the two possible year day counts. The formula asks, with the intercession of the MOD function that appraises the remainder of a number divided by the second argument – in this case 4 – if the year drawn from E3 is precisely divisible by that 4. If it is – that is, if the formula discovers a leap year – we use 366; otherwise, the formula supplies a denominator of 365.

Once you copy the expression down the H column you can simply enter a standard AVERAGE somewhere:


I get .4732, suggesting a player birth-month “average” appreciably in advance of the June 30/July 1 yearly midpoint.

And while of course that result appears to merely corroborate that which we already divulged through the earlier pivot tables, our finding here is advantaged by a greater precision.

And precision, as any player whose serve bounces a half-inch outside the lines will tell you, matters.

Birth Month and Tennis Rankings: Part 1

23 Dec

We’ve batted this ball around before, but those hacks were taken on other fields. Still, a recent (UK) Times piece by Daniel Finkelstein on birth order and its association with soccer players’ ascent to the British Premiership league returned the analytical ball to me on a different court – in this case the one earmarked for tennis.

We’ve looked at tennis, too, but with a consideration of country and age-driven breakouts of mens’ tennis players – not their birth months. So I booked some time on the tennisabstract site and its current, online-sortable rankings of the male of the species, which you can copy and paste from here.

The rankings seem current indeed, by the way; an ascendant Andy Murray in the pole position attests to their recency. In search of some deep background on the matter, I Googled my way into the menstennisforums site, and its precedent discussion of the birth-month-rankings relationship (you need to join the forum, by the way; a free enrollment entitles you to limited access to its holdings). In this connection a Taiwanese contributor screen-shot this birth-month-rankings distribution for 2014 player-rankings data:


 We see that the birth months of all ranked players skew heavily toward the first half of the year, and rather discernibly, though occupants of the top-100 exhibit a far evener natal distribution, among that far smaller sample (if in fact the cohort can be permissibly understood as a sample. A sample of what, after all?) Yet 54% of the top 500 present a first-half birth certificate, as do 55% of top-1000 position holders. The proportion for all 2221 ranked players: 56%. Something, then, seems to be at work. So what about 2016 data?

That sounds like a question we could answer. But before we give it a try, a pre-question of sorts could be posed at the activity: does it pay to bother? If the 2014 data above have been faithfully compiled – and they probably have – would much interpretational gain be realized by another look at the men’s rankings, but two years’ later? With a player cohort exceeding 2000, would statistical sense be served by recounting the birth month distributions?

Well, they said Clinton would win, too. Distributions change, and testing the data anew – which after all are not wholly coterminous with 2014’s player pool – is worth the try, especially since we’ve budgeted for the project (a bit of blog humor, that was).

So let’s see, starting with this pivot table (note: 13 players have no birth dates to report, and are to be filtered away throughout):

Rows: DOB (grouped by Months only)

Values: DOB (Count, then % of Running Total In (this against the DOB baseline, the only one undergirding the pivot table. Turn Grand Totals off, too).

I get:


The running totals’ month-by-month accumulation indeed emulates the 2014 56-44 first/second-half yearly breakout, along with the respective monthly contributions to the whole. No surprises, then – but replication does have its place.

And how do our month distributions compare with the 2014 top 100, 500, and 1000? We can start by dragging DOB into the Columns area and grouping these into bins of 100, retaining the running total effect. Isolating the first bin in the screen shot, I get:


 Here, and unlike the 2014 figures, the first/second-half differential breaks 59-41%, comporting with the rankings’ overarching tendency, although again, of course the universe of 100 players will not mollify a statistician.

For the birth-month distribution for the top 500, group the rankings by that interval:


Pretty much more of the same. Then group by 1000:


The approximate 56-44 weighting runs through the data and its several granularities; and remember that the third, 2001-3000 bin, comprises only 65 players.

Now what if we isolate the contingent from the US? We’ve learned in a previous post about the August birth-month effect that seems to prefigure the career prospects of baseball players from that country. First, in view of the likely diminished US-specific aggregate that’ll sprinkle just a few numbers across the rankings I’ll remove Rank from the table, introduce a Slicer for Country and click USA, and restore Grand Totals. I’ll also tap DOB a second time for Values duty, one instance to convey the straight sums, the other to record that running column percentage. Here I get:


Note first of all that only 164 Americans appear among the 2087 ranked players, around 7.9% of them all, even as that proportion leads all nations. Second we see that no Jan-Jun differential obtains for the US, though the 23 Americans born in October could perhaps be wondered about.

But the global birth-month disparity holds, and as such calls for an accounting. Tennis players, after all, are among the most international of sporting populations, the rankings admitting players from 98 countries. The simple, but yet-to-be-substantiated hypothesis, would maintain that January 1 cut-off dates for age-specific tennis youth programs advantage older players, but that’s an early surmise. (Note by the way that UN birth data by month across the 1967-2015 periods reveals no January-June skew.)

First conclusion: more work needs to be done here. And while we’re at it, think about Michael Grant, an American ranked 836 and born in 1956, having earned his highest rank of 96 in…1979. Well done, Mr. Grant, I’d say – and he was born in Februrary.

But what about women players? Good question.

L’autre election: Budget Participatif, 2016

12 Dec

Trust me; there have been other elections contested across the planet of late that do not involve candidates with big hair and/or trademark pants suits. Consider, by way of example, that now-annual attestation of Parisian fiscal democracy, the Budget Participatif, for which we budgeted a couple of thousand words last year in a pair of posts.

The budget referendum, you may recall, asks Parisians to point their collective thumbs up or down at several hundred project proposals for the city, some specific to one of Paris’ arrondissments (districts), the others citywide. What’s not pinpointedly specific is the definition of a Parisian, understood here as a resident of the city – that’s all. My Google translator imparts some additional slack to the eligibility requirements: “All Parisians may vote without age or nationality (Parisians who live in Paris are deemed Parisians).“ We’ll have to call the translation a free one.

Locutions aside, the Paris Open Data site again brings 2016 referendum results to our attention, right here:


Just click on the Excel link; then take a look at what you’ve downloaded.

Surprise. If you think back to last year’s resultats spreadsheet – and if your recollection fails, observe this excerpt:


Seven useful fields in there, naming and counting the information any interested party would seek to know: the sums of the budgets earmarked for the project (in euros), project arrondissement (75000 points to a citywide proposal), internet and in-person vote numbers, and their joined totals (though I’m not sure what the decimals bring to the party), the fate of each vote (GAGNANT flags a winning project, NON RETENU a losing one), and project description. Now unwrap this year’s workbook. It can’t be manageably screen-shot; its 72 columns won’t miniaturize intelligibly, so you’ll have to unwrap it yourself and endeavour to survey its mighty expanse.

In a year’s time the Budget Participatif worksheet has mushroomed its field count by an order of magnitude – even as it sets forth what is in effect the same information, with perhaps one exception we hope to acknowledge later. Where in the 2015 rendition but one superordinate field properly subsumes all the voting information about each and every arrondissement (i.e., Localisation, in column D), the current sheet grants three fields to each – one for its internet and in-person votes, the third totalling the former two.

And if nothing else, new navigational privations burden the sheet. If you want to view the voting numbers for the 20th arrondissement, then, you’ll be in for a long scroll. And the arrondissements are only intermittently sorted in the Localisation field, too.

I’ve belaboured the point in the past, but I’ll belabour anew: the data set reformation instituted by the 2016 version discourages the kind of analysis to which one would be inclined to subject the data.

For but one example: if in the 2015 rendition I wanted to pivot table election results via a Slicer featuring arrondissement numbers, I’d try

Row: Projets

Projets Gagnants/Non retenus (I’ve worked with the Tabular Form layout, and eliminated subtotals)

Slicer: Localisation

(You’ll note the unfilled Values area – our exclusive concern here with text enumeration entitles us to the omission. And you’ll probably want to turn Grand Totals off.)

And I’d wind up with something like:


 But you won’t be able to replicate the above on the 2016 sheet – because again, each arrondissement has been gifted with a set of fields all its own, and you can’t filter or slice across fields; you slice the items populating a unitary field. And I’m not so sure how a standard filtering of these rows would work, either.

Indeed – given the wholesale reimagining of the data, ask yourself what pivot tables the current Budget sheet could facilitate. There’s also the matter of row 541 and its queue of what appears to be totals of columnar figures, but these don’t add their respective rows 2 through 540 precisely. Those imprecisions aside, I’d allow that the row need be deleted, or at least resettled, from the data set.

And because of the arrondissement-specific nature of much of the Budget voting – in which district residents decide on indigenous projects – a spate of zeros floods the sheet. This excerpt:


Selects a project vote sampling from the 9 through 11th arrondissements, and the corresponding vote for these in the 1st. What you’re seeing makes near-perfect sense; residents of the 1st aren’t supposed to vote for the projects above (though indeed, the fugitive single vote for the Plus d’arbres dans les rues du 10e begs for scrutiny); and that Paris-wide eligibility stricture has the effect of loosing more than 29,000 overwhelmingly extraneous, zero-bearing cells into the data set, or nearly three-quarters of all the cells.

But The 2016 sheet does widen at least one new vista on the vote numbers, though: it breaks out the vote for citywide projects (the ones denoted 75000) by arrondissement, an insight that the 2015 iteration doesn’t afford. Does that gain, then, offset the inconveniences wrought by the new data organization?

Bonne question; and if Paris Open Data is happy to foot my Eurostar bill I’ll be happy to ask it for you in person.