De-identification & Synthetic Data

Moderate · Methods & Study Design track · ~35 min hands-on + readings and quiz

← Back to the Methods & Study Design track

Two ways to work safely with sensitive data: remove identifiers, or generate realistic fakes.

What you’ll be able to do

  • Apply de-identification standards (e.g., HIPAA Safe Harbor)
  • Generate synthetic data for sharing and teaching
  • Recognize re-identification and fidelity limits

Overview

De-identification removes identifiers so data can be used more freely; synthetic data generates realistic but fake records. Both let you teach, demo, and prototype without exposing real people — your course already uses synthetic crash data this way.

Neither is magic. De-identified data can sometimes be re-identified by combining fields, and synthetic data can leak patterns or miss real structure. Check both before relying on them.

Practice activities

Activity 1 · Moderate — De-identify a sample

Time ~15 min · Tools ChatGPT Edu (fabricated data only)

Goal. Apply Safe Harbor-style de-identification and test re-identification risk.

Setup. Use this fabricated emergency department visit table:

Patient Name DOB Age Sex ZIP Visit Date Diagnosis Provider
Maria Santos 1992-04-15 34 F 19134 2026-03-10 Tibial fracture, pedestrian struck by vehicle Dr. Okafor
James Henderson 1954-11-02 71 M 19143 2026-03-12 Hip fracture, fall on broken sidewalk Dr. Okafor
Linh Nguyen 1998-07-22 27 F 19120 2026-03-14 Concussion, bicycle-vehicle collision Dr. Patel
Robert Jackson 1943-09-30 82 M 19104 2026-03-10 Subdural hematoma, pedestrian struck at crosswalk Dr. Amadi
Destiny Brown 2009-06-18 16 F 19131 2026-03-15 Wrist fracture, fell off e-scooter Dr. Patel

This is entirely fabricated — no real patients. But it contains the full range of HIPAA identifiers: names, dates of birth, exact ages, ZIP codes, visit dates, and provider names.

Steps.

  1. De-identify:

    Apply HIPAA Safe Harbor-style de-identification to this fabricated dataset (remove or generalize identifiers). Explain each change. [sample]

  2. Attack it:

    Now act as an adversary: could you re-identify anyone by combining the remaining fields with public data? Where’s the risk?

  3. Decide whether it’s safe enough or needs more generalization.

Expected result. A de-identified sample and an adversarial risk assessment.

Check your work. Age + ZIP + date is a classic re-identification combination — scrutinize it.

Common pitfalls. Removing direct identifiers isn’t enough; quasi-identifiers re-identify. Use fabricated data here.

Stretch (optional). Generalize further (age bands, 3-digit ZIP) and re-assess.

Activity 2 · Moderate — Generate and stress-test synthetic data

Time ~13 min · Tools ChatGPT Edu + R/Python

Goal. Make realistic synthetic data and check its fidelity.

Setup. Describe a dataset’s structure (columns, ranges, relationships). You can mirror the Philadelphia crash data structure.

Steps.

  1. Generate it reproducibly:

    Generate a synthetic dataset with these columns, realistic distributions, and plausible relationships. Give me R or Python code so it’s reproducible. [structure]

  2. Compare the synthetic distributions to what you’d expect (or to a public summary).

  3. Critique fidelity:

    Where is this synthetic data likely unrealistic or missing real structure?

Expected result. A reproducible synthetic dataset and a fidelity critique.

Check your work. Synthetic data can miss real correlations — don’t draw substantive conclusions from it.

Common pitfalls. Synthetic data is for teaching, prototyping, and sharing — not a substitute for real analysis. It can also leak patterns if generated from real data.

Stretch (optional). Use the synthetic set to test an analysis script before touching real data.

Activity 3 · Moderate — Generate and statistically validate synthetic data with Claude Code

Time ~15 min · Tools Claude Code + R/Python

Goal. Have an AI agent generate synthetic data and run real statistical fidelity checks against a reference — turning Activity 2’s prose critique into measurable numbers.

Setup. Claude Code is a command-line coding agent that writes and runs code in one session — so instead of copying code into R yourself, you watch it generate the data, compute the checks, and report the results. Reminder: Claude Code is a consumer/PI-purchased tool approved for Low Risk Data only — use only fabricated data like the structure below, never real records. Use the same Philadelphia crash structure from Activity 2, plus this fabricated reference summary to check against:

  • 62% of pedestrian crashes occur during daylight hours
  • 18% involve speeding
  • 44% occur at intersections
  • 12% result in a severe injury
  • Speeding crashes are roughly twice as likely to be severe as non-speeding crashes

Steps.

  1. In a terminal, ask Claude Code to generate the data reproducibly:

    Write and run an R (or Python) script that generates 500 synthetic pedestrian crash records with these columns: [structure]. Set a seed, use realistic distributions, and save it as a CSV.

  2. Then have it compute the fidelity check instead of just opining:

    Now compare the synthetic data against this reference summary: 62% daylight, 18% speeding, 44% at intersections, 12% severe injury, and speeding crashes about twice as likely to be severe. Compute each statistic from the synthetic data, show observed vs. expected side by side, and flag any variable off by more than 5 percentage points.

  3. Ask it to fix what diverged:

    Adjust the generation script so the flagged variables match the reference, re-run the comparison, and confirm everything is within tolerance.

Expected result. A reproducible synthetic dataset plus a computed observed-vs-expected comparison table — a fidelity check you can re-run, not a one-off prose answer.

Check your work. Matching marginal percentages doesn’t guarantee realistic relationships — verify the speeding-severity association actually holds in the synthetic data, not just the individual proportions.

Common pitfalls. An agent that runs its own code can also grade its own code — read the comparison output yourself rather than accepting “everything matches.” And a dataset tuned to match five reference statistics can still miss every other real-world pattern.

Stretch (optional). Ask Claude Code to also compare full distributions (not just means/proportions) — e.g., a chi-squared test on the hour-of-day distribution — and explain what the test does and doesn’t tell you.

Check your readiness

Answer these, then check — your score suggests whether to dive in or skim the readings first.

Useful resources