Search

Search papers and lessons

Selection Bias

Level 3 · 13 min read

Selection bias is distortion caused by how people end up in a study: if inclusion depends on the exposure, the outcome, or both, the association inside the sample can differ from the one in the population.

On this page

  • Colour = topic mix
  • Probability
  • Epidemiology
  • Methods
  • Sign in to see your progress

TL;DR

Selection bias happens when the people in a study are not a fair picture of the group the study is about, because of how they came to be in it. If being included depends on the exposure and the outcome, or on something that both of them cause, the association you measure inside the sample can be different from the association in the population, even when the two are unrelated out in the world. The fix is to understand the process that put people into the data before you interpret the numbers.

Where you'll see it: in hospital-based studies, volunteer surveys, trials that lose patients to follow-up, studies of people who are still working, and reviews that only see the studies that got published.

This lesson is an explanation of a statistical idea. It is not medical advice.

Intuition

A hospital that makes two diseases look opposed

Suppose two diseases, A and B, are completely unrelated in the general population. Having one tells you nothing about having the other. Now look only at patients in a hospital. The hospital admits people who have at least one of the two diseases. Among those admitted, a patient who does not have disease B is almost certain to have disease A, because they must have A to be there at all. A patient who does have B is much less likely to also have A, because B alone already explains the admission. Inside the hospital, the two diseases look negatively linked, even though they are independent in the world.

Nothing about the diseases changed. The act of selecting on something they both feed into created the association. This is the core of selection bias. The study population is a filtered version of the population of interest, and the filter depends on the variables under study.

flowchart LR
  A[exposure] --> S[selected into the study]
  Y[outcome] --> S
  A -.-> Y

The dashed arrow is the link we want to study, and in the scenario above it does not exist. The solid arrows show that both variables feed into the selection. Conditioning on S, which is what happens when we only analyse the selected people, opens a path between A and Y through the selection node.

The plot below shows the same effect in a single number. Let pp be the true probability of disease A in the population, with disease B at 10 percent. The dashed line is the population value. The solid curve is the probability of A among the people who were selected into the hospital, which is far from the population value.

00.20.40.60.8100.20.40.60.81p, probability of disease A in the populationprobability
  • population P(A)
  • P(A | admitted)
With B at 10 percent and A and B independent, the admitted group shows a much higher share of A than the population does. The point marks p = 0.1.

Two ways it happens

There are two common routes. The first is selection on something both the exposure and the outcome cause, which is the hospital story above. The second is selection on the outcome itself or on a quantity closely tied to it. Think of a trial in which patients who feel worse leave the study. Whether a patient is still in the data depends on how they are doing, and how they are doing is the outcome. The people left behind are no longer a fair comparison.

Selection bias is different from confounding. Confounding comes from a common cause of the exposure and the outcome in the whole population, and it is present before anyone is selected. Selection bias comes from the way the sample was formed, and it can happen even when no confounder exists. Both can be present in the same study, and they call for different fixes.

The math

Setup

Write AA for exposure, YY for outcome, and SS for an indicator that equals 1 when a person is in the study and 0 otherwise. The quantity we want is the population association:

E[Y∣A=1]−E[Y∣A=0],\mathbb{E}[Y \mid A = 1] - \mathbb{E}[Y \mid A = 0],

where the expectations average over everyone in the population. The quantity we can compute is the same contrast restricted to the study:

E[Y∣A=1,S=1]−E[Y∣A=0,S=1].\mathbb{E}[Y \mid A = 1, S = 1] - \mathbb{E}[Y \mid A = 0, S = 1].

Selection bias is the gap between these two contrasts. If SS is independent of YY once AA is fixed, the gap is zero, and the study is safe as far as selection goes. The gap is non-zero when the selection depends on the outcome in a way that differs between the exposure groups.

The collider case

Let XX and YY be two independent binary variables, with P(X=1)=pP(X = 1) = p and P(Y=1)=qP(Y = 1) = q. Let the selection be S=1S = 1 when X=1X = 1 or Y=1Y = 1 (or both). Then XX and YY are independent in the population, but a variable that is caused by both of them is a collider. Conditioning on a collider creates an association between its causes.

The probability of being selected is

P(S=1)=1−(1−p)(1−q)=p+q−pq.P(S = 1) = 1 - (1 - p)(1 - q) = p + q - pq.

Among the selected, the probability that X=1X = 1 is

P(X=1∣S=1)=P(X=1)P(S=1)=pp+q−pq.P(X = 1 \mid S = 1) = \frac{P(X = 1)}{P(S = 1)} = \frac{p}{p + q - pq}.

This is larger than pp whenever q<1q \lt 1, so selection makes XX more common than it is in the population.

Now condition on Y=0Y = 0 as well. If Y=0Y = 0 and S=1S = 1, then XX must be 1, because S=1S = 1 requires X=1X = 1 or Y=1Y = 1. So

P(X=1∣S=1,Y=0)=1.P(X = 1 \mid S = 1, Y = 0) = 1.

Among the selected people who lack YY, XX is certain. Among the selected people who have YY, XX is merely pp. The two conditional probabilities point in opposite directions from each other, which is the negative association that appeared in the hospital story.

Selection on the outcome

When selection depends on YY directly, the same algebra applies with SS as the variable that decides inclusion. If P(S=1∣A=a,Y=y)P(S = 1 \mid A = a, Y = y) differs across values of yy, then the outcome distribution among the included people is not the population distribution. The simplest case is loss to follow-up. If the people who die or feel worse are more likely to leave the study, the observed death rate among those who stay is a biased estimate of the true death rate, and the bias depends on how different the loss rates are between the arms.

Worked examples

Example
The hospital with two independent diseases

Take 10,000 people. Diseases A and B are each present in 10 percent of people, independently. The expected counts are:

B presentB absentTotal
A present1009001,000
A absent9008,1009,000
Total1,0009,00010,000

Step by step, if the hospital admits anyone with at least one disease:

  1. Admitted people are those with A or B. The count is 100+900+900=1,900100 + 900 + 900 = 1,900.
  2. Among admitted people with B present, the count with A is 100, out of 100+900=1,000100 + 900 = 1,000. So P(A∣admitted,B)=100/1000=0.10P(A \mid \text{admitted}, B) = 100/1000 = 0.10.
  3. Among admitted people with B absent, every admitted person has A, since the only way in is through A. The count with A is 900, out of 900 admitted. So P(A∣admitted,not B)=900/900=1.00P(A \mid \text{admitted}, \text{not } B) = 900/900 = 1.00.
  4. Check against the formula: P(X=1∣S=1,Y=0)=1P(X = 1 \mid S = 1, Y = 0) = 1 and P(X=1∣S=1,Y=1)=p=0.10P(X = 1 \mid S = 1, Y = 1) = p = 0.10, matching steps 2 and 3.
  5. Among all admitted people, P(A∣admitted)=1000/1900=0.526P(A \mid \text{admitted}) = 1000/1900 = 0.526, which is far above the population value of 0.10.

Interpretation: in the hospital, having B makes A look rare (0.10 versus 1.00 for those without B), so the two diseases appear to exclude each other. In the population they are independent. A researcher who studied only this hospital would find a strong association that is entirely produced by admission.

Example
A trial that loses sicker patients

Consider an invented trial with 1,000 people in each arm. The true five-year death risk is 10 percent in both arms, so the treatment has no effect. Patients who are doing badly are more likely to drop out, and deaths are not always recorded for them. The numbers below are made up to show the mechanism.

ArmRandomisedLost to follow-upDeaths among lost (unrecorded)Deaths among followedFollowed patientsTotal deaths
Control1,0002004060800100
Treated1,0001001090900100

Step by step:

  1. True risk in control: 100/1000=0.10100/1000 = 0.10. True risk in treated: 100/1000=0.10100/1000 = 0.10. True difference: 0.
  2. Complete-case risk in control, using only followed patients: 60/800=0.07560/800 = 0.075.
  3. Complete-case risk in treated: 90/900=0.10090/900 = 0.100.
  4. Complete-case difference: 0.100−0.075=+0.0250.100 - 0.075 = +0.025, which suggests the treatment is harmful.
  5. Complete-case risk ratio: 0.100/0.075=1.330.100/0.075 = 1.33, against a true ratio of 1.00.

Interpretation: the arms have different loss rates (20 percent versus 10 percent), and in the control arm the lost patients died far more often than the followed ones (40 of 200, or 20 percent, versus 60 of 800, or 7.5 percent), while in the treated arm they died at the same rate (10 percent). The analysed population in control is healthier than the full randomised group, so its death rate looks too low. Randomisation balanced the arms at the start, but the selection that happened afterwards broke the balance. The error is not in the treatment itself. It is in which patients the analysis is allowed to see.

Tradeoffs and failure modes

SituationWhat goes wrongBetter choice
Volunteer survey or self-selected sampleThose who respond differ from those who do not, often in the outcome itselfRandom sampling from a defined frame, plus reporting of response rates and comparisons with non-responders
Hospital or clinic-based case-control studyAdmission depends on both exposure and disease, which creates the collider patternPopulation-based sampling, or a design that does not condition on hospital admission
Loss to follow-up that differs between armsComplete-case analysis compares selected groups, and the bias can point either wayAnalyse everyone as randomised, use inverse-probability weighting, and run a sensitivity analysis on the missing outcomes
Studies of people who are still working (the healthy worker effect)Those who became too ill to work have left the study group, so the group looks healthier than the general populationInclude people who stopped working, or model the exit from work explicitly
Studies that only include people who survived to a time pointThose who died earlier are missing, so the observed group is filtered by the outcomeDefine the cohort at the start of exposure, and count all who began
Reviews that see only published resultsPositive findings are more likely to be published, so the pooled estimate is inflatedTrial registries, unpublished data, and funnel-plot checks, with the caveat that these checks can mislead when studies are few

A rule carries over from confounding. Do not adjust for a collider or for a variable that is itself affected by the exposure and the outcome. Adjusting for a collider, or analysing only the selected group, creates the association instead of removing it. Draw the causal graph first, and check whether the selection node sits on a path between exposure and outcome.

Randomisation does not remove selection bias from who enters the trial. It balances the arms among those who were enrolled. Who was enrolled, and who stayed, is a separate question, which is why a randomised trial can still give a biased answer when follow-up is uneven. The randomised trial is the standard design against confounding, and it still needs careful follow-up to protect against selection.

History

In 1946, the American statistician Joseph Berkson pointed out that studies of hospital patients can show associations between diseases that do not exist in the general population. His argument was about the mathematics of who gets admitted, and it was an early warning that the sample can manufacture a result. The effect now carries his name as Berkson's paradox.

During the Second World War, a statistical group working for the United States military analysed damage to returning bombers. The planes that came back had holes in some areas, and the obvious response was to armour those areas. Abraham Wald argued that the planes that did not come back were the ones that mattered, and that the armour should go where the returning planes were unhit. The story is often told as the origin of survivorship bias, which is a close relative of selection bias: the sample was filtered by survival, and the filter shaped what was seen.

Publication bias became a named problem as meta-analysis spread through the 1970s. In 1979, Robert Rosenthal described the "file drawer problem", the worry that null results sit unpublished while positive ones reach journals and then get pooled. The concept caught on because it explained why reviews of a literature could reliably overstate effects, and because the same logic applied to every stage at which a study could be filtered. The shared idea is that a conclusion is only as good as the process that decided which observations count.

Check yourself

QuestionIn one or two sentences, explain how selection bias differs from confounding bias.Show answer

Confounding comes from a common cause of the exposure and the outcome in the population, and it is present whether or not anyone is studied. Selection bias comes from the way the study sample was formed, so it depends on inclusion that is related to both the exposure and the outcome, or on a collider. A study can have both, and each needs a different fix, such as adjustment for confounders and changes to sampling or follow-up for selection.

QuestionIn the collider setup with p=0.2p = 0.2 and q=0.1q = 0.1, what is P(X=1∣S=1)P(X = 1 \mid S = 1)?Show answer

The probability of selection is P(S=1)=p+q−pq=0.2+0.1−0.02=0.28P(S = 1) = p + q - pq = 0.2 + 0.1 - 0.02 = 0.28. Then P(X=1∣S=1)=p/0.28=0.2/0.28=0.714P(X = 1 \mid S = 1) = p / 0.28 = 0.2 / 0.28 = 0.714, about 71 percent. The population rate of XX is 20 percent, so the selected group contains far more XX than the population does, and this happens without any link between XX and YY in the world.

QuestionWhy can a randomised trial still be biased by selection, even though randomisation balanced the arms?Show answer

Randomisation balances the characteristics of people at the moment they are assigned, which is the source of its protection against confounding. Selection can happen afterwards, through loss to follow-up or exclusion from analysis, and if that selection depends on the outcome and differs between arms, the analysed groups are no longer balanced. The balance was real at enrolment, and it was broken by who stayed in the data.

QuestionA study of a drug includes only patients who were discharged alive from hospital. Describe the risk of bias and a fix.Show answer

Patients who died in hospital are excluded, so the analysis is conditioned on survival until discharge. If the drug affects in-hospital death or the conditions that lead to it, the included group is filtered by a variable related to both the exposure and the outcome, which can distort the comparison in either direction. A fix is to define the cohort at the time treatment starts and include everyone who began, using methods that handle deaths as outcomes. This is an explanation of the statistics, not advice about the drug.

Sources