Jennifer and 719 other synthetic participants form the six-month cohort.
Jennifer’s fictional teaching course
One cohort. One continuous analysis.
Follow Jennifer’s entirely fictional cohort from the study question and first data checks through description, comparison, measures of association, regression, confounding and final reporting.
One course, not seven separate pages. Work down this page in order on a first visit. Returning students can use the chapter links without leaving Jennifer’s story.
Fictional study background · course start
Jennifer is the opening case in a realistic synthetic cohort.
This teaching study was created to practise a complete observational analysis without real patient data. In a fictional UK general-practice network, 720 adults aged 65–96 were recorded at baseline and followed for six months. Jennifer, aged 82, is the opening participant case.
Jennifer lives alone, takes eight regular medicines and has a baseline frailty index of 0.34. A structured medication review was recorded at baseline; later outcomes were measured at six months. She makes the data human, but she and every other participant are fictional.
Estimate the adjusted association; do not claim that review caused the outcome.
Use effect estimates, uncertainty, assumptions and reproducible code throughout.
Your route through the course
Seven decisions on one page.
Work from 01 to 07
Each decision supplies information needed by the next. Begin with the cohort and finish with a reproducible interpretation.
Start Chapter 01 ↓Jump to one chapter
Every chapter stays in the same course and ends by stating what you learned.
Choose from all seven ↓Meet the cohort
Import, label and audit the common cohort before calculating anything.
Jump to chapter 01 ↓ 02Characterise data
Match counts, percentages, means, medians and plots to each variable type.
Jump to chapter 02 ↓ 03Compare groups
Use cross-tabs, chi-square or Fisher’s exact, Welch’s t-test and Mann–Whitney with purpose.
Jump to chapter 03 ↓ 04Measure association
Separate follow-up prevalence, incident risk and odds; choose measures the design supports.
Jump to chapter 04 ↓ 05Choose regression
Choose linear, logistic, ordered, count or time-to-event models from the outcome.
Jump to chapter 05 ↓ 06Understand confounding
Use causal thinking to distinguish confounders from mediators and colliders.
Jump to chapter 06 ↓ 07Complete the analysis
Run and report the whole workflow, with a reproducible record in each package.
Jump to chapter 07 ↓Chapter 01 · Meet the cohort
Start with people, time and the question.
What happened, and when?
- Participants
- Jennifer and 719 other entirely fictional adults aged 65–96, represented by one row each.
- Baseline
- Age, medicines, frailty, disability and whether a structured medication review was recorded.
- Follow-up
- Disability, quality of life, falls and hospital admission were recorded six months later.
- Main question
- Was baseline medication review associated with disability at six months after accounting for pre-specified baseline differences?
- Important limit
- Review was observed, not randomly allocated. The course estimates an association; it cannot prove that review caused the outcome.
Confirm 720 rows, one unique participant identifier per row, valid codes and plausible ranges.
A blank outcome is unknown, not “no disability”. Keep missing values visible and record the analysis denominator.
Name the population, exposure, comparator, outcome and six-month timeframe before calculating anything.
A trustworthy analysis begins with the study design and a safe data file, not with a test menu.
Go deeper · study design, populations and missing data →
Continue in this courseChapter 02 · Characterise data →Describe the whole cohort before comparing medication-review groups.Chapter 02 · Characterise data
Choose summaries that fit each variable.
| Variable | Type | Useful first summary | Why |
|---|---|---|---|
| Medication review | Binary category | Count and percentage | Shows how many participants are in each exposure group. |
| Age | Continuous | Mean and SD, plus range and plot | Centre and spread are useful when the distribution is reasonably regular. |
| Medication count | Count and often skewed | Median and IQR, plus distribution | A few high values can pull the mean away from a typical participant. |
| Frailty category | Ordered category | Count and percentage in each level | The order matters, but gaps between levels are not assumed equal. |
| Six-month disability | Binary outcome | Observed n, missing n and percentage | The denominator must exclude outcomes that were not observed. |
Write the cohort portrait before the comparison.
Describe who entered the study, the distribution of important variables and how much information is missing. Do not use baseline p-values to decide whether the groups are “the same”.
Variable type, distribution and missingness determine an honest summary.
One clear overall table, one useful distribution plot and a short clinical description of the cohort.
Go deeper · estimates, spread and statistical uncertainty →
Continue in this courseChapter 03 · Compare groups →Match each unadjusted question to the outcome that was recorded.Chapter 03 · Compare groups
Let the question and outcome choose the comparison.
| Question | Outcome | Useful approach | Read first |
|---|---|---|---|
| Did disability proportions differ? | Binary | Cross-tabulation; chi-square or Fisher’s exact test | Both proportions and their difference |
| Did mean quality of life differ? | Continuous | Group summaries, plot and Welch’s t-test | Mean difference and confidence interval |
| Did medication-count distributions differ? | Skewed count | Group distributions and a rank-based comparison when justified | Medians, IQRs and the shapes of both distributions |
A p-value does not tell you how large, important or causal a difference is. Report the observed group values, an effect estimate and its confidence interval before the p-value.
There is no universal “two-group test”; the recorded outcome and the target comparison matter.
A small comparison table that names the groups, method, estimate, uncertainty and assumptions.
Go deeper · follow a comparison from data to p-value →
Continue in this courseChapter 04 · Measure association →Turn the disability table into absolute and relative measures.Chapter 04 · Measures of association
Tell the same comparison on more than one scale.
| Baseline review | No disability | Disability | Observed total |
|---|---|---|---|
| No review | 400 | 112 | 512 |
| Review | 155 | 45 | 200 |
22.5% versus 21.9%
Disability was recorded for 45/200 reviewed participants and 112/512 unreviewed participants.
+0.6 percentage points
The reviewed group had about 0.6 more recorded disability cases per 100 participants. The confidence interval is essential.
Proportion ratio ≈ 1.03
The six-month outcome proportion was about 1.03 times that in the no-review group.
Odds ratio ≈ 1.04
The odds were similar, but odds are not probabilities and the estimate is still unadjusted.
Because disability was also present at baseline for some people, these are six-month outcome proportions, not risks of new disability. Always carry the denominator, time point and reference group with the estimate.
Absolute and relative measures answer different practical questions; neither should travel without uncertainty.
A plain-language sentence on the absolute scale and another on the relative scale.
Go deeper · interpret differences, ratios and their intervals →
Continue in this courseChapter 05 · Choose regression →Move from unadjusted measures to a model suited to the outcome.Chapter 05 · Choose regression
Start with the outcome, not the software menu.
Linear regression
Quality-of-life score → adjusted mean difference.
Logistic regression
Disability yes/no → adjusted odds ratio and useful predicted probabilities.
Ordered logistic
Robust, pre-frail, frail → proportional-odds model when its assumption is defensible.
Poisson or negative binomial
Number of falls → rate or count model after checking exposure time, zeros and overdispersion.
Cox regression
Days to admission → hazard ratio while retaining censoring information.
Jennifer’s primary model
Six-month disability is binary, so the course uses logistic regression. The model includes medication review and a pre-specified set of baseline variables. Its adjusted odds ratio is a conditional association, not automatic proof of cause.
Inspect coding, sparse categories, functional form, influential observations and whether the available events can support the planned parameters.
Regression choice follows the outcome, design and estimand; covariates do not rescue a poorly framed question.
Go deeper · choose covariates for the model’s purpose →
Continue in this courseChapter 06 · Understand confounding →Explain why reviewed and unreviewed participants may differ before follow-up.Chapter 06 · Confounding
Ask why people received the exposure.
Review was not random.
People taking more medicines or living with frailty may be more likely to receive a review.
The same features predict disability.
Baseline frailty and disability can influence both receipt of review and the later outcome.
Compare more similar participants.
Use age, sex, social circumstances, medication count and baseline health only when their causal role is justified in advance.
Adjustment is not randomisation.
Measurement error, model form and unmeasured causes can leave residual confounding.
Do not select confounders because their bivariate p-values are below 0.05. Use timing, subject knowledge and an explicit causal story.
A change from the crude to adjusted estimate can reveal important baseline structure, but it cannot prove every confounder was controlled.
A short table comparing crude and adjusted estimates, with one sentence explaining the chosen adjustment set.
Go deeper · causal diagrams and adjustment sets →
Continue in this courseChapter 07 · Complete the analysis →Bring the design, estimates, assumptions and limitations back together.Chapter 07 · Complete the analysis
Answer the question, not the software output.
- Reconcile the participants. Explain why the model may use fewer than the 720 people who entered the cohort.
- Lead with the estimate. Give the adjusted association and confidence interval before the p-value.
- State what was adjusted for. Link every covariate to the pre-specified causal rationale.
- Report diagnostics. Show that coding, functional forms, sparse data and influential observations were checked.
- Keep the conclusion observational. Describe compatibility, magnitude and uncertainty without saying the review caused disability.
- Preserve the record. Keep the data dictionary, syntax, output, decisions and final interpretation together.
A defensible final sentence
In this entirely fictional cohort, the adjusted estimate was compatible with lower odds of six-month disability among reviewed participants, but the confidence interval also included little or no difference. The observational design, missing outcomes and possible residual confounding limit causal interpretation.
A complete analysis is an argument connecting the question, design, data checks, estimates, uncertainty, assumptions and limitations.
Use the same structure in a dissertation: question in the Introduction, decisions in Methods, estimates in Results and limitations in Discussion.
Course summary
What Jennifer’s story has taught you.
Define who was observed, what happened first and what the design can support.
Match summaries to variable type, distribution and missingness.
Choose a comparison that answers the question and report magnitude before significance.
Use absolute and relative scales with denominators, reference groups and intervals.
Choose regression from the outcome and target quantity.
Use causal reasoning for confounding, not automatic p-value screening.
Join the decisions into a reproducible, appropriately cautious conclusion.
Common files
Download once. Use in any route.
The medication-review cohort
720 entirely synthetic adults aged 65–96, followed for six months. The data cover medication review, polypharmacy, frailty, disability, quality of life, falls and hospital admission. No real patients are represented.
Stata route
One fully commented do-file from import and checking to regression and saved outputs.
Download the Stata do-fileSPSS route
Equivalent reproducible commands for the Syntax Editor, including labels and models.
Download the SPSS syntax fileR route
Base R plus recommended MASS and survival packages, with a clean RStudio Project.
These data were designed for teaching. The medication review is observational, not randomised, so the crude comparison is deliberately confounded by baseline frailty. Do not use the simulated results for clinical decisions.
Model map
Start with the dependent variable.
The model is driven first by the type of outcome, then by the study design, dependence between observations, distribution and target measure. This is a starting map, not a substitute for checking assumptions.
Linear regression
Example: six-month EQ-5D-style score. Report an adjusted mean difference.
Logistic regression
Example: disability yes/no. Report odds ratios and, where useful, adjusted probabilities.
Ordered logistic
Example: robust, pre-frail, frail. Check the proportional-odds assumption.
Poisson / negative binomial
Example: number of falls. Check exposure time, zeros and overdispersion.
Cox regression
Example: days to admission. Preserve censoring and check proportional hazards.
Go deeper · software and statistical references
Stata video tutorials
Short official videos covering the interface, data management, tests and models.
Open Stata videosIBM SPSS resources
Official getting-started material, feature videos and documentation.
Open IBM resourcesRStudio User Guide
Official guidance on the four panes, projects, source files and reproducible work.
Open the RStudio guideStatistics at Square One
A concise BMJ reference for displays, tests and study design. The free online text is an older edition.
Open the BMJ referenceDAGitty
Draw causal diagrams and examine adjustment sets before choosing covariates.
Learn with DAGittyOfficial manuals
Use software help alongside the worked pages; commands and defaults can change between releases.
Read An Introduction to R