Statistics Lab

One cohort. Three routes. Seven steps.

A complete worked introduction to medical statistics using the same synthetic group of older adults followed over time in Stata, SPSS and R. Follow the sequence or open the page you need.

The software changes; the statistical question does not. Each step explains the decision first, then gives equivalent syntax for all three packages.

Seven-step investigationStart at 01 or open the step you need

Analysis checkpoint

Set up once, then follow the investigation.

Work through these six prompts in order. Each one supplies what the next one needs.

1 · Before you start

You do not need to know a statistical test yet. Download the common teaching package and choose Stata, SPSS or RStudio. If the software is unfamiliar, use its first-contact guide before Step 01.

Words used on this page

Cohort
a defined group of people followed over time.
Exposure
the baseline characteristic or care being compared; here, medication review.
Outcome
a later health measure, such as disability at six months.
Observational study
researchers record care and outcomes rather than assigning treatment at random.
Association
an observed difference or pattern; it does not by itself prove cause and effect.
2 · Why this comes now

A reproducible analysis starts with the study design and checked data. The seven steps then build one argument in order: check, describe, compare, measure, model, examine confounding and report.

3 · Do this now
  1. Download the complete teaching package and keep its data and syntax files together.
  2. Choose one software route; keep the same route as you work through Sections 01–07.
  3. Read the cohort brief, then begin with the participant timeline and data audit.
Same step in Stata and SPSS

Stata uses the commented .do file and SPSS uses the matching .sps file. Their commands look different, but every numbered section answers the same epidemiological question and should lead to the same decision.

4 · Read this

Use the route map and codebook first. At this point, read variable meanings and the study timeline—not effect estimates.

5 · Ready to continue when

Your chosen software is open, the common CSV and syntax file are in one folder, and you can say who is followed, what the exposure is and which outcomes occur later.

6 · Next step 01 · Meet the cohort Define the timeline, import the common CSV and check that the file is safe to analyse.

Your epidemiological brief

Does structured medication review relate to better six-month health?

You have a cohort of 720 adults aged 65–96. Medication review was recorded at baseline; quality of life, disability, frailty, falls and emergency admission were then observed for six months. Review was not randomised, so people offered it may already have had greater clinical need.

DesignObservational cohort

Start with temporality, follow-up and measured baseline differences.

ExposureMedication review

Compare reviewed participants with those not reviewed.

TaskEstimate associations responsibly

Describe, compare, adjust and interpret without turning association into proof of effect.

Choose how to work

Follow the investigation or open one problem.

Common files

Download once. Use in any route.

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.

Continuous

Linear regression

Example: six-month EQ-5D-style score. Report an adjusted mean difference.

Binary

Logistic regression

Example: disability yes/no. Report odds ratios and, where useful, adjusted probabilities.

Ordered

Ordered logistic

Example: robust, pre-frail, frail. Check the proportional-odds assumption.

Count

Poisson / negative binomial

Example: number of falls. Check exposure time, zeros and overdispersion.

Time to event

Cox regression

Example: days to admission. Preserve censoring and check proportional hazards.

Open the full regression decision page

Worth keeping

Documentation, videos and statistical references.

Stata video tutorials

Short official videos covering the interface, data management, tests and models.

Open Stata videos

IBM SPSS resources

Official getting-started material, feature videos and documentation.

Open IBM resources

RStudio User Guide

Official guidance on the four panes, projects, source files and reproducible work.

Open the RStudio guide

Statistics at Square One

A concise BMJ reference for displays, tests and study design. The free online text is an older edition.

Open the BMJ reference

DAGitty

Draw causal diagrams and examine adjustment sets before choosing covariates.

Learn with DAGitty

Official manuals

Use software help alongside the worked pages; commands and defaults can change between releases.

Read An Introduction to R