Data quality
Outliers in insurance data: error, or the claim that matters most?
In insurance, the largest values are often the most important ones. Deleting them makes models look cleaner and prices too low; keeping data errors makes them unstable. This article follows the work step by step: the checks the analyst declares with the business, then our outlier detector, which finds the regimes first, applies robust layers inside each regime, answers cautiously when a column holds two populations, and returns a coded result in which nothing is deleted and every decision is left to someone who knows the business. At each step, we show where the usual shortcut goes wrong, measured on simulated data with a known truth.
Two very different things
An outlier can be an error: an amount typed in cents instead of units, a payment loaded twice, a date of care before the policy started, a sensor reading during an outage. Or it can be the truth: the serious accident, the long hospital stay, the liability claim that costs more than a thousand ordinary ones. Insurance exists for the second kind, and its price depends on them.
Telling the two apart is a sequence. Its first step belongs to the analyst; our outlier detector runs the next ones in a fixed order, and nothing in it deletes a value:
- Checks declared by the analyst. The domain of each variable and the rules that cross variables are written with the business before looking at the data, and run before the detector, which does not find these errors on its own.
- Regimes first. Where a series changes for good, the change is proposed, tested, and kept only if it is validated, once the test has been calibrated on comparable series; until then, candidate changes are only reported as leads.
- Robust layers inside each regime. Statistics that a few extreme values cannot move, applied one layer after another.
- Two populations? In a column read without regimes, a clearly separated group is reported as a possible second population rather than flagged point by point.
- A coded, reviewable result. Every flag carries the rule that set it, and a person who knows the business decides.
Step 1: what the analyst declares, four kinds of strange values
Before any statistics, a strange value in a table of policies or claims belongs to one of four kinds, and each kind calls for its own answer. The first three are found by checks the analyst declares and runs before the detector, the domain of each variable and the rules that cross variables, written with the business before looking at the data; the fourth is where the statistics of the next steps come in.
Impossible: outside the possible domain. An age of 190, a negative exposure, a date of care before the date of birth: the value cannot exist, whatever the portfolio. It calls for stopping and understanding where it comes from, never for pulling it back to a bound: an age of 190 brought down to 100 is still wrong, and now it looks right. An impossible value is not always alone; it can betray a whole base, an extraction or a field that is wrong.
“In one project, by finding values outside the possible domain, I showed that some databases were wrong. Since age carries a huge weight in pricing, the impact was immediate.”
Possible but rare: borderline values. Ages around 100 exist, but they are rare, and they sit where exposure is thinnest, so each record weighs more. Deleting them removes real people; keeping them blindly lets an entry error weigh on the oldest ages. So they are neither deleted nor kept blindly: they are candidates for review, and a domain expert, or a reference source such as the original record, decides.
Contextual: valid in each column, not valid together. An age of five is a valid age, and smoker is a valid status; together, they make no sense. Valid in each column does not mean valid together. These errors escape every check run one column at a time; they are caught by consistency rules that cross variables: age against smoking status or family status, date of loss against period of cover, amount paid against amount claimed. When the pair is impossible, both variables are questioned, because nothing says which of the two is wrong.
“In one of my projects, I found five-year-old children recorded as smokers. That called into question both the age and the smoker variable, which carries a very large weight in health insurance pricing.”
Improbable but possibly true: statistical outliers. A claim a hundred times larger than the others may be an error, or the serious accident the tariff exists for. It is flagged, analysed and put in front of an expert, never deleted automatically. The next steps are about this fourth kind: how our detector finds it without being fooled by changes of regime, and what is done with it once found.
Cleaning the flagrant errors first matters because they move every statistic computed on top of them, and a correlation can turn around completely. In our SGTech engagement, a variable that should move with CH4 flow showed a correlation of −7% before cleaning, and +71% once the corrupted periods had been isolated. A period may be set aside only for a documented reason, such as an operational incident, independent of the result hoped for. How to read a correlation without finding relations that do not exist is the subject of our article on correlations. What such simple checks have found in our engagements is told on our anecdotes page and in our article on serendipity through rigour.
Step 2: find the regimes first
A value is only extreme compared with its own regime. When a book of business changes, a new product, a tariff revision, a change of claims handling, the level of a series moves for good. Compared with the months before, every normal value after the change looks abnormal; compared with the months after, a real anomaly before it hides in the crowd. So the detector does not start by looking for odd points: it starts by finding where the series changes regime.
Where the usual shortcuts go wrong. Two shortcuts are common, and both cut series that never changed. The first accepts every cut a segmentation proposes. The second looks for the position where before and after differ most, then tests that position as if it had been chosen in advance. We measured both on simulated series without any change of regime, 100 per level of persistence. With independent days, the segmentation alone cuts one series in three, and the best-looking position passes a 5% test in seven series out of ten. Once each day keeps part of the previous day’s deviation, as claims and sensor series do, both cut between 87 and 100 series out of 100. Our detector cut none of the series with independent days, and one in a hundred when each day keeps 30% or 60% of the previous deviation. These are comparisons with naive practices only: we have not measured, on the same series, a standard change-point test correctly adjusted for dependence.
Candidate changes come from PELT, an exact penalised segmentation. Among all the ways of cutting the series into pieces, cuts placed every fifth position and pieces of at least two values, it keeps the one that minimises the spread inside the pieces plus a price for each cut:
where and are the ends of the series, is the mean of piece , and is the largest of three scales of the series: 1.4826 times the median absolute deviation, the interquartile range divided by 1.349, and the standard deviation. While the cuts exceed a budget of the larger of 3 and candidates, is multiplied by 1.7, at most ten times. The price of a cut grows with the noise and the length of the series. Even so, as measured above, a segmentation alone is not a test.
A candidate is therefore tested, not believed. At a position , with the values before it and the values after it, the detector counts , the number of pairs (before, after) in which the value before is the larger, a tie counting one half, and computes the rank statistic and Cliff’s delta:
where is the size of each group of tied values. is the Mann-Whitney statistic in absolute value, corrected for ties. is the probability that a value before the cut exceeds a value after it, minus the reverse: it lies between −1 and 1 and does not depend on the units. Only positions with more than values on each side are admissible, with by default.
Two traps are closed here, and they are what sets this validation apart. Choosing the best-looking position inflates false changes, so a candidate is compared with the largest statistic of each simulated series over all admissible positions, not with the distribution of a single test. And neighbouring days resemble each other, so the reference “no change” is simulated by a stationary bootstrap. The series is centred on its median on each side of its strongest cut, and these residuals are resampled in blocks of random length, whose mean is estimated from the autocorrelation of these residuals, after Politis and White; the blocks keep the persistence of the series. The p-value of a candidate is the share of the simulated series whose largest statistic reaches its own:
The segmentation is never rerun on the simulated series. A candidate is validated when it is both significant against that maximum and large enough to matter:
with and by default. Once a change is validated, the series is split there, and each side is tested again on its own, with its own simulation. Candidates are examined from the strongest down; a candidate within positions of a validated change is set aside, and on a side the search stops at the first candidate that fails.
A series too persistent to tell a change from a slow drift gets no verdict rather than a false one: when the mean block length exceeds a quarter of the window, or when the window holds fewer than effective observations, , the candidate stays in the table with that status and never becomes a boundary. These two thresholds, and the way the series is centred, are designed to be learned on simulated series without change that resemble the real ones, then frozen. Until that calibration has been run, the detector does not validate any change: it lists the candidates as exploratory leads, and creates no regime. The measures below were made before this rule, with declared prior values. Every candidate, validated or not, is listed with its date, its p-value, its effect size and its status.
On the series shown below, the change of level was validated with a p-value of 0.0005, the floor of the simulation, and a Cliff’s delta of −0.98: almost every value before the change is below almost every value after it. Across our 50 test series with a change, it was found and validated every time. The limit we measured: on very persistent series, where each day keeps 80% of the previous day’s deviation, the detector still cut 17 series out of 100 that had no change, and abstained on one. Those series had 400 points and the detector ran with its default settings, which are not calibrated to the series at hand. A later check with the same default settings on shorter series of 200 points found false cuts in 20 of 60 series at the same persistence (33%), and in 48 of 60 random walks (80%), while abstaining on at least one candidate in only 21 of those 60. Until that calibration is done, an open fix in our register, a break reported on a strongly dependent series is a lead to examine, not a finding.
Step 3: inside each regime, robust layers
Inside a regime, the references are statistics that a few extreme values cannot move: the median and the quantiles rather than the mean and the standard deviation. The layers run in order, and each one works only on the points the previous ones left, with its statistics recomputed, so that one huge value cannot hide a smaller one. Writing for the values of the regime, missing values and, by default, exact zeros set aside, and for the points flagged by layer with the statistics of :
- a fence built on two quantiles, after Tukey (for amounts, which are positive, the first pass uses only the upper fence);
- a score of local density, only when the remaining values are strongly skewed;
- the distance to the median in units of the median absolute deviation, the modified z-score of Iglewicz and Hoaglin;
- the gap to a short moving average, when a time axis is declared, to catch a jump that stays inside the general range;
- a second pass of the fence and of the modified z-score on what remains, then declared guards on the raw values.
For a point of , with and the declared lower and upper quantiles of , the declared multiple, and its median and its median absolute deviation, and the declared threshold, the fence and the modified z-score flag:
The factor 0.6745 makes the median absolute deviation comparable to a standard deviation for normal data. The moving-average layer compares each value with the mean of a short window around it in time, the value itself included (by default, the value and its neighbour), among the points still unflagged, in units of the spread of these residuals:
where and are the mean and the standard deviation of the residuals, and the declared threshold of this layer. Amounts with a heavy tail are read on a logarithmic scale, , decided from their shape, which is meant to keep large genuine claims from being flagged merely for their size. The switch is made when every value is non-negative and
where is the excess kurtosis of the values, with and by default. The layers run on that scale; the guards read the raw values. The logarithmic scale is not a protection, and this limit is open: on clean simulated log-normal samples, with no error in them, the detector with its default settings still flagged about 2% to 4% of the genuine values on average, depending on the spread, and up to 9% in a single draw (30 draws of 1,000 values). Those flags are candidates for review, not errors.
Every threshold is declared before looking at the data. The detector’s default settings are deliberately wide: the 20% and 80% quantiles with , the modified z-score at and the moving average at 2, a local density score that, when it runs, flags 5% of the remaining points by construction, and two guards on the low side: one flags the values below a quarter of the 20% quantile, the other the lowest 1% of each regime, by construction. The measures shown below use the literature’s standards instead: the quartiles with Tukey’s far-out fence, , the modified z-score at , the moving average at 3.5 as well, neither of the low guards, and no rule that flags a fixed share of the points by construction. For a backtest, the detector can be fitted on the past alone: quantiles, medians and thresholds come from the history up to a date, the later rows are only scored, and the moving average then reads earlier observations only.
Data errors usually betray themselves: a cluster of amounts exactly a hundred or a thousand times the typical values, identical payments on the same day, dates outside the contract, negative exposures, amounts above the contractual limit of the act. The rules declared in step 1 catch many of them; the layers find the rest, as candidates for review, never for automatic deletion.
Measured: what finding the regimes first changes
These measures were made with the validation running on its declared prior values; since then, the detector validates a change only under a calibration fitted to comparable series, and none has been frozen yet. We measured it on 50 simulated series of 400 days, each with a change of level halfway and four anomalies injected at random places, two too high and two too low on average. Read in one block, the series loses one anomaly in ten, hidden by the change of level, and raises almost four false alerts per series. Read regime by regime, every anomaly was found and false alerts fell below one per series, about one point in five hundred. The change of regime itself was found and validated in every series.
These figures hold for the declared thresholds of the literature. With the detector’s looser default thresholds, which also flag the lowest one per cent of each regime by construction, every anomaly is found in both readings, but false alerts rise to 12 per series in one block and to 31 regime by regime. The thresholds matter as much as the order, which is why they are declared before looking at the data. Both readings use our detector with the same thresholds: the comparison is between the naive practice, one block, and ours, regimes first, not with another method used correctly.
Step 4: one column, two populations?
This step is an alternative to step 2, not a step after it: it runs only when the column is read without looking for regimes, and on at least 40 values by default, typically a column of amounts rather than a series over time. The detector then first looks at the shape of the distribution. It looks for heads, compact groups of values, and only then runs the layers of step 3 inside each head large enough to be read, so that one population is never judged against another; a point that belongs to no head is scored against the heads only.
Where the usual reading goes wrong. A detector that reads the column as one population measures every value against the bulk, and a genuine group of values a level above it is flagged as a block, point by point. We met the case in practice: about ten values around 3,000, a second kind of value recorded under the same label as values around 200, flagged as a block. The chart below reproduces it on simulated amounts: 300 around 150, 11 between 2,500 and 3,000, and one isolated 12,000. Read as one population, by our detector without this step, all 11 values of the group are flagged, with the 12,000. Our detector reports the group as a second head, flags none of its values, and still flags the 12,000. In that case, at an insurer, the second population revealed a nomenclature that mixed several risks under one code, most claims around ILS 200 and a few around ILS 3,000; the per-variable table, the expert and the encoding corrected along the way are told in our article on a column that holds several populations.
The rule, in order. On the working scale, when every value is positive, since two populations of different levels are separated by a factor rather than a difference, candidate groups come from a Gaussian mixture whose number of components grows only while each new one lowers the Bayesian information criterion by a declared margin. A group is set apart from the other values only across an empty gap:
where is the smallest width of the empty interval between and the nearest other value, over the sides where there are other values (zero if another value lies within the range of ), a robust standard deviation, and by default. Taking the larger of the two spreads is deliberate: a thin slice of one skewed population, or three values close by chance in a sparse tail, has a tiny spread of its own, and would otherwise pass for a population. A group set apart in this way is a head when it holds at least three values, a count and never a share of the table, and is compact:
where is its standard deviation and the dominant head: the median of the group lies at least four of its own standard deviations from the main one. The bound 0.25 is a declared, provisional setting: the benches we ran on data with a known truth to choose it found no rule that did better on every count, so it stays as declared. A point that belongs to no head is scored against the heads only, never against itself, and flagged only if it is extreme for every head :
On the simulated column of the chart, the empty gap above the group is 1.41 on the log scale, from 2,922 to 12,000, against 1.8 × 0.32 = 0.57 required; the spread of the group is 0.014 of its distance to the main head, against 0.25 allowed; and the 12,000 lies 14 robust units from the main head and 56 from the group, against the declared 3.5: it is flagged by this scoring. The layers of step 3 then run inside each head large enough to be read, 40 values by default, on its own rows; a smaller head such as the group of 11 is protected by the rule above and only the points beyond an empty gap are scored against it.
A column of amounts sometimes looks as if it held two populations. Three situations must be kept apart, and the detector reports a second population in only one of them. Its rule is deliberately cautious:
- One skewed population. A long tail of large claims is the usual shape of insurance amounts, not a second population, and the detector does not invent one to explain it. On the skewed laws we measured, false second populations were rare: none for three log-normal laws, a gamma of shape 2 and a Weibull of shape 0.7, 4 draws in 180 for a gamma of shape 0.5, at most 1 in 180 for a Pareto and an exponential law. Heavier tails produce more, as stated below.
- A distinct group, clearly separated. A compact group of at least three points (the minimum is a declared setting), separated from all the other values by a clear empty gap, such as amounts entered in cents next to amounts in units, is reported as a possibly distinct population, and its points are not flagged for lying far from the main group. The report suggests checking how that group is coded with the owner of the data; the detector changes nothing.
- No clear gap. When the populations overlap, when a single point bridges them, or when the table is very large or the values very spread out, a second population is often no longer reported: the classical detection judges the mixture as a whole and flags the unusual points.
This safeguard is deliberately conservative; it is not a general mixture detector. When the evidence is ambiguous, the detector prefers to flag unusual observations rather than invent a second population. That caution has limits, measured on simulated data, that we state: on amounts whose logarithm follows a Student law with three degrees of freedom, about 4% to 7% of 480 draws showed a false second population of a few tail values, depending on the settings and on how a false population is counted, and between 8% and 16% of the draws on a symmetric law with tails as heavy (180 draws per bench); amounts coarsely rounded, to the hundred, were split into two false heads in two draws out of ten on our first case, and in 17% to 37% of 30 draws on later benches; an extreme value lying above a distant head can be absorbed into that head, where it is no longer flagged (one draw in ten on those rounded amounts); and a widely spread cloud of values can still, occasionally, be read as a population. The step does not run when the detector is fitted on the past alone for a backtest.
Each head found is described in a report: its count, its median, its range and how far it lies from the main group, with a note that suggests checking its coding with the owner of the data.
Step 5: nothing deleted, every flag coded and reviewable
The detector deletes nothing. Each flagged value carries the code of the rule that marked it, so that the reviewer knows whether a fence, the distance to the median, the moving average or the scoring against a head set it; the rows that follow a validated change of regime are marked; each validated change carries its date, its p-value and its effect size; each head is in the report of step 4. A person who knows the business can then confirm, correct or keep each flag. A copy of the data with the flagged cells replaced can be produced next to the original, never in its place. In our engagements, every correction, exclusion and cap is recorded with its reason, the number of records and the amounts affected, so that the results can be reproduced and challenged. Removing data because it is inconvenient is never a reason. Our article on data leakage covers the other way data can mislead a model.
Where it works, where it is fragile
The detector keeps three problems apart: a value extreme for its regime (step 3), a group of values that forms a population of its own (step 4), and a series that has changed for good (step 2). It works where the evidence is clear: in the measures made with the validation on its declared prior values (it now validates a change only under a frozen calibration, and none exists yet), on our simulated series, a change of level was found and validated in all 50 series that had one, and once the series was read regime by regime, every injected anomaly was found. Its time steps (the change of regime and the moving average) read the rows along a declared axis: the time column, or else, when it looks for changes of regime, the variable along which those changes are placed; the order of the file no longer matters. Rows that share the same date, such as several claims on one day, need a declared key to order them, otherwise the time steps are refused on those rows and the reason is named; without any axis there is no moving average. The results come back in the original row order, and the detectors that do not depend on time keep working. It is fragile in four measured places. On very persistent series, where each day keeps 80% of the previous day’s deviation, it cut 17 of 100 series that had no change (95% interval about 11% to 26%) and abstained on one; with the same default settings on series of 200 points, it cut 20 of 60 such series (33%) and 48 of 60 random walks (80%), abstaining on at least one candidate in only 21 of those 60, and calibrating the validation to the series at hand is an open fix. On clean log-normal amounts, its default settings flagged about 2% to 4% of the genuine values on average, up to 9% in one of 30 draws, now that the moving average no longer runs without a time axis (about 6% to 8% before, when it read the rows in file order). On amounts whose logarithm follows a Student law with three degrees of freedom, it reported a false second population in about 4% to 7% of 480 draws. On amounts rounded to the hundred, it split one population in two in 2 draws out of 10 on our first case, and in 17% to 37% of 30 draws on later benches. In every case the output is a flag to examine, never an automatic deletion: the detector deletes nothing, and these rates are why a person who knows the business reviews each flag.
After the review: keep the genuine large claims, and price them apart
Removing large claims makes a severity model look better and makes the tariff too cheap. The usual treatment is to cap each claim at a threshold in the rating model and to price the excess separately, as a loading spread over the portfolio or over the segments that generate it. Above a high threshold, extreme value theory, a generalised Pareto distribution for the excesses, usually describes the tail better than a single distribution fitted to the whole range. That is a pricing step, after the review: our detector only flags the large claims, it does not model their tail.
Technical details
The number of simulated series of step 2 is derived from the level of the test, not chosen: is the smallest number for which the Monte Carlo standard error of a p-value at the level stays within 0.005,
at , the rule at the time of the measures; the current version also holds that precision at the stricter level , which raises . No p-value can fall below : a change at the floor of the simulation is one that none of the 1,900 simulated series without change matched. The seed of the simulation is derived from the data, the window and the settings, so the same call always gives the same draws, and two windows never share them. The mean block length is estimated with the rule of Politis and White, as corrected by Patton, Politis and White.
References
J. W. Tukey (1977), Exploratory Data Analysis, Addison-Wesley; B. Iglewicz and D. C. Hoaglin (1993), How to Detect and Handle Outliers, ASQC; M. M. Breunig, H.-P. Kriegel, R. T. Ng and J. Sander (2000), “LOF: identifying density-based local outliers”, ACM SIGMOD; R. Killick, P. Fearnhead and I. A. Eckley (2012), “Optimal detection of changepoints with a linear computational cost”, Journal of the American Statistical Association; H. B. Mann and D. R. Whitney (1947), “On a test of whether one of two random variables is stochastically larger than the other”, Annals of Mathematical Statistics; N. Cliff (1993), “Dominance statistics: ordinal analyses to answer ordinal questions”, Psychological Bulletin; D. N. Politis and J. P. Romano (1994), “The stationary bootstrap”, Journal of the American Statistical Association; D. N. Politis and H. White (2004), “Automatic block-length selection for the dependent bootstrap”, Econometric Reviews; A. Patton, D. N. Politis and H. White (2009), “Correction to ‘Automatic block-length selection for the dependent bootstrap’”, Econometric Reviews; G. Schwarz (1978), “Estimating the dimension of a model”, Annals of Statistics; K. M. Ashman, C. M. Bird and S. E. Zepf (1994), “Detecting bimodality in astronomical datasets”, The Astronomical Journal.
More publications
PublicationsHow to analyse a time series: an econometric protocol
Stationarity, ADF and Phillips–Perron tests, Zivot–Andrews breaks, Granger causality, cointegration and error correction, step by step with worked examples.
Read the articleStatisticsTarget-guided reading of an unsupervised PCA: what one axis says about the outcome
Correlation circle, what an axis is made of, and how far an axis built without the outcome separates it: 91% of unseen tumours classified, about half of the linear separation.
Read the articleData qualitySerendipity through rigour: the findings nobody was looking for
Domain checks, cross-variable rules, reconciliations and totals split by part: how consistency checks uncovered more than ILS 1 million.
Read the articleLet’s build better decisions together
Tell us about the decision you need to make.
A few lines are enough: your sector, the data you have and what you want to improve. We reply personally with a first view of the approach.
- A few lines are enough
- NDA on request
- Code and documentation handed over


