Show the code of the figure
show(lambda: figures.skill_by_day(days, skill))November 30, 2026
Series: Bayesian Modelling for Agriculture, Part 3. Part 1 stated the planting decision as one equation and described the onset of the rains. Part 2 built the Bayesian model of the onset and took a planting day from its predictions. This post tests that forecast on seasons that the model has not seen, and Part 4 updates it as the rain arrives.
A model agrees with the seasons that it was fitted to, so its fit says little about the next one. A farmer needs three answers before relying on a forecast of the onset. The first is whether it is better than what the farmer already has, the record of past onsets. The second is whether its probabilities can be taken at face value, so that a probability of 0.3 is followed by an onset in about three seasons of ten. The third is what the planting day taken from it gains or loses, and where.
Part 1 gives a reason to expect a modest answer. The dipole correlates with the onset at about in most regions, so it explains about a quarter of the variation. A forecast built on it can narrow the distribution only moderately. The loss under the climatology also bounds what a forecast can save. A farmer who knew the onset would lose nothing in a season with one, but a season without an onset costs a false start whatever is known. The test therefore asks how much of the attainable saving the forecast recovers. The expectation is stated before the scores are read. The forecast should be better than the climatology on most days, approximately calibrated, and worth a fraction of the most that a forecast could save.
The test follows the practice of probabilistic forecasting, in which a forecast is judged by its calibration and its sharpness together.1 It keeps the setting of Part 1, a false start that costs 30 days of delay, with 10 and 60 as the range of that ratio.
Each of the 44 seasons is held out in turn. The model of Part 2, with the physical prior and the shared season effect, is fitted to the other 43 seasons. The index is standardised with the training seasons only, and the six regions of the held-out season are forecast together. The season is the unit of the test because the regions of a season share the ocean. Their residuals correlate at 0.55 in Part 2, so holding out one region and keeping its neighbours would let the neighbours reveal the season. Cross-validation of this kind estimates how well a model predicts data that it has not seen.2 The reference forecast is the climatology of each region, the onsets of its other 43 seasons. A season without an onset counts as later than every day. A forecast has to beat this reference to be worth using, because the reference needs no model. Nothing else changes between folds, so a difference between the two forecasts is attributed to the dipole and to the model that uses it.
The 44 fits are checked one by one with the diagnostics of Part 2. After the first pass four folds failed them. One of them, the fold that holds out 2010, had a stuck chain with 1,000 divergent transitions, an of 1.54 and an effective sample size of 7. A fold that fails is not scored, because a forecast from a sampler that did not explore the posterior has no standing as a test. The four were refitted with a target acceptance rate of 0.99 and a new seed, and all four passed at the first attempt, as Table 1 shows. The rule for the refits was set before any score was computed. The 44 folds then have no divergent transition, a largest of 1.010 and a smallest bulk effective sample size of 691.
| Season held out | Divergences | Bulk ESS | After the refit: divergences | Bulk ESS | ||
|---|---|---|---|---|---|---|
| 1982 | 2 | 1.005 | 1,156 | 0 | 1.008 | 829 |
| 2007 | 1 | 1.003 | 1,142 | 0 | 1.004 | 790 |
| 2009 | 0 | 1.011 | 710 | 0 | 1.007 | 777 |
| 2010 | 1,000 | 1.536 | 7 | 0 | 1.007 | 691 |
A forecast of the onset is a distribution, so it is scored as one. For each day of the window the forecast gives the probability that the onset has come by day . The record gives the outcome , which is 1 if it had come and 0 if it had not. A season without an onset has on every day of the window, because all that is known is that the onset lies beyond it. The censored seasons therefore need no special treatment here. The Brier score of day is the mean squared difference between the probability and the outcome,
It is a proper score, which means that a forecaster lowers its expected value only by reporting honest probabilities.3 A forecast that always says 0.5 scores 0.25, and a perfect forecast scores 0. The skill against the climatology is
which is positive where the forecast is better than the record and zero where it is no better.
Figure 1 shows the skill on each day. The mean Brier score over the 92 days is 0.112 for the forecast and 0.125 for the climatology, a skill of 0.109. The daily skills average 0.089, which is lower. The skill of a day is a ratio, and days with small scores weigh as much as those with large ones. The forecast is the better of the two on 88 of the 92 days. The four days without a gain, days 2, 4, 5 and 7, are in the first week, when an onset is rare and neither forecast has much to say. On days 20, 30, 45, 60 and 75 the skill is 0.107, 0.095, 0.148, 0.114 and 0.082. It is largest, 0.153, on day 69. It is nearly nothing at the end of the window, 0.026 on day 92, where the climatology scores 0.068 because most onsets have come.
The gain is therefore steady across the window and not concentrated in a few weeks. It is modest, as expected for a predictor that explains about a quarter of the variation. A farmer can expect the forecast to improve the odds on every day until the end of the window. By then the outcome is almost settled and there is little left to improve. It is also a gain that each of the 44 seasons had to earn without the help of its own record, which an in-sample fit could not show.
A forecast that beats the record can still be unreliable. If a forecast is calibrated, the probability that it assigned to the value that occurred, the probability integral transform, is uniform between 0 and 1.4 A season with an onset gives this value directly, as the forecast probability of an onset no later than the observed day. A censored season gives only that the onset lies beyond day 92, so its value lies between the forecast probability of day 92 and 1. It is drawn uniformly at random in that range. This keeps the values uniform when the forecast is calibrated, which a test on a planted record confirms. It is a construction of this post: the sources read treat the transform for counts and for continuous variables, and none treats a censored onset.
The check draws the empirical distribution function of the 264 values minus the uniform distribution function. A band shows where a uniform sample stays at every point with probability 0.95.5 A band for the whole curve is wider than a band for each point taken separately. Over a hundred points some point leaves a pointwise band in most samples, so the band is found by simulation. Where the curve is above zero, more values fall at or below that point than a uniform distribution gives, and where it is below zero fewer do. A curve that leaves the band signals a forecast that is not calibrated, and the place where it leaves says which part of the forecast distribution is at fault.
Figure 2 gives this curve in its first panel. It stays inside the band at all 101 points. Its largest departure from zero is at 0.48, where the band runs from to . A dip below zero in the middle means that fewer observations than expected fell below the middle of their forecasts, which points to a forecast that is somewhat early. The dip is inside the band, so the data do not establish it. It agrees with the finding below that the forecast under-states late seasons at Dodoma and Iringa. The curve does not show how far a central interval misses, so the interval is checked directly. A central 90% interval holds the outcome when the transform lies between 0.05 and 0.95. This is so for 84.8% of the 264 records, and for 84.8% to 86.0% over four draws of the random values of the censored seasons, against 90% in principle. The shortfall of about five points is between 2.2 and 2.8 sampling errors of 1.8 points. The forecast is therefore somewhat over-confident, with intervals that are a little too narrow, although the curve stays inside a simultaneous band that is wide for 264 values. A count among the onsets alone would mislead. Of the 241 onsets, 88.8% lie in their interval. A forecast that was exactly right would contain 92.4% of them, because part of its probability lies beyond the window. The forecast also puts 8.2% of its probability after the window, against 8.7% of the records that were censored. It reproduces the share of late seasons as well as the dates.
The other panels compare the forecast probability that the onset has come by day 30, 45 and 60 with the share of seasons in which it had. A forecast on the diagonal is reliable, because a probability of 0.3 is then followed by an onset in three seasons of ten. On days 45 and 60 the points lie close to the diagonal. On day 30 the lowest bin, with a mean forecast of 0.11, was followed by an onset in 17% of its 126 records. The bin at 0.69 was followed by one in 58% of 12 records. Early in the window the forecast therefore under-states the chance of an early onset and slightly over-states a high probability. Twelve records are a small sample for that bin, however. A planting rule that waits for a probability of 0.69 would act on a number that is a little too high.
The pooled result hides the differences between regions. The central interval holds the outcome for 75.0% of the 44 records at Dodoma, 3.3 sampling errors below 90%. It does so for 81.8% at Iringa and 84.1% at Rukwa, which are 1.8 and 1.3 sampling errors below. The other three regions are within 0.3 sampling errors of 90% or above it. The forecast also puts 28.9% of its probability after the window at Dodoma, against 34.1% of the records. The regions with the most censored seasons are therefore those in which the forecast is least reliable about late seasons. This is the direction that Part 2 anticipated, when its simulated count of seasons without an onset fell on the upper side at Dodoma and Iringa. At Dodoma the forecast under-states the risk of a late season. A planting rule that leans on that tail should be read as a lower bound on the risk there.
The intervals are wide, with a median 90% interval of 62.7 days in a window of 92, from 43.7 days at Rukwa to 67.5 at Iringa. The forecast moves the odds and does not fix the date, which is what a predictor with a correlation of can be expected to do.
The region with the weakest calibration is also the one with the largest expected loss, so it deserves a closer look. Figure 3 draws each of the 44 forecasts for Dodoma against the onset that followed, ordered along the dipole index. The medians fall as the index rises, as the slope of Part 2 says they should. A segment that runs past the dotted line at day 92 gives the forecast a chance that the onset comes after the window. The onsets scatter around them, and the intervals are wide enough that the forecast cannot rank two seasons of similar index. The 15 orange points are the seasons without an onset. Eleven of them lie at a negative index, which is the pattern of Part 1, with a mean index of against 0.03 in the other seasons. The central 90% interval holds the outcome for 75.0% of the 44 forecasts for Dodoma, 15 points below its nominal level. A farmer reading this figure would conclude that the dipole is a useful sign of a late or an early season at Dodoma and a poor guide to the day.
A forecast is worth what it changes in the decision. For each held-out record two planting days are taken, as in Part 1. One is the day of least expected loss over the forecast draws, and the other is that day over the climatology of the other seasons. Both are scored against the onset that followed with the loss of Part 1. The relative value is the saving in mean loss as a share of the mean loss of the climatology,
A value of 0 means that the forecast is no better than the record, and a positive value is the share of the loss that the forecast saves. The most that any forecast could save is less than the whole loss, because a season without an onset in the window costs a false start whatever the day. At a ratio of 30 that unavoidable loss is 2.6 of the 23.4 days, so the share of the attainable saving is a little larger than . The interval of comes from resampling the 44 seasons with replacement, a season at a time. The regions of a season share the ocean and are not independent evidence.6 It is the 5% to the 95% quantile of 2,000 resamples.
| Cost of a false start | Climatology loss | Forecast loss | Relative value | 90% interval |
|---|---|---|---|---|
| 10 to 1 | 9.28 | 9.37 | to | |
| 30 to 1 | 23.41 | 20.80 | 0.111 | 0.063 to 0.160 |
| 60 to 1 | 31.51 | 30.16 | 0.043 | to |
At a ratio of 30 to 1 the forecast lowers the mean loss from 23.4 to 20.8 days, which is 11% of the loss of the climatology and 12.5% of the saving that was attainable. The interval from 6% to 16% excludes zero. At 10 to 1 the value is and at 60 to 1 it is 0.043, and both intervals include zero. Three ratios do not show the pattern, so the first panel of Figure 4 follows the value over ten ratios from 5 to 100. Below a ratio of about 10 the forecast does not pay, with values of , and at 5, 7 and 10 and intervals that include zero. From 14 to 40 it does, with values of 0.057, 0.048, 0.111 and 0.070 and intervals above zero. The value at 60 falls to 0.043 with an interval from to 0.114. At 80 and 100 it is 0.130 and 0.102, with intervals above zero.
The dip at 60 lies within the uncertainty of its neighbours, so it is not evidence of a feature of the forecast. The reading is that the forecast pays whenever a false start costs more than about 14 days of delay, and that it does not when it costs 10 or less. This is consistent with Part 1, in which the planting day is early at a low ratio. The mean day of the climatology is 25 at 10 to 1, so the loss is mostly the cost of delay. The forecast has little to improve then, though the test does not isolate that reason. The mean planting day of the forecast moves from day 28 at 10 to 1 to day 48 at 30 to 1 and day 60 at 60 to 1. A farmer or an adviser has to state the ratio that applies before the forecast can be said to pay, as Part 1 argued.
Figure 4 gives the second panel by region at 30 to 1. The value is 0.25 at Rukwa and 0.20 at Ruvuma, where the forecast saves 6.4 and 5.2 days of loss. It is 0.11 at Mbeya, 0.07 at Dodoma, 0.01 at Njombe and at Iringa. The forecast helps most at Rukwa and Ruvuma and least at Dodoma and Iringa, the two regions with the most censored seasons. At Dodoma, which has the largest loss under the climatology, 26.9 days, it saves 1.9 days, and at Iringa it costs 0.5 days. The forecast also under-states the share of seasons without an onset in those two regions. It gives 28.9% against 34.1% at Dodoma and 8.3% against 13.6% at Iringa. Its model of late seasons is therefore the weakest where the gain is smallest and the cost of a bad planting day is highest. An advisory service with limited reach should therefore start with Rukwa and Ruvuma, and the model of late seasons needs work before it can serve the driest region.
The test says how far the forecast can be trusted, and the model says what it advises. Table 3 gives the planting day of least expected loss for each region after a positive and after a negative dipole, for a false start worth 30 days of delay. It comes from the model fitted to all 44 seasons. The table adds the band of days within 5% of the least loss and the chance that no onset comes in the window. A reader needs the region and the sign of the dipole index of August to October, which is known on 1 November, and takes the row that applies.
| Region | Positive dipole: best day | Band | No onset | Negative dipole: best day | Band | No onset |
|---|---|---|---|---|---|---|
| Dodoma | 57 | 46 to 68 | 13.6% | 71 | 54 to 85 | 43.2% |
| Iringa | 45 | 37 to 52 | 3.0% | 54 | 45 to 65 | 14.6% |
| Mbeya | 38 | 33 to 46 | 0.5% | 51 | 42 to 58 | 6.4% |
| Njombe | 39 | 35 to 47 | 0.9% | 49 | 42 to 59 | 6.0% |
| Rukwa | 30 | 28 to 34 | 0.0% | 41 | 34 to 47 | 0.7% |
| Ruvuma | 41 | 36 to 47 | 1.0% | 53 | 43 to 62 | 8.2% |
A negative dipole moves the advised day later in every region. The move is 14 days at Dodoma, 9 at Iringa, 13 at Mbeya, 10 at Njombe, 11 at Rukwa and 12 at Ruvuma. The days at Dodoma agree with those of Part 2, which were 56 and 70 for other draws of the same fit. After a negative dipole the band at Dodoma runs from day 54 to day 85 and the chance of no onset is 43%. The advice there is therefore to wait for the rain and not to plant on a date, as Part 2 concluded.
The test of this post qualifies the table. The forecast pays at Rukwa, Ruvuma and Mbeya, so the days advised there, from 30 to 53, can be offered with confidence. At Dodoma and Iringa the model under-states the chance of a late season, so the days advised there are the earliest that the evidence supports. A farmer who fears a false start more than the ratio of 30 to 1 implies should plant later than the table says.
The test can be repeated for another forecast of a decision quantity, and its steps are the same. First, fix the model, its priors and the loss before any held-out score is seen, so that nothing is chosen on the data that judge it. Second, hold out the unit that carries the dependence, here the season, and fit on the rest with the same settings in every fold. Third, check every fold with the diagnostics of the sampler, and refit a failed fold by a rule that was set beforehand.
Fourth, score the forecast as the distribution that it is, with a proper score against the reference that needs no model. Read the skill by day or by threshold and not only on average. Fifth, check calibration with the transform of the held-out values and a band for the whole curve. Read the regions separately, because a pooled result can hide the places where the forecast fails. Sixth, take the action from the forecast and from the reference and compare their realised losses with an interval that resamples the dependent unit. Seventh, state the ratios of the costs at which the forecast pays and those at which it does not. The value of a forecast belongs to the decision and not to the forecast alone.
The test rests on 44 seasons, and its 264 records are not independent, so its intervals are those of 44 seasons. The constants of the rule that defines the onset are not validated for Tanzania. The ratio of the cost of a false start to the cost of a day is an assumption. The value of 0.11 describes a stylised decision and not a yield. The climatology is the empirical distribution of the other seasons and carries no trend, for which Part 1 found no evidence. A trend would favour a model that sees the year. A farmer who knew that the onset lay beyond the window would still pay a false start for any day inside it. The saving that perfect knowledge could bring is therefore smaller than the loss of the climatology. The band of the transform curve and the sampling errors assume independent records, and the regions of a season are not, so both are narrower than they should be. That does not weaken the finding that the curve stays inside its band, and it makes the shortfall of the interval less certain than two to three sampling errors suggest. The model, its priors and the loss ratios were fixed in Part 1 and Part 2, and nothing was chosen on the held-out seasons. The four refitted folds depart from a single pass and are reported above. The probability integral transform of a censored season is drawn at random, so its histogram changes a little with the seed. A season without an onset is a false start for every planting day, which is the loss of Part 1 and not a measured one.
The forecast of Part 2 predicts held-out seasons better than the climatology of the record. The margin is consistent with a predictor that explains a quarter of the variation. Its Brier score is 11% lower on average and lower on 88 of 92 days, with the largest daily gain, 15%, near day 69. The curve of its probability integral transform stays inside the band of a calibrated forecast. Its central 90% interval holds only about 85% of the outcomes, so the forecast is somewhat over-confident. It is least reliable in the regions with the most censored seasons, 75% at Dodoma and 82% at Iringa, where it under-states the chance of a late season.
As a basis for the planting day it saves 11% of the loss of the climatology at a false start worth 30 days of delay. That is 12.5% of the saving that was attainable. The interval of the first runs from 6% to 16%. It pays at every ratio from 14 to 100 except 60, where the interval includes zero. At a ratio of 10 or less it cannot be separated from the climatology. The gain is 25% at Rukwa and 20% at Ruvuma and a loss of 2% at Iringa. The forecast is therefore a modest help that is worth offering where the onset is early and the record is complete. It needs a better model of late seasons before it can serve the driest region. Part 4 asks what changes when the rain that has already fallen is added to the dipole.
The notebook is in the bayesian-modelling repository and runs from the first cell to the last in its uv environment, with PyMC 6.4 and ArviZ 1.3. The rainfall of the regions ships with the package, and the indices are downloaded from NOAA on the first run. The 44 fits are stored in small files, one for each held-out season, so that a repeat run takes seconds. The fits themselves take about ten minutes on a laptop. The folds, the scores, the planting losses and the figures are functions of the bayes.climate and bayes.plot packages, which have unit tests. Among them are a planted record whose transform stays inside the band and an overconfident forecast whose transform leaves it. The journal papers cited were read by abstract only. The passages of Bayesian Data Analysis cited in Sections 7.1 and 7.2 were read in its free electronic edition.
[1] T. Gneiting, F. Balabdaoui, and A. E. Raftery, “Probabilistic forecasts, calibration and sharpness,” J. R. Stat. Soc. B, vol. 69, no. 2, pp. 243-268, 2007, doi: 10.1111/j.1467-9868.2007.00587.x. The abstract proposes “the paradigm of maximizing the sharpness of the predictive distributions subject to calibration,” where calibration is “the statistical consistency between the distributional forecasts and the observations” and sharpness “refers to the concentration of the predictive distributions and is a property of the forecasts only.” Among the tools it names is the probability integral transform histogram. Read by abstract only.↩︎
[2] A. Gelman et al., Bayesian Data Analysis, 3rd ed. Boca Raton, FL, USA: CRC Press, 2013, doi: 10.1201/b16018, Sec. 7.2: “In Bayesian cross-validation, the data are repeatedly partitioned into a training set and a holdout set, and then the model is fit to” the training set. A. Vehtari, A. Gelman, and J. Gabry, “Practical Bayesian model evaluation using leave-one-out cross-validation and WAIC,” Stat. Comput., vol. 27, no. 5, pp. 1413-1432, 2017, doi: 10.1007/s11222-016-9696-4, whose abstract describes the estimation of “pointwise out-of-sample prediction accuracy from a fitted Bayesian model.” The book was read in its free electronic edition and the paper by abstract only.↩︎
[3] A. Gelman et al., Bayesian Data Analysis, 3rd ed. Boca Raton, FL, USA: CRC Press, 2013, doi: 10.1201/b16018, Sec. 7.1: “Measures of predictive accuracy for probabilistic prediction are called scoring rules. Examples include the quadratic, logarithmic, and zero-one scores. Good scoring rules for prediction are proper and local: propriety of the scoring rule motivates the decision maker to report his or her beliefs honestly.” The Brier score is the quadratic score of the probability of a binary event, an identification that is the reading of this post and not a sentence of the book. Read in the free electronic edition of the book.↩︎
[4] T. Gneiting, F. Balabdaoui, and A. E. Raftery, “Probabilistic forecasts, calibration and sharpness,” J. R. Stat. Soc. B, vol. 69, no. 2, pp. 243-268, 2007, whose abstract names “probabilistic calibration” among the forms of calibration and the “probability integral transform histogram” among the tools for checking it. C. Czado, T. Gneiting, and L. Held, “Predictive model assessment for count data,” Biometrics, vol. 65, no. 4, pp. 1254-1261, 2009, doi: 10.1111/j.1541-0420.2009.01191.x, which proposes “a nonrandomized version of the probability integral transform” for counts. Both were read by abstract only.↩︎
[5] T. Säilynoja, P.-C. Bürkner, and A. Vehtari, “Graphical test for discrete uniformity and its applications in goodness-of-fit evaluation and multiple sample comparison,” Stat. Comput., vol. 32, Art. no. 32, 2022, doi: 10.1007/s11222-022-10090-6. The abstract presents “simultaneous confidence bands for the whole empirical cumulative distribution function (ECDF) of the PIT values under the assumption of uniformity” and calls them “an intuitive ECDF-based graphical test for uniformity, which also provides useful information on the quality of the discrepancy.” The band of this post is found by simulation in a simple form. Read by abstract only.↩︎
[6] B. Efron, “Bootstrap methods: Another look at the jackknife,” Ann. Stat., vol. 7, no. 1, pp. 1-26, 1979, doi: 10.1214/aos/1176344552. The abstract introduces “a general method, called the ‘bootstrap,’” for estimating the sampling distribution of a statistic from a sample. Resampling whole seasons, so that the dependence between regions is kept inside each draw, is the application made here and is not treated in the abstract. Read by abstract only.↩︎
@online{faustine2026,
author = {Faustine, Anthony},
title = {When to {Plant:} {Testing} the {Onset} {Forecast} on
{Seasons} {It} {Has} {Not} {Seen}},
date = {2026-11-30},
url = {https://sambaiga.github.io/pages/blog/posts/2026/11/2026-11-30-testing-the-onset-forecast.html},
langid = {en}
}