# Extreme outliers

How extreme monthly outliers are corrected: replaced with the median of the district's other months in the same year.

An *extreme outlier* (A monthly value more than 5 times the median absolute deviation (MAD) from the median monthly value of the same series (district, or the national or admin-1 series being assessed), the median and MAD being computed from all years except the most recent one (source). In data adjustment it is replaced by the median of the district's non-outlier months in the same year.) is a monthly number far from the usual values of the same
district, such as an accidental extra zero. The [data quality assessment](https://datasuite.damurka.com/en/methodology/data-quality/outliers.md) finds
and counts them; the data adjustment corrects them, so that a single wrong month does not distort a district's annual
total.

> **Note**
>
> **At a glance**
> - **Adjusts:** each monthly value more than 5 × MAD from the district's median monthly value.
> - **Replaced by:** the *median* (The middle value of a series once sorted: half the values are above it, half below. A few extreme values barely move it, unlike the mean.) of the district's other (non-outlier) months in the same year.
> - **In the app:** applied automatically by **Adjust Data** on the **[Data Adjustment](https://datasuite.damurka.com/en/apps/countdown/data-preparation/data-adjustment.md#press-adjust-data)** page; the effect shows on **[Data Adjustment Changes](https://datasuite.damurka.com/en/apps/countdown/data-preparation/data-adjustment-changes.md)**.

## Why

Extreme outliers, such as an accidental extra zero in a number, can have a large impact, especially on subnational
numbers, and can greatly affect coverage trend assessments: one month ten times too high can nearly double a
district's annual total.

## What

Extreme outliers, as defined in the [data quality assessment](https://datasuite.damurka.com/en/methodology/data-quality/outliers.md#what), are
corrected by imputing the median monthly value of the same year.

| Problem | Action | Adjustment |
| --- | --- | --- |
| Extreme outliers can greatly affect coverage trend assessments | If a monthly value is greater or smaller than 5 times the *Median absolute deviation (MAD)* (How much the values of a series usually differ from their median: the median of the distances between each value and the median. A monthly value more than 5 MAD from the median is an extreme outlier.) from the district's monthly median value, an adjustment is made | Extreme monthly outliers are corrected and given the median of the district's other (non-outlier) months in the same year |

- The median and MAD that define an outlier are computed from all years except the most recent one, so the latest year is judged against the earlier years.
- Outliers are looked for after the [adjustment for completeness of reporting](https://datasuite.damurka.com/en/methodology/data-adjustment/completeness-adjustment.md), in the adjusted numbers.
- All the adjusted service indicators are corrected, and inpatient numbers too. Mortality indicators are not.

## Formula

A monthly value $x$ is an extreme outlier when

$$\lvert x - m \rvert > 5 \times MAD$$

and it is then replaced:

$$x \rightarrow \tilde{x}_{y}$$

where

- $m$ is the district's median monthly value, over all years except the most recent;
- $MAD$ is the median absolute deviation of the same values;
- $\tilde{x}_{y}$ is the median of the district's months in the same year $y$ that are not extreme outliers.

**Worked example:** a district usually gives about 500 penta1 vaccinations a month (median 500, MAD 40, so the normal
range is 500 ± 5 × 40, from 300 to 700). One month was entered as 5,000. It is an extreme outlier and is replaced by
the median of the district's other months that year, say 505. The annual total drops from about 10,500 to about 6,000.

## Settings

| Setting | Default | What it means |
| --- | --- | --- |
| Outlier bound | 5 × MAD | How far from the median a monthly value must be to be corrected. |
| Baseline years | All years except the latest | The years used for the median and MAD. |
| Replacement | Median of the non-outlier months, same district and year | The value given to an extreme outlier. |

## Interpretation

- **Did the outlier correction change a year's total by more than the completeness adjustment?** Then that year had large outliers: look at them on the [Outlier Detection](https://datasuite.damurka.com/en/apps/countdown/data-quality/outlier-detection.md) page.
- **Is there a real-world explanation?** Outliers are identified statistically. A vaccination campaign, an outbreak or a stock-out can produce a real peak, and the correction then removes real services; consider the reasons before accepting the correction.
- **Are the outliers mostly in the latest year?** The latest year is compared with the earlier ones, so a real, steady increase can be flagged. Check the trend.

### Example: outliers in measles 1 vaccinations

![Change in the number of measles 1 vaccinations made by each adjustment step, by year](https://datasuite.damurka.com/images/data-adjustment-out-outliers-change.png)

**Reading the chart:** each bar is what one adjustment step changed in the national number of measles 1 vaccinations in
a year; the label is the change as a percentage of the reported number. Red is the adjustment for completeness of
reporting ($k$ = 0.25), blue the outlier correction (below zero when outliers were lowered).

**What it shows:** the completeness adjustment added between 0.15% and 1.8% a year. The outlier correction was small in
the first four years (between +0.08% and −0.54%) but removed about 18,500 vaccinations (−4.0%) in the fifth year and
10,600 (−2.2%) in the last, more than the completeness adjustment added: the adjusted numbers of those two years are
about 2% lower than the reported ones. Before accepting this, check on the Outlier Detection page which districts and
months were corrected, and whether a measles campaign or another real event explains the peaks.

## After the adjustment

The corrected numbers then go through the [missing value](https://datasuite.damurka.com/en/methodology/data-adjustment/missing-values.md) correction
and into the master adjusted dataset, used for [Denominator assessment and selection](https://datasuite.damurka.com/en/methodology/denominators.md)
and [Coverage](https://datasuite.damurka.com/en/methodology/coverage.md).
