Practical sessions — synthetic data

Download the session ZIP from its lecture card and extract it. Open the extracted folder as an RStudio project, or set it as the working directory with setwd(). Keep the data folder beside the practical .R file. Only base R is required. The student scripts run as supplied; TODO prompts are comments for students to complete.

Lecture 10: one-sample mean, employment rate, original jewellery ratios, synthetic regression.

Lecture 12: paired differences, independent Welch comparisons, percentage points, original PISA comparison.

Lecture 14: independence, sparse original election table, conditional Monte Carlo test, original die counts.

Each script gives objectives, prerequisites, a 90-minute route, guided work, independent exercises and interpretation prompts. The original examples are adapted from the supplied Thilo Klein material; youth data are newly simulated.

Data dictionary

data/synthetic_youth.csv: 240 fictional people, seed 20261005. Regenerate with Rscript generate_data.R from this folder. No confidential records or real programme findings.

VariableMeaning
idUnique simulated person ID, 1–240
ageSimulated age, 18–29 years
educationSchool, Vocational or University; mutually exclusive simulated groups
treatment1 = assigned to fictional programme; 0 = comparison. Exactly 120 in each group.
employed1 = employed at follow-up; 0 = not employed
earningsMonthly euros, zero if not employed; synthetic rounded non-negative earnings otherwise
score_beforeContinuous synthetic baseline interview score, arbitrary score units
score_afterFollow-up score with common time trend, simulated programme increment and noise

The generator uses independent education/age draws and balanced random programme assignment. Employment probabilities depend on education and assignment. Scores are generated with Gaussian noise. Earnings need not be normal: they include a point mass at zero. A model valid for interview scores is not automatically appropriate for earnings.

The Lecture 10 employment exercise uses comparison-group observations to illustrate a marginal iid Bernoulli model under this generator. It estimates a rate, not a treatment effect. Lecture 12 compares groups within a simulated random-assignment design. Interpretations never describe real empirical results.

The sparse election-table warning in Lecture 14 is intentional: students inspect expected counts and use conditional Monte Carlo inference. Record seed and replicate count. Student scripts that plot may create Rplots.pdf in a noninteractive run.