Math for Causal Inference
All simulators

Selection on Testing

Only the tested enter the data: smoking can look protective against infection, and only the odds ratio can survive.

Day 57: Selection Bias in DAGs
SmokingInfectionTestedSmokers: infected, population5.0%Non-smokers: infected, population5.0%Smokers: positive among tested24.0%Non-smokers: positive among tested62.0%
risk ratio: population / tested
1.00 / 0.39
odds ratio: population / tested
1.00 / 0.19
share of population tested
7.0%

Only tested people enter the data. Testing depends on smoking (cough) and on infection (symptoms), so it is a collider. Set the true relative risk to 1 and watch smokers look protected among the tested. With no smoking effect on testing (selection on the outcome only), the odds ratio survives selection even though risks do not.