The dataset behind everything
The Farrlandia Census
All 10,000 residents of Farrlandia, enumerated: demographics, exposures, biomarkers, and health outcomes, generated from a documented causal structure so every association in the data has a knowable truth behind it. The interactive explorer shows a 1,000-person simple random sample of this census — Step 3 of the seven-step framework, made literal. Analyze the full census in whatever software you have.
farr <- read.csv("https://epidemiologymatters.com/farrlandia/census/farrlandia-census.csv")
table(farr$smoking, farr$lung_cancer)
prop.table(table(farr$cvd))
import delimited "https://epidemiologymatters.com/farrlandia/census/farrlandia-census.csv", clear tab smoking lung_cancer, row cs cvd heavy_alcohol
import pandas as pd
farr = pd.read_csv("https://epidemiologymatters.com/farrlandia/census/farrlandia-census.csv")
pd.crosstab(farr.smoking, farr.lung_cancer, normalize="index")
GET DATA /TYPE=TXT /FILE="farrlandia-census.csv" /DELIMITERS="," /FIRSTCASE=2. * Download the file first, then point FILE= at it. CROSSTABS /TABLES=smoking BY lung_cancer /CELLS=ROW.
Codebook
The 27 Variables
Binary variables are coded 1 = yes, 0 = no. There are no missing values — this is a census, and every resident answered every question. (Real data will never be this kind to you. That is also a lesson.)
| Variable | Type | Description |
|---|---|---|
| id | integer | Resident identifier (10001–99998). |
| age | years | Age at census, 18–79. |
| sex | female / male | Sex. |
| district | text | Residential district: Snow (industrial), Nightingale, Hill, Doll, Rose (most affluent). |
| ses | 1–5 | Socioeconomic position, 1 = lowest, 5 = highest. |
| education | text | Highest education: primary, secondary, tertiary. |
| occupation | text | Coal miner (Hill Colliery), factory worker (Snow), farmhand, service worker, office worker, student, retired, unemployed. |
| water_source | text | Household water: “snow pump” (the old pump serving District Snow’s poorest streets) or “municipal”. |
| insured | 0/1 | Has health insurance. |
| smoking | 0/1 | Current smoker. |
| pack_years | continuous | Cumulative smoking dose; 0 for non-smokers. |
| air_pollution | 0/1 | High residential air-pollution exposure (concentrated in Snow and Hill). |
| poor_diet | 0/1 | Diet quality below recommended. |
| physical_inactivity | 0/1 | Below activity guidelines. |
| heavy_alcohol | 0/1 | Heavy episodic drinking (more common under 40). |
| social_isolation | 0/1 | Socially isolated. |
| bmi | kg/m² | Body mass index. |
| systolic_bp | mmHg | Systolic blood pressure. |
| family_history_cvd | 0/1 | First-degree family history of cardiovascular disease. |
| cvd | 0/1 | Prevalent cardiovascular disease (≈7%). |
| depression | 0/1 | Prevalent depression (≈10%). |
| lung_cancer | 0/1 | Lung cancer, ever diagnosed (≈3%). |
| type2_diabetes | 0/1 | Prevalent type 2 diabetes (≈8%). |
| resp_infection_past_year | 0/1 | Respiratory tract infection, past year (≈18% overall; markedly higher in Hill — see Lesson E). |
| injury_past_year | 0/1 | Injury requiring medical attention, past year (≈11%). |
| clinic_visit_past_year | 0/1 | Attended the Farrlandia clinic in the past year (≈36%). Handle with care — see Lesson D. |
| followup_years | years | Person-years of follow-up in the Farrlandia cohort, 4.0–10.0. |
For instructors
Six Lessons Are Buried in the Data
The census was generated from a known causal structure, so these findings are guaranteed to be there when your students go looking. Assign the question; the data will keep its side of the bargain. (Census v1.1 — adds occupation, water source, and respiratory infection.)
A · Confounding
Smoking is associated with cardiovascular disease — but smoking is also patterned by age and socioeconomic position, which shape CVD on their own. Have students compare crude and adjusted estimates and say what changed, and why.
B · A masked effect
Crudely, heavy drinkers have the same CVD risk as everyone else. Stratify by age and the harm appears. The trick: heavy drinking is concentrated in the young, whose baseline risk is low. Confounding does not always exaggerate — sometimes it hides.
C · Interaction
The effect of smoking on lung cancer is roughly twice as large among residents with high air-pollution exposure as among those without. Two component causes completing the same sufficient cause — Chapter 11, in the data.
D · Selection (Berkson’s bias)
Restrict any analysis to clinic attendees and strange things happen: type 2 diabetes appears to protect against depression, an association that does not exist in the full census. Clinic attendance is a collider — both conditions bring people through its doors.
E · Structure and place
Respiratory infection runs at roughly 17% in four districts — and 29% in Hill, home of the Hill Colliery. Miners themselves carry the heaviest burden. Disease here is patterned by geography and occupation, not chance: ask students what a “district effect” is actually made of.
F · An innocent suspect
District Snow’s poorest households draw water from the old Snow Pump. Crudely, pump users have more CVD — but the pump is causally inert: its users are simply poorer. Adjust for socioeconomic position and district, and the pump is acquitted. Not every accused exposure is guilty; John Snow would want the analysis done properly.
Instructor’s answer key — expected values (spoilers)
Values your students should approximately reproduce (risk ratios; Mantel-Haenszel for adjusted):
| Lesson | Analysis | Expected |
|---|---|---|
| A | Smoking → CVD, crude / age-adjusted | ≈2.1 / ≈2.0 |
| B | Heavy alcohol → CVD, crude / age-adjusted | ≈1.0 / ≈1.6 |
| C | Smoking → lung cancer, RR by pollution stratum | ≈5 (low) vs ≈10 (high) |
| D | Diabetes → depression, full census / clinic only | ≈0.9 / ≈0.5 |
| E | Respiratory infection: Hill vs other districts; miners vs non-miners | ≈29% vs ≈17%; RR ≈2.9 |
| F | Snow Pump → CVD, crude / SES-district-age adjusted | ≈1.3 / ≈1.1 |
The census is simulated (fixed seed, generator documented in the site repository), so these values are stable across downloads. Sampling variability applies only to subsamples your students draw themselves.
Provenance
Where This Data Comes From
Farrlandia is simulated. Every resident was generated from a documented data-generating process with a fixed random seed, which is exactly the point: unlike real data, the truth behind every association is knowable, so methods can be tested against it. No real people are described by this dataset. Use it freely in courses, workshops, and problem sets, with attribution to Epidemiology Matters (Keyes, Abba-Aji & Galea, Oxford University Press).