
Missing Values and Imputation
A missing rainfall reading might conceal a dry day or a broken gauge. A four-day weather record shows how a median fill changes the total and why the reason for a gap matters.
Sources
Résumé complet
A rain gauge that breaks during a storm and a gauge that faithfully records a dry day can both leave a blank in a spreadsheet. The blank looks identical, yet the two situations mean different things. Before filling any gap, ask why it is there, because the answer shapes what a sensible replacement could be.
Suppose a school weather station logs daily rainfall in millimetres. Three complete days read 4 mm, 6 mm and 8 mm. A fourth day is missing because the gauge was knocked over. Median imputation replaces the gap with the middle value of the known readings. Sorted, the three values are 4, 6 and 8, so the median is 6 mm. The filled row now reads 6 mm, and the record is complete enough for a simple calculation such as a four-day total of 24 mm. The interpretation matters. We have not recovered the rain that fell. We have inserted a plausible stand-in drawn from nearby days, and any later average quietly treats that stand-in as measured fact.
Now imagine the same three values but a missing fourth day in midsummer, when the gauge was working and no rain fell. Here the honest entry may be 0 mm, not 6 mm. Filling 6 mm would invent rainfall that never occurred. The median is a reasonable guess only when the gap resembles the days around it. If gaps cluster in storms, or if a sensor fails precisely when readings are extreme, imputing the middle value pulls the record toward ordinary weather. This is a bias in the filled data, and no simple fill removes it. The method makes a dataset usable, not correct.
Three responses deserve comparison. Deletion removes the incomplete row, which is simple but sacrifices the other values in it, such as a valid temperature reading recorded the same day. An indicator adds a separate yes-or-no column marking which entries were filled, so later analysis can see where guesses sit and can test whether filled days behave differently. Reasoning about cause asks whether missingness itself carries information, such as a gauge that fails only in heavy rain. These can be combined, and an indicator does not repair bias, but it keeps the guess visible.
In class, give pairs a small table of daily rainfall with one note documenting a broken gauge and another recording that a second observer verified dry weather. Ask each pair to write the number they would enter and one sentence of justification, then compare justifications across pairs. Record the reasons on the board, sorted into measurement faults, true zeros and unknown causes. The disagreement itself is the lesson, because it makes visible that filling a gap is a judgement about measurement, not a neutral arithmetic step.
For a prediction exercise, first separate earlier training days from later test days. Estimate the replacement median using the earlier observations and store that number. Apply the stored median to missing values on later days. If students recalculate the median with the later readings included, information from the evaluation period has helped design the very model being tested.


