Introduction & data summaries
Vocabulary and description. No inference yet — the job is to say what a data set is and describe it honestly.
Try these first
Have a go before opening the solution. Getting stuck is the point — it tells you which idea below to go and read.
-
1
Classify the study
A hospital reviews records for 2,480 patients admitted with pneumonia. For each patient they record age (years), sex, insurance type (none / public / private), length of stay (nights), and whether the patient was readmitted within 30 days. They report that patients with no insurance were readmitted more often.
(a) Classify each of the five variables. (b) Which is the explanatory variable and which the response? (c) Is this observational or experimental? (d) Can the hospital conclude that lacking insurance causes readmission?UsesVariable typesCases, variables, and the data matrixObservational vs experimentalConfounding variablesThe two 'randoms'
Work it through
- Age — numerical, continuous. Length of stay — numerical, discrete (whole nights). Sex — categorical, nominal. Insurance type — categorical; you could argue ordinal (none < public < private) but nominal is the safer answer unless the question implies an ordering.
- Readmitted within 30 days — categorical, nominal, with two levels. A yes/no variable is categorical even when it is stored as 0/1.
- Insurance type is the explanatory variable, readmission the response — that is the direction the hospital suspects.
- It is observational. Nobody assigned patients to an insurance type; the researchers only recorded what was already true.
- So no causal claim. A confounder is easy to name: income. Lower income makes a patient both more likely to be uninsured and more likely to face the transport, medication and housing problems that drive readmission.
AnswerAssociation only. Without random assignment the hospital can say uninsured patients were readmitted more often, not that the lack of insurance caused it.
Where this goes wrongA confounder has to be linked to both variables. Naming one that touches only readmission earns nothing.
-
2
Summarize a skewed sample
Twelve patients' lengths of stay, in nights, are listed below. Compute the mean, median, standard deviation, Q1, Q3 and IQR. Identify any outliers using the 1.5×IQR rule. Then say which measure of centre and spread you would report, and why.1, 2, 2, 3, 3, 3, 4, 4, 5, 6, 7, 21
UsesDescribing a distributionMean/SD vs median/IQRBox plots and the 1.5xIQR rule
Work it through
- Mean: the values sum to 61, so x̄ = 61/12 = 5.08 nights.
- Median: with 12 values the middle two are the 6th and 7th, 3 and 4, so the median is 3.5 nights.
- Standard deviation: s = √( Σ(x−x̄)² / (n−1) ) = 5.30 nights. Divide by n−1 = 11, not by 12.
- Quartiles: split the ordered data at the median into two halves of six. Q1 is the median of the lower six = 2.5; Q3 is the median of the upper six = 5.5. IQR = 5.5 − 2.5 = 3.0.
- Fences: Q1 − 1.5×IQR = -2.00 and Q3 + 1.5×IQR = 10.00. The value 21 is above the upper fence, so it is flagged as an outlier. Nothing falls below the lower fence.
- The distribution is right-skewed with one extreme value, so report the median (3.5 nights) and IQR (3.0) — the robust pair.
- See how much the outlier moves things: drop the 21 and the mean falls from 5.08 to 3.64, while the median only moves from 3.5 to 3.0. That gap is what “robust” means.
Answerx̄ = 5.08, median = 3.5, s = 5.30, Q1 = 2.5, Q3 = 5.5, IQR = 3.0. 21 is an outlier. Report median and IQR.
Where this goes wrongDividing by n instead of n−1 gives 5.07 — a plausible-looking wrong answer.
-
3
Row proportions or column proportions?
Of 480 patients, 200 were uninsured and 280 insured. 34 of the uninsured and 21 of the insured were readmitted within 30 days.
(a) Build the contingency table. (b) What proportion of uninsured patients were readmitted? (c) What proportion of readmitted patients were uninsured? (d) Which of those two answers is the one the hospital's claim needs?Readmitted Not Total Uninsured 34 166 200 Insured 21 259 280 Total 55 425 480
UsesContingency tables, row vs column proportionsCases, variables, and the data matrix
Work it through
- (b) conditions on being uninsured, so divide by the uninsured row total: 34/200 = 17.0%.
- (c) conditions on having been readmitted, so divide by the readmitted column total: 34/55 = 61.8%.
- Same cell, 34, two completely different numbers — 17.0% and 61.8% — because they are divided by different totals.
- The claim is “uninsured patients are readmitted more often”, which compares readmission rates between insurance groups. That needs (b), the row proportion — and its comparison: insured readmission is 21/280 = 7.5%.
Answer(b) 17.0% of uninsured patients were readmitted. (c) 61.8% of readmitted patients were uninsured. The claim needs (b): 17.0% vs 7.5% for insured patients.
Where this goes wrongReading the question for what is held fixed is the whole skill. “Of the uninsured…” fixes the row; “of those readmitted…” fixes the column.
How it worksthe written version — read this instead of watching anything
This week is vocabulary, and the vocabulary is load-bearing: almost every later mistake traces back to misreading what kind of variable or what kind of study you have.
Start with the data matrix. Rows are cases, columns are variables, and n is the number of rows. Every variable is either numerical (arithmetic on the values means something) or categorical (it takes one of a set of labels). The test is not whether the value looks like a number — a zip code is stored as digits but averaging zip codes is nonsense, so it is categorical.
Describing a distribution takes four things, every time: shape, centre, spread, and unusual observations. Skew is named for the tail, so a distribution with a long right tail is right-skewed even though most of the data sits on the left.
Which summary you report follows from the shape. For roughly symmetric data use the mean and standard deviation. When the data are skewed or contain outliers, use the median and IQR — these are the robust statistics, meaning they barely move when one extreme value is added. Watch this in problem 2: dropping a single outlier moves the mean by more than a night while the median shifts by half of one.
The standard deviation divides by n − 1, not n. That is the sample standard deviation, and it is what every formula in this course expects. Box-plot whiskers reach the furthest point within 1.5×IQR of the box; anything past that is flagged as a suspected outlier — flagged, not deleted.
For two categorical variables, a contingency table cross-tabulates counts. Row proportions and column proportions answer different questions. Read the question for what is being held fixed: “of the uninsured…” fixes the row, “of those readmitted…” fixes the column.
Look up an idea
-
Cases, variables, and the data matrix
Rows are cases, columns are variables. n is the number of rows — getting this straight now prevents df errors later.
if the text is not landing Data basics -
Variable types
Numerical (discrete / continuous) vs categorical (nominal / ordinal). A zip code is categorical — test it by asking whether arithmetic on the values means anything.
if the text is not landing Data basics -
Describing a distribution
Four things every time: shape, centre, spread, unusual observations. Skew is named for the tail, not the bulk.
if the text is not landing Numerical data -
Mean/SD vs median/IQR
Mean and SD for symmetric data; median and IQR when skewed or when outliers are present. The robust pair barely moves when an extreme value is added.
if the text is not landing Numerical data -
Box plots and the 1.5xIQR rule
Whiskers reach the furthest point within 1.5xIQR of the box; anything past that is flagged as a suspected outlier.
if the text is not landing Numerical data -
Contingency tables, row vs column proportions
Which proportion you want depends on what the question holds fixed. Read the question for the conditioning group.
if the text is not landing Categorical data -
Simulation-based inference (the case study)
Shuffle the group labels many times and see how often chance alone produces a difference this big. Every p-value later in the course answers exactly this question with a formula instead of a shuffle.