AdvancedIndependently reviewed, not yet spot-checked by a human

Selection bias

Selection bias is not the vague complaint that a sample "was not representative". It is a rule you can write down — who gets into the analysis. This page runs one cohort under four different attrition rules, against a fifth row in which everyone is kept, and shows that two of them leave the estimate untouched, one damages the risk ratio while sparing the odds ratio, and one wrecks both — and why adjusting for covariates cannot undo any of it.

It is not confounding, which is why adjustment cannot rescue it

Confounding means the two groups being compared were already different, and that difference affects the exposure and the outcome at once. It lives inside the data you collected, so as long as the variable was measured, putting it in the model handles it.

Selection bias means that who got into this dataset was itself determined by the exposure or by the outcome. It happens before the data exist. Every row you are holding has already been filtered. Put age, sex and every comorbidity into the model and it changes nothing about the people who were never selected, because they are not there.

Two diseases inside a hospital that look mutually exclusive but are not

Start with an example too clean to be misread. Two diseases exist in the population, with prevalences of 8% and 12%, and they are drawn independently in the code, so the true odds ratio between them is exactly 1. Neither affects the other, and they share no common cause.

The only thing that happens is this: having either disease raises your probability of being admitted. Someone with neither disease is admitted with probability 2.0%; someone with disease A alone with probability 36.3%, someone with disease B alone with probability 31.4%, and someone with both with probability 55.4%. That last cell is the engine of the whole thing: people who have both diseases are the easiest of all to get admitted, so inside the inpatient population “has both” is relatively magnified while “has neither” is all but emptied out — and most of what remains has one disease or the other.

Who is analysednOdds ratio between A and B
The whole population400,0000.990
Inpatients only32,3170.097

Among inpatients the two diseases look strongly mutually exclusive. This is Berkson’s bias, also called admission rate bias. The mechanism is not mysterious: most people in hospital have at least one of the diseases, so within that group “does not have A” almost amounts to “has B”. The association was manufactured by the act of selection; it was never in the population.

Left panel: the horizontal axis is the admission probability of people with neither disease (log scale) and the vertical axis is the odds ratio between the two diseases among those admitted (log scale). The lower the admission probability, the further the odds ratio is pushed down, reaching about 0.02 at the left edge; it returns to 0.99, back against the horizontal dashed line drawn at the true value of 1, when the admission probability reaches 1, which is the whole population. Right panel: risk ratios (circles) and odds ratios (triangles) under five selection rules, each measure with its own dashed true-value line. Under the first three rules both estimates sit on their lines; under the fourth, where selection depends on the outcome only, the odds ratio of 1.61 is still on its line but the risk ratio has dropped to 1.34, clearly below it; under the fifth, where selection depends on the exposure and the outcome together, the risk ratio of 4.52 and the odds ratio of 7.32 both sit far above their lines.
Left: the more selective the hospital, the stronger the association it manufactures. Right: not every kind of selection creates bias, and one kind of selection does not damage the two effect measures equally.Plotting script figures/scripts/B8-03-selection-bias.R

The curve in the left panel deserves a second look, because it is continuous. A hospital is not a switch that is either biased or unbiased; the more specialised it is and the higher its admission threshold, the stronger the association it manufactures. At the far left, an admission probability of 0.5% pushes an odds ratio whose true value is 1 down to 0.025. At the far right, where everybody is “admitted”, the estimate returns to 0.990 — that cell simply is the whole population.

Four rules for who is missing from the analysis, with completely different costs

Berkson’s bias is the extreme case. The commoner problem is loss to follow-up in a cohort: some people are not followed to the end. Below, the same cohort — 400,000 people, of whom 40% are exposed — is analysed five times. The true risk ratio is 1.5 (risk in the unexposed is 10%) and the true odds ratio is 1.588.

The first row is the baseline in which everyone is analysed. The second is loss unrelated to both the exposure and the outcome, where every person is retained with the same probability of 35%. The three rows meant to be compared with one another are the third to the fifth: in those, the retention probability is always one of 90% or 20%, and the only thing that differs is what decides which of the two a person gets.

Who staysn analysedRisk in unexposedRisk in exposedRisk ratioOdds ratio
Everyone analysed400,0009.9%15.1%1.5231.616
Loss unrelated to both139,0369.9%15.1%1.5261.620
Loss depends on exposure192,1039.9%15.0%1.5161.608
Loss depends on outcome114,31032.9%44.1%1.3411.610
Loss depends on both97,0379.8%44.3%4.5187.318

The benchmark to compare against is the first row, not the theoretical truth. This is one draw of the simulation, so the 1.523 and 1.616 in that row are the answer this dataset gives when nobody is lost at all, and the gap between them and the theoretical values is the scale of the simulation’s own noise. Read row by row, the table says four different things:

  • Loss unrelated to both exposure and outcome (second row) — even after discarding more than six people in ten, both estimates are still on the truth. What was lost is precision (the confidence interval widens), not correctness.
  • Loss that depends on the exposure only (third row) — also unbiased. This row is the one most often misread: “the exposed group was followed up much more completely” sounds alarming, but as long as, within each exposure stratum, the people who stayed have the same risk as the people who left, the risk inside each stratum is untouched — and the risk ratio is a ratio of within-stratum risks.
  • Loss that depends on the outcome only (fourth row) — the risk ratio falls to 1.341, but the odds ratio is 1.610, essentially unmoved. The next section is about exactly this.
  • Loss that depends on both exposure and outcome (fifth row) — a risk ratio of 4.52 and an odds ratio of 7.32, overstating the truth by factors of 3.0 and 4.6 respectively.

Why case-control studies report odds ratios and not risk ratios

The fourth row above was not a coincidence; it is an algebraic fact. Sampling on the outcome multiplies the odds within every exposure stratum by the same constant, so the ratio between strata is unchanged. Risk has no such property: risk is capped at 1, so multiplying it by a constant compresses it.

A case-control study does precisely this — find the cases first, then find the controls. It is the fourth row by construction. So reporting an odds ratio rather than a risk ratio is not a convention or a preference: the odds ratio is the only one of the two that remains estimable under that sampling design.

If you know the selection probability you can weight it back — and knowing it is the hard part

The wrecked estimate in the last row — the first row of the table below, which is the same draw and the same people as the fifth row above — can be repaired: if you know each person’s probability of being retained, use its reciprocal as a weight — inverse probability of selection weighting — and scale the survivors back up to the group they stand for.

Risk ratioOdds ratio
Analysing the survivors directly4.5187.318
Weighting by the inverse selection probability1.5321.626
The truth1.5001.588

After weighting, both estimates return to the neighbourhood of the truth. But the demonstration cheats in one specific way, and that is the point: in a simulation the selection probability is hard-coded, so it is known to the last decimal place.

In a real study nobody knows that probability. All you can do is build a model that predicts it from the variables that happen to be recorded on the people who stayed and the people who left — and if any part of the reason for leaving went unrecorded (deteriorating disease, moving away, an unreported death), that model is systematically wrong and the weighting only relocates the error.

The named biases in clinical research, and which row each one is

NameWho is filtered outWhich row above
Berkson / admission rate biasOnly inpatients are seen, and both diseases raise the chance of admissionMore extreme than the fifth row: selection depends on the “exposure” and the “outcome” at once
Healthy worker effectPeople in employment are healthier than the general population, and whether they can stay employed is related to the exposureFifth row
Prevalent user biasOnly current users of a drug are enrolled, so early discontinuers and early deaths are excludedFifth row
Volunteer / response biasPeople who agree to take part or return a questionnaire differ from non-responders in both exposure and outcomeFifth row
Differential loss to follow-upExposed people who have the event are especially likely to disappearFifth row
Sampling on the outcome (case-control)Deliberate sampling on the outcomeFourth row — this is a design, not a bias, as long as you report the odds ratio
Sampling on the exposure (exposure cohort)Deliberate sampling on the exposureThird row — also a design

What to look for when reading a paper

  1. Every box in the flow diagram needs a number and a reason. If the CONSORT or STROBE diagram just says “n excluded” without the reasons and the count for each reason, a reader cannot tell whether this is the third row or the fifth.
  2. Loss to follow-up must be reported by group. One overall rate can hide differential loss; separate rates for the exposed and the comparison group cannot.
  3. Baseline characteristics of those lost. A good paper includes a table comparing those who stayed with those who left. Without it you can only take the authors’ word for it.
  4. Look in the eligibility criteria for phrases like “currently taking”, “able to attend follow-up”, “consented to participate”. Each of those defines a selection rule.
  5. Where the controls came from. Hospital controls, neighbourhood controls and population-registry controls have entirely different bias structures.

Run it yourself

set.seed(20260823)
n <- 200000

# A cohort with a known truth: risk 0.10 unexposed, risk ratio 1.5
E <- rbinom(n, 1, 0.4)
Y <- rbinom(n, 1, ifelse(E == 1, 0.15, 0.10))

rr <- function(e, y) mean(y[e == 1]) / mean(y[e == 0])
rr(E, Y)                                  # the truth, computed on everybody

# Selection that depends on the exposure ONLY — still unbiased
keep <- rbinom(n, 1, ifelse(E == 1, 0.9, 0.2))
rr(E[keep == 1], Y[keep == 1])

# Selection that depends on BOTH — this is the one that breaks
keep2 <- rbinom(n, 1, ifelse(E == 1 & Y == 1, 0.9, 0.2))
rr(E[keep2 == 1], Y[keep2 == 1])

# Weight back by the inverse of the (here: known) selection probability
p  <- ifelse(E == 1 & Y == 1, 0.9, 0.2)[keep2 == 1]
Es <- E[keep2 == 1]; Ys <- Y[keep2 == 1]; w <- 1 / p
wrisk <- function(g) sum(w[Es == g] * Ys[Es == g]) / sum(w[Es == g])
wrisk(1) / wrisk(0)

Verified with R 4.6.0. Every number on this page is simulated, with the seed fixed at 20260823.

Common misuses

MisuseWhy it is wrong
“Adjusting for selection bias” with a multivariable modelAdjustment handles confounding inside the data; the people who never entered the data are not in the model
Declaring bias whenever loss to follow-up is highLoss unrelated to both exposure and outcome costs precision only
Declaring no problem whenever loss to follow-up is lowA small but highly differential loss can still reverse a conclusion
Reporting only the overall loss-to-follow-up rateDifferential loss is visible only in the group-specific numbers
Reporting a risk ratio from a case-control studyAfter sampling on the outcome the risks are no longer population risks; only the odds ratio remains estimable
Using hospital controls without discussing how the control condition relates to the exposureThat is precisely the doorway to Berkson’s bias
Enrolling only current users of a drug and calling it a cohort studyPrevalent user bias; early discontinuation and early events are systematically excluded
Reporting an IPW correction without describing the weight modelThe credibility of the correction comes entirely from that model’s assumptions; not stating it is not reporting it

Reproducing every number on this page

/opt/homebrew/bin/Rscript figures/scripts/B8-03-selection-bias.R

Read the figure

The answer comes from the same statistical output that produced this page's figures, not from a number typed in beside them.

Disease A and disease B are drawn independently in the population, so the true odds ratio is 1 and the whole population returns 0.990. What does the odds ratio become among admitted patients, and what does that mean?

Show the answer and why

Correct answer: 0.097. Inside the admitted group the two diseases look strongly mutually exclusive, and that association was created by the act of looking only at admissions

0.097 is the odds ratio among admissions, and the population value of 0.990 has already told us there is no real association. The gap is not sampling error but selection itself: most admitted patients have at least one of the diseases, so within that group not having A almost amounts to having B. Neither 0.784 nor 0.025 is the cell for these admissions - both come off the curve in the left panel, which recomputes the same quantity under some other admission threshold. Taking one of them as the answer here is answering about a different hospital, and the bias is not large enough to matter that rides along with 0.784 is what that swap buys. As for biological antagonism, the two diseases are drawn independently in the simulation, so no mechanism could produce it. Turning an association manufactured by selection into a statement about the diseases is the misreading this page most wants to stop.

The same cohort is run under five loss rules. In the third row, loss depending on exposure only, 90% of the exposed and just 20% of the unexposed are retained, which sounds severe. What is its risk ratio?

Show the answer and why

Correct answer: 1.516, almost exactly the everyone-analysed baseline. As long as within each exposure stratum those who stay and those who leave carry the same risk, the within-stratum risks are untouched

1.516 is essentially the everyone-analysed baseline, so this row carries no bias. A risk ratio is the risk within the exposed stratum divided by the risk within the unexposed one, and letting exposure decide who stays changes how many are in each stratum, not the risk inside it - both strata are thinned at random and the ratio survives. That is also why a cohort sampled on exposure is a design rather than a bias. 4.518 is the fifth row, where loss depends on exposure and outcome together and both stratum risks are distorted, which is how it reaches that scale. 1.341 is the fourth row, where loss depends on the outcome only and pulls down the risk ratio while leaving the odds ratio alone. All three rows lose a large share of the cohort and the cost is entirely different, so the question is never how much was lost but what rule decided it.

The fourth row, loss depending on the outcome only, pulls the risk ratio down to 1.341. What is the odds ratio in the same row, and why does it matter?

Show the answer and why

Correct answer: 1.610, essentially unmoved. Sampling on the outcome multiplies the odds within each exposure stratum by the same constant, so the ratio between them is unchanged - which is why case-control studies report odds ratios

1.610 is almost identical to the everyone-analysed row, so loss depending on the outcome alone leaves the odds ratio untouched. The algebra is that it multiplies the odds within every exposure stratum by one constant, so the ratio survives; risks have no such property, because a risk is bounded above and multiplying it compresses the result, which is where the same row's risk ratio of 1.341 comes from. 7.318 is the fifth row, where loss depends on exposure and outcome together and not even the odds ratio survives. 1.588 is the theoretical truth, but the comparison this table asks for is the first row, not the theory: within one draw, the first row is the answer this dataset would give with no loss at all. A case-control study samples on the outcome by construction, so reporting an odds ratio rather than a risk ratio is not convention but the only estimate that design still supports.

The second and fifth rows lose comparable shares of the cohort. Which statement is right?

Show the answer and why

Correct answer: The second row loses over six tenths and its risk ratio is still 1.526, matching the everyone-analysed row - how much was lost is not the test, what rule decided it is

1.526 is the second row: after losing more than six tenths of the cohort the risk ratio still matches the everyone-analysed one, because loss unrelated to exposure and to outcome costs precision rather than validity. 4.518 is the fifth row, which loses a comparable share and has its estimate destroyed - so the share lost cannot be the test, and the rule that decided it must be. 1.523 is the everyone-analysed first row, and attaching it to the fifth row produces exactly the opposite conclusion. What to chase in practice is whether people who had the outcome in the exposed arm were unusually easy to follow up. A paper reporting one overall loss figure leaves that unanswerable, which is why loss by arm and the baseline characteristics of those lost are what to look for.

The destroyed estimate in the fifth row is reweighted by the inverse of the selection probability. What does the risk ratio return to, and does that make the method usable in a real study?

Show the answer and why

Correct answer: It returns to 1.532, hugging the truth. But the selection probability was hard-coded in the simulation, and a real study can only estimate it from recorded variables - get that wrong and weighting just moves the error

1.532 hugs the truth, so weighting really does rescue the fifth row: it scales those who stayed back up to the group they represent. But the demonstration cheats, and that is the point - the selection probability is written into the simulation, exact to every decimal. No real study knows it. It has to be estimated from variables recorded on both those who stayed and those who left, and if any part of why people left went unrecorded - deterioration, moving away, an unreported death - that model is systematically wrong. 4.518 is the unweighted row, and a weighting that left the point estimate alone would not be a correction at all. 1.500 is the theoretical truth, and the weighted estimate lands near it rather than on it; reading near the truth as bias removed is where this method is most often over-read. What weighting really produces is a set of checkable assumptions: what went into the weight model, and why those variables suffice.

The horizontal axis of the left panel is the admission rate among those with neither disease. As it widens from 0.5% out to everybody, what does the odds ratio do?

Show the answer and why

Correct answer: It climbs from 0.025 back towards the truth. A hospital is not an on-off switch for bias - the higher the admission threshold, the stronger the association it manufactures

The curve is continuous: at the left end, where the threshold is strictest, a true odds ratio of 1 is squeezed to 0.025, and at the right end, where everyone counts as admitted, it returns to 0.990 - and that point is the whole population. The size of the bias is therefore a function of how selective the hospital is, not a yes-or-no question. 0.990 is the rightmost point, and treating it as the shape of the whole curve claims that selection causes no bias, which the 0.025 at the other end refutes. 0.591 sits in the middle of the curve and has the direction wrong too: as the threshold loosens, more of those with neither disease are admitted, so the association moves back towards the truth rather than further from it. When reading a hospital-based case-control study, ask where the controls came from and whether their reason for admission is related to the exposure.

Watch next

Principles of Epidemiology 09. Case-Control Study 2: M-H Methods & Selection Bias
繁中臺大開放式課程 NTU OCW· 68 minAn open course from National Taiwan University — lectured in Mandarin, with English slides. The second half is the most complete treatment of selection bias available in Chinese; watch it, then come back to the simulations on this page.
Confounding, chance, and bias
ENCochrane Austria· 10 minTen minutes separating confounding, chance and bias from one another. The first section of this page — that selection bias is not confounding — gets a slower version here.

Sources and licences

This page is original writing

Report a content problem

The statistics on this site are written by AI and reviewed by AI; a human only spot-checks. What you can see may be what we cannot.

The more specific, the more fixable — e.g. which sentence disagrees with which textbook or paper.

Needed only if you want a reply; reports without it are still read.

Sent along with your report

These are attached automatically. You can drop any of them.