learn-bayesian-with-phoebe / Practitioner session 10 of 10
Learn Bayesian with Phoebe · Practitioner session 10 of 10

The pooling bench

Nine sessions of method, and every one of them has been missing the same thing: a case where you know the answer. Tonight you have one. Halloway's twelve outlets redeem a voucher at rates the generator states outright, so a prior can be scored against the truth rather than defended, a pooling method can be given a root-mean-square error rather than an argument, and a stopping rule can be run two hundred times to find out how often it stops on the wrong arm. Three benches, one world, nothing looked up.

🔴 Hardest Data scientists and analysts Anyone who has to defend a small-data number 45 min
0-3 · Welcome 3-14 · A world with a known answer 14-40 · Build-along: the three benches 40-45 · Q&A
Part 0

What the bench measures

Error against the truth, and nothing else. Not how reasonable a prior sounds, not how elegant a model is, but the distance between the estimate a method produced and the rate that is actually there. Real analyses never get this number. Here every outlet's true rate is a line in the source file, and every bench reports how close each method came.

Live = presented in the 45 minutes Self-study = the full depth, after class 🔍 Every diagram zooms

★ What you walk out with tonight. The measured cost of a prior, at the outlet where a sensible one was confidently wrong and at the flagship where a wrong one still moved the answer at n = 900. A pooling ladder with a number on every rung: 0.054, 0.031, 0.025. And a stopping rule whose wrong-stop rate is a count rather than a promise: two in two hundred.

LiveWhere a known answer comes from3 min▶

Twelve outlets, one voucher, one month. The generator draws each outlet's true redemption rate around 0.12 with genuine spread, then draws each customer's redemption from that rate. Footfall is deliberately unequal, from 18 vouchers at Northgate to 900 at Westfield, because that is what a real chain looks like and because the whole argument for pooling lives in the gap between those two numbers. The grand rate across all 2,443 vouchers is 0.141; the mean of the twelve true rates is 0.132.

Northgate is the recurring character. Its true rate is 0.192, the highest in the chain, and it redeemed one voucher in eighteen, an observed 0.056. Neither number is a mistake. One in eighteen is simply what a true 0.192 looks like at that volume about a fifth of the time, and the whole discipline exists for cases like it.

Real world

Halloway's regional manager had Northgate flagged for closure on the strength of the 0.056. The analyst's first instinct was to blend it with the chain-wide belief, which gave 0.110 and did not save it. The estimate that did save it, 0.124, came from letting the other eleven outlets say how much any one outlet's month should be trusted, which is what bench B does.

Self-studyWhat is real here, and what is not3 min▶
  • The world. Twelve outlets from a fixed seed, identical for every learner, generated by the model written out in bayes-live.js where every rate is visible.
  • Bench A. Exact conjugate Beta-Binomial posteriors. The interval is the 5.5 and 94.5 percent quantiles of 20,000 draws, an 89 percent equal-tailed interval, which is what ArviZ 1.x reports by default.
  • Bench B. No pooling is each outlet's observed rate. Complete pooling is the grand rate for everybody. Partial pooling is an empirical-Bayes fit: the mu and kappa that maximise the marginal Beta-Binomial likelihood across the twelve outlets, searched on a grid, then each outlet shrunk toward mu with weight n over n plus kappa. It is a real fit, and it is the simpler of the two standard approaches; session 6 names the fully Bayesian version that puts a prior on kappa too.
  • Bench C. One cumulative experiment: the first 50 customers per arm are the first 50 of the same 3,000. P(B > A) and both expected losses are Monte Carlo over 20,000 paired draws from the two posteriors.
  • Nothing is stored. Every figure on the bench is computed when you click. A result that disagreed with the course notes would be the notes' problem.
Part 1 · covers the three benches and what each one scores

Three questions, one world

10 min live

The three benches answer the three questions the track has been circling. How much does a belief cost when it is wrong? How much do eleven other outlets know about the twelfth? And when is a difference big enough to act on? Each one has a number because the truth is known, and the numbers do not all flatter the method.

Three benches. Each one reports a distance from the truth, not an opinion. A · What a prior costs Northgate, n = 18, truth 0.192 Informed prior, 100 pseudo-obs: 0.068 to 0.159, misses Flat prior, 2 pseudo-obs: 0.020 to 0.222, contains, wide Westfield, n = 900: wrong prior still moves the answer by 0.026 cost = weight x distance B · The pooling ladder RMSE against twelve true rates No pooling 0.054 Complete pooling 0.031 Partial pooling 0.025 Helped 6 outlets, hurt 6 Big wins on the small ones, thousandths lost on the large C · The A/B decision Westfield, true lift 2.5 points n = 50: P(B > A) 0.915 expected loss 0.0029, keep going n = 100: P(B > A) 0.975 expected loss 0.0005, stop, B 200 replays of the same rule: 23 stop at 100, 2 on the wrong arm Every figure above is scored against a truth written into the generator. That is the one thing a real analysis never gets, and the reason the bench exists.
🔍 Click to zoom - three benches, one world. The numbers that flatter the method and the ones that do not are on the same card.
LiveThe rung that decides the argument for pooling4 min▶

Of the three ladder rungs, partial pooling wins on the Halloway data with a root-mean-square error of 0.025 against 0.031 for treating every outlet as identical and 0.054 for treating each as unrelated. The interesting number is not the winner, it is how the winner was chosen. Partial pooling learned from the twelve outlets that the right pooling strength was kappa = 116: each outlet's month counts for n over n plus 116, which is 0.13 at Northgate and 0.89 at Westfield. Nobody set that. The data did.

Change the world and the method changes its mind. In a world where the outlets are truly identical it learns a kappa at the top of the grid and pools completely, matching the grand-rate method to a few ten-thousandths. In a world where they are wildly different it learns kappa = 3.6 and barely pools, landing at 0.030 while complete pooling collapses to 0.145. That adaptiveness is the whole case for the method, and the bench lets you watch it happen rather than take it on faith.

Self-studyThe six outlets partial pooling made worse3 min▶

Pooling is not free and the bench says so. On the real data, shrinking toward 0.135 improved six outlets and worsened six. The improvements are large and land where the data are thin: Northgate's error falls from 0.136 to 0.068, Hillcrest's from 0.088 to 0.021, Old Quay's from 0.058 to 0.023. The deteriorations are small and land where the data are thick: Market Row from 0.000 to 0.007, Parkside from 0.002 to 0.008, Docklands from 0.007 to 0.009, with The Arcade and Westfield unchanged to three decimals.

That asymmetry is the honest summary of shrinkage. It buys tenths on the outlets that need it and costs thousandths on the ones that do not, and the net is a lower error across the chain. It is also why the method is easy to sell badly: a manager at a large outlet will notice their number moved and will not notice it moved by less than the noise. Northgate, for its part, is still under-estimated at 0.124 against a truth of 0.192. The method halved the error. It did not remove it.

Part 2 · build-along

Run the three benches

26 min build-along

Work through the tabs in order. On bench A, try the informed prior at Northgate and then the same prior at Westfield, and watch what volume does and does not fix. On bench B, run all three worlds and read kappa each time. On bench C, look at the experiment at 50 and then at 100, and notice that the probability was already high before the rule was willing to stop.

Try the wrong prior at Westfield before you believe anything about volume. Nine hundred customers, a prior worth a hundred, and the estimate is still 0.026 away from what the data said. The prior's weight fell to a tenth. Its distance from the truth did not fall at all.

Part 3 · covers the write-up

Turn three benches into one defensible number

6 min live

The bench produces estimates. A defensible number is an estimate plus the prior it rests on, the interval kind and level, and the decision rule it feeds, all written down where a reader can argue with them. The estimate is the part people fight about; the other three are the parts that decide whether the fight is fair.

State the prior as a pseudo-count and a source. "Partial pooling across the twelve outlets, learned kappa 116, which weights Northgate's month at 0.13." A prior nobody can express this way was defaulted, not chosen.

Give the interval with its kind and level. "89 percent equal-tailed." Not "the interval". The level is a tooling default that changed this year and the kind changed with it; a reader who assumes 95 percent HDI will misread every number you give them.

Report the decision rule, not just the probability. "P(B > A) = 0.975; expected loss of choosing B is 0.0005 against a threshold of 0.001, so the rule stops." At n = 50 the probability was 0.915 and the rule said keep going, because the loss was 0.0029. The probability alone would have stopped too early.

State the measured error rate of the rule. "Across 200 replays at this sample size, the rule stopped 23 times and 2 of those were on the wrong arm." That is a count, not a promise, and it is the sentence that stops "Bayesian tests have no peeking problem" from being said in your name.

Name what the method did not fix. Northgate is still at 0.124 against a truth of 0.192. A report that says the estimate improved is true; a report that says the outlet is now well understood is not.

Check yourself

Three questions

On the real Halloway data partial pooling scores 0.025 against 0.031 for complete pooling and 0.054 for none. A colleague concludes partial pooling should always be used. What does the bench actually show?

The method's value is that the pooling strength is estimated rather than asserted. Complete pooling collapses to 0.145 in the wildly-different world; partial pooling reads the spread off the data and lands at 0.030. The lesson is adaptiveness, not a permanent winner.

At n = 50 per arm, P(B > A) is 0.915. Why does the rule say keep going?

The rule is on expected loss, not on the probability. At n = 100 the probability is 0.975 and the loss is 0.0005, so it stops. There is no significance cut-off and no minimum sample in the rule; the stake does the work.

Across 200 replays of the Westfield experiment, the rule stopped at n = 100 in 23 of them and on the wrong arm in 2. What is the right way to report that?

The expected-loss rule controls the cost of a wrong decision, not the frequency of one. The frequency is what the 200 replays measure, and reporting it is what makes the rule defensible rather than merely convenient. The peeking argument itself belongs to the experimentation course.

Homework

After the track

45 min

Take a rate your team estimates for several small units, regions, stores, cohorts, segments, and build the pooling ladder on it. Observed rate per unit, grand rate for all, and the empirical-Bayes shrinkage from session 6. You will not have the truth to score against, so report the one thing you can: how far each unit's estimate moved, and whether the units that moved most are the ones with the least data. If they are, the method is doing what it should. If a large unit moved a long way, something else is going on and that is worth a look.

Sources covered

What tonight maps to

✓ The full Halloway canon, live Four priors at Northgate and Westfield; the pooling ladder at 0.054, 0.031 and 0.025 with kappa 116; the A/B rule stopping at n = 100 with 2 wrong stops in 200.
✓ Partial pooling as an estimated quantity Statistical Rethinking's multilevel chapters, run against a known truth in three worlds: real, identical, wildly different.
✓ Expected loss as the decision rule Kruschke's argument that estimation supersedes the test, applied as a stopping rule with a measured wrong-stop rate rather than a promised one.
◐ The fully Bayesian hierarchical model Session 6 names the version that puts a prior on kappa and samples it; the bench uses the empirical-Bayes fit because it is exact, fast and honest about being the simpler method.
· Power, randomisation and the peeking argument Not covered by design. learn-experimentation-with-phoebe owns experiment mechanics; this bench reports the measured wrong-stop rate and hands the argument over.
· Confidence intervals and hypothesis tests Not covered by design. learn-statistics-with-phoebe owns frequentist inference.

Session 10 cheat sheet

The ladder0.054 unpooled, 0.031 pooled, 0.025 partial. The winner learned its own pooling strength.
kappa = 116Northgate's month weighs 0.13, Westfield's 0.89. Set by the data, not by anyone.
Helped six, hurt sixTenths gained on thin outlets, thousandths lost on thick ones. Say both.
Northgate, still 0.124Against a truth of 0.192. Halved the error, did not remove it.
0.915 was not enoughExpected loss 0.0029 at n = 50. The rule stopped at 100, at 0.0005.
2 in 200The rule's wrong-stop rate at n = 100, counted. Report it beside the estimate.
89 percent, equal-tailedThe tooling default since ArviZ 1.0. Say the kind and the level every time.
State the prior as a pseudo-count"Learned kappa 116" is a choice. "The default" is not.