Repeated measures and crossover designs: measuring the same people more than once
To see if a blood pressure drug works, we measure twelve people at weeks 0, 4, 8 and 12. People start at very different blood pressures, so a small drop in the average is easily hidden by those differences. Move things yourself to see what changes when you follow the same people, and what you have to watch out for in return.
Short answer. If you measure the same people more than once, you can take away how different people are to begin with and compare only the change inside each person. That is why an effect shows up with fewer people. A crossover design gives every person both treatments, one after the other. The catch: values from the same person are alike, so you must not analyze them as if they came from separate people, and you have to watch for the first treatment's effect spilling into the next period (the carryover effect).
All data on this page (blood pressure, people, drugs A and B) is made up with a fixed-seed random number generator. This page explains statistical ideas only. It is not advice about any drug or treatment.
Both pictures show the same values. The left one joins each person's values with a line. The right one removes the lines and keeps only the weekly mean (blue) and spread (purple, mean ± 1 standard deviation). The sliders also move with the arrow keys. "Draw 12 new people" changes the seed and makes up twelve different people.
Definitions
The page explains with twelve or five people, but the definitions are the same for n subjects and any number of time points (or conditions). is the value of subject i at time point j.
- repeated measures design
- A design that measures the same subjects at two or more time points or under two or more conditions. Measurements from the same subject are not independent of each other.
- between-person variation, within-person variation, intraclass correlation
- Split a value as below into the mean at that time point , the subject's offset (variance ) and the noise of each measurement (variance ). Then is the between-person variation and the within-person variation. If b and ε are independent, the correlation of two values from the same subject is the intraclass correlation (ICC).
- paired t-test
- Take each subject's difference , then build the test statistic from the mean and sample standard deviation of the n differences. If the differences are independent and normal with mean 0, t follows the t distribution with n − 1 degrees of freedom.
- sphericity
- An assumption of repeated measures ANOVA with three or more time points: the variance of the difference is the same for every pair of time points.
- crossover design
- A design where each subject gets all the treatments being compared, one after another, and the order is set at random for each subject. A 2×2 crossover design has treatments A and B, the orders A → B and B → A, and two periods, with a washout period between them. A difference that comes with the period for everyone, whatever the treatment, is the period effect.
- carryover effect
- The effect of the treatment from an earlier period lasting into the measurement of a later period. In a 2×2 crossover design where only the A-first group has carryover, the estimate that averages the two orders' mean (A − B) has the expected value below (τ is the true difference between A and B).
- pseudoreplication and design effect
- Pseudoreplication is analyzing measurements that are not independent (repeated values from the same subject) as if they were independent observations. With m measurements per subject, the design effect is how many times larger the true variance of the mean is than it would be if the same number of measurements were all independent.
1. Between-person and within-person variation
Repeated measures means measuring the same person (or the same animal, the same dish of cells) two or more times. Measuring over time (weeks 0, 4, 8, 12) counts, and so does measuring the same person under different conditions (while taking drug A and while taking drug B).
Split the reasons values are spread out into two, and you can see why repeated measures help.
| What | In plain words | Example | Slider in the lab |
|---|---|---|---|
| Between-person variation | How much people's natural starting levels differ | One person usually sits at 120, another at 160 | Between-person spread |
| Within-person variation | How much the same person wobbles each time you measure | How they feel that day, the device, their posture | Within-person noise |
The lab makes up its data like this.
Each person's offset is drawn once and used at all of that person's weeks (its standard deviation is the between-person spread). The noise is drawn fresh at every measurement (its standard deviation is the within-person noise). If you take week 12 − week 0 for each person, the offset drops out, because both of that person's values contain the same offset. Only the true change and the noise are left. That is why the lines in the left picture have similar slopes no matter how big the between-person spread is.
If you treat the same values as "different people each week", like the right picture, you have to compare the difference in weekly means against the width of the clouds, which is mostly between-person spread. When that spread is large, the change is buried.
How alike are two values from the same person? When the only thing that differs between people is their starting level, as in this lab:
With the starting values that is 12² ÷ (12² + 3²) = 144 ÷ 153 ≈ 0.94. The bigger the between-person spread and the smaller the noise, the more alike one person's values are. Textbooks call this ratio the intraclass correlation (ICC).
Try this. (1) At the start (between 12, within 3, change −8) the mean drops from 145.5 to 137.2, by 8.3, but within one week people are spread out by 12.3 on average (standard deviation). The clouds on the right mostly overlap. On the left all 12 people went down, and the change per person has mean −8.3 and standard deviation 3. (2) Raise the within-person noise to 10: only 8 people go down, and the standard deviation of the change per person becomes 10. Comparing inside each person does not remove the noise. (3) Put the noise back to 3 and raise the between-person spread to 20: the clouds on the right now spread by 20, but the shape of the lines on the left and the change's standard deviation of 3 stay the same. Lower the between-person spread to 0 and the change is clear on the right too (spread 2.6). (4) From the starting values, set the true change to 0: 7 of the 12 people still go down. With no effect at all, about half go down from noise alone.
A before-and-after comparison cannot tell you it was the drug
The lab above follows one group over time. Even if blood pressure went down, this data alone cannot say whether it was the drug, the season, the natural course of the illness, or people getting used to being measured. If you only pick people whose blood pressure is high, their next reading tends to come back toward the average a little even if nothing is done (regression to the mean). So to talk about an effect you compare with a control group that lived through the same weeks (randomization and control groups), or you mix up the order as a crossover design does (section 7). What repeated measures give you is a sharper comparison, by taking away between-person variation. Telling cause apart is the job of the design.
2. Same data, two analyses: independent t and paired t
Now cut the time points down to two (week 0 = before, week 12 = after). There are two ways to compare the before and after means (t-test).
- Independent two-sample t-test: treat the 12 before values and the 12 after values as two groups of different people.
t = (after mean − before mean) ÷ √(s₁² ÷ n + s₂² ÷ n), where s₁ and s₂ are the sample standard deviations of the two groups. Here we use Welch's version, which does not assume the two groups have the same variance. - Paired t-test: first take each person's difference
d = after − before, then ask how far the mean of those n differences is from 0.t = d̄ ÷ (s_d ÷ √n)with n − 1 degrees of freedom, where d̄ is the mean difference and s_d is the sample standard deviation of the differences.
The top of both fractions is the same, because after mean − before mean = mean of the differences. What differs is the bottom, the standard error. The independent analysis has the between-person variation in it. The paired analysis does not.
| Analysis | Mean difference | Standard error | t | Degrees of freedom | p |
|---|---|---|---|---|---|
| Independent groups (Welch) | |||||
| Paired |
When the made-up data is created, the ρ slider splits the variance at one time point (100) into a between-person share (ρ) and a within-person share (1 − ρ). Changing ρ keeps the spread at one time point (standard deviation 10) and the true change (−5) the same. It only makes each person's before and after more or less alike. With the same seed, the same twelve people shift a little. The correlation r measured from the sample is a bit different from ρ. "Hand example (5 people)" switches to the numbers in section 4. The right picture estimates how many people you need to find a difference of 5 mmHg with standard deviation 10, a two-sided 5% test and 80% power.
Try this. (1) At the start (ρ = 0.8) the sample correlation is r = 0.83 and the mean difference is −5.41. The independent analysis has standard error 3.39, t = −1.6, p = 0.125, so it cannot tell the change apart from luck. The paired analysis has standard error 1.38, t = −3.91, p = 0.002. Same data. (2) Lower ρ to 0: r = −0.14, and the two analyses come out close (independent p = 0.053, paired p = 0.082). Pairing gives nothing here. This sample's r is slightly negative, so the paired standard error (3.1) is even larger than the independent one (2.9), and the paired test has 11 degrees of freedom against 21.9. (3) Raise ρ to 0.9: the paired standard error drops to 0.98 and p < 0.001. The independent analysis barely moves (standard error 3.27, p = 0.12). (4) On the right, a two-group design needs 63 per group, 126 people in all. The paired design needs 63 people at ρ = 0 (two measurements each, so the same 126 measurements), 32 at 0.5, 13 at 0.8 and 7 at 0.9.
The curve on the right uses these formulas (an approximation based on the normal distribution).
δ is the difference you want to find (5) and σ is the standard deviation at one time point (10). 1.96 is the cut-off for a two-sided 5% test and 0.84 is the point of the standard normal distribution that matches 80% power. The only difference between the two formulas is (1 − ρ), and that comes from the formula in the next section. With only ten or so people, the t distribution's cut-off is wider than 1.96, so you need a few more people than this estimate. The exact calculation is on the sample size page.
Wrong ways to read it. (1) The paired p = 0.002 does not mean "a 0.2% chance the drug does nothing". It means "the chance of a difference this big or bigger by luck alone, if there were no effect". (2) The independent p = 0.125 is not evidence of no effect. It means this analysis could not tell the change apart from luck. (3) Do not run both analyses and keep the smaller p. Which analysis to use is decided in advance by how the data was collected (are they the same people?). More on the hypothesis testing and p-values page.
3. How the formula is built: the variance of the differences
Why the paired analysis helps comes down to one formula.
Var is the variance, σ₁ and σ₂ are the standard deviations before and after, and ρ (rho) is the before-after correlation of the same people. We put the same data as the lab above (the ρ you chose, or the hand example) on a scatter plot and build the formula one step at a time.
Press "Next" to go one step at a time. A piece is added to the formula on top (the orange background marks the new piece), the picture changes by that step, and below you get the reason and this data's numbers. If you change the ρ slider or press "Hand example (5 people)" in section 2, this picture switches to the same data.
Written only as formulas, the steps above look like this. The last line uses the numbers of the hand example in section 4.
- Scatter plot:
Var(after − before) = ?Each dot is one person. What we want to know is how spread out each person's difference (after − before) is. The smaller that spread, the more clearly the mean difference shows. - No pairs (ρ = 0):
σ₁² + σ₂². For two unrelated values, the wobbles do not cancel in the difference. They add up. Even for a subtraction, the variances add (the same idea as "add two independent values and their variances add" on the probability distributions page). In the picture we pair each after value with somebody else's before value (by rotating the list) so the correlation is close to 0. With the starting data the shuffled correlation is 0.01 and the variance of the differences is 137.2, close to the sum of the two variances, 73.4 + 64.6 = 137.9. - High goes with high (ρ > 0):
− ?Back to the real pairs, the dots form a long cloud along the diagonal. Whoever was high before is high after. The starting data has correlation 0.83. If the two values move together, that shared part has to be taken away. - Take away the overlap:
− 2ρσ₁σ₂. The differenceafter − beforeis how far the dot sits above or below the diagonal (after = before), measured straight up or down. The closer the dots hug the diagonal, the shorter the lines. The amount the two values move together (the covariance) isρσ₁σ₂. The 2 is there because when you expand(after − before)²you getafter² − 2 × after × before + before², so the cross term shows up twice. With the starting data,73.4 + 64.6 − 114.9 = 23, and the variance measured directly from the differences is also 23. - Equal σ:
2σ²(1 − ρ). Put σ₁ = σ₂ = σ and you getσ² + σ² − 2ρσ² = 2σ²(1 − ρ). That is the no-pairs value2σ²times(1 − ρ). ρ = 0.8 gives one fifth, 0.5 gives half, 0 gives no change. If ρ is negative, the variance gets bigger. - So the standard error shrinks and t grows:
SE = √(σ₁² + σ₂² − 2ρσ₁σ₂) ÷ √n. The standard error of the mean difference is the standard deviation of the differences divided by √n. With equal σ it is√(1 − ρ)times the no-pairs value. The mean difference does not change, so t grows by one over that. With the starting data, real pairs give standard error 1.38 and t = −3.91; shuffled pairs give 3.38 and t = −1.6.
Try this. (1) With the starting data, go to step 4: 73.4 + 64.6 − 114.9 = 23 matches the variance of 23 measured directly in the strip. When you plug in the variances and correlation measured from the sample, the formula is not an approximation. It is exact. (2) Press "Hand example (5 people)" in section 2 and step through again: step 4 shows 40 + 22.5 − 54 = 8.5. (3) Lower the ρ slider to 0 and look at step 4: the orange lines get long, and the real and shuffled differences spread about the same.
4. Work it by hand: five people before and after
Blood pressure (mmHg) of five made-up people. These are the same numbers as "Hand example (5 people)" in section 2.
| Person | Before | After | Difference d = after − before | d − mean | (d − mean)² |
|---|---|---|---|---|---|
| 1 | 148 | 140 | −8 | −3 | 9 |
| 2 | 136 | 133 | −3 | 2 | 4 |
| 3 | 152 | 146 | −6 | −1 | 1 |
| 4 | 140 | 139 | −1 | 4 | 16 |
| 5 | 144 | 137 | −7 | −2 | 4 |
| Sum | 720 | 695 | −25 | 0 | 34 |
- Mean difference.
d̄ = −25 ÷ 5 = −5. The same as after mean 139 − before mean 144. - Variance and standard deviation of the differences.
s_d² = 34 ÷ (5 − 1) = 8.5,s_d = √8.5 ≈ 2.92. We are estimating from a sample, so we divide by n − 1 (the sample variance on the probability distributions page). - Standard error.
SE = 2.92 ÷ √5 ≈ 1.30. - t and degrees of freedom.
t = −5 ÷ 1.30 ≈ −3.83, with5 − 1 = 4degrees of freedom. - p-value. In a t distribution with 4 degrees of freedom, the chance that |t| is 3.83 or more (both sides) is about 0.019. It lies beyond 2.78, the two-sided 5% cut-off for 4 degrees of freedom.
The same calculation written as formulas looks like this.
The same numbers as two independent groups. The before variance is (4² + 8² + 8² + 4² + 0²) ÷ 4 = 160 ÷ 4 = 40 and the after variance is (1² + 6² + 7² + 0² + 2²) ÷ 4 = 90 ÷ 4 = 22.5 (distances from the means 144 and 139). Standard error √(40 ÷ 5 + 22.5 ÷ 5) = √12.5 ≈ 3.54, t = −5 ÷ 3.54 ≈ −1.41, Welch degrees of freedom about 7.4, p ≈ 0.20. The same mean difference of −5, but a standard error about 2.7 times larger.
Check with the formula. The covariance is (4 × 1 + (−8) × (−6) + 8 × 7 + (−4) × 0 + 0 × (−2)) ÷ 4 = 108 ÷ 4 = 27 and the correlation is 27 ÷ (√40 × √22.5) = 27 ÷ 30 = 0.9. Var(after − before) = 40 + 22.5 − 2 × 27 = 8.5, the same 8.5 as in step 2.
# The same calculation in Python (scipy)
from scipy import stats
before = [148, 136, 152, 140, 144]
after = [140, 133, 146, 139, 137]
stats.ttest_rel(after, before) # paired: t ≈ −3.83, p ≈ 0.019
stats.ttest_ind(after, before, equal_var=False) # independent (Welch): t ≈ −1.41, p ≈ 0.198
5. Key properties
| Property | In plain words | In the labs |
|---|---|---|
| Between-person variation drops out | The difference is taken inside each person, so starting levels cancel. What is left is the true change and the within-person noise | Section 1 lab, between-person spread at 20 |
| The gain depends on the correlation | The variance of the differences is 2σ²(1 − ρ). With ρ = 0 there is no gain and you only lose degrees of freedom. With a negative ρ it is worse | The ρ slider in section 2, step 5 in section 3 |
| Values from the same person are not independent | Counting similar values as separate makes the standard error too small and gives false "significant" results. The sample size is the number of people, not the number of measurements | Section 8 lab |
| Order gets mixed in | A later measurement also carries the passing of time, practice, tiredness and the effect of the earlier treatment | Period effect and carryover in section 7 |
| People drop out | Ask people to come back many times and some stop coming. If the reason they leave is tied to the outcome, analyzing only those who stayed is biased | Section 9 |
6. What you gain and what it costs
| What you gain | What it costs |
|---|---|
| Between-person variation drops out, so you get the same precision with fewer people | Dropouts: the longer the study and the more visits, the more people leave |
| Each person is their own comparison | Order effects: things that change by themselves over time (season, the course of the illness, regression to the mean) get mixed with the treatment |
| You can see a curve of how each person changes (who changes fast, who slowly) | Practice effects: doing the same test again makes people better at it |
| Fewer people to recruit, so less time and money | Fatigue effects: measure many conditions in one sitting and people get tired toward the end |
| Carryover: an earlier treatment lingers into a later measurement (section 7). And because measurements are alike, the analysis gets more complicated (sections 8 and 9) |
Order, practice and fatigue effects can be kept from piling up on one side by changing the order of conditions from person to person (a crossover design, balanced orders). Mixing the order only cancels effects that push everyone the same way. An effect that depends on the order, like carryover, stays (section 7).
7. Crossover design: everyone gets both treatments
In a crossover design each person gets both treatments one after the other (a new drug A and a comparison B, for example a placebo). The order is chosen at random for each person. Half get A first (A → B), half get B first (B → A). Between the two periods there is a washout period with no treatment, so the first treatment's effect can wear off. Two orders × two periods is called a 2×2 crossover, the most common form.
Each person has a value on A and a value on B, so the treatment effect can be compared inside each person, with all the benefits of repeated measures. Unlike the before-and-after comparison in section 1, mixing the order lets you separate "change from time passing" from "the treatment". The estimate is:
Twelve made-up people (6 A-first, 6 B-first). The true effect is "A lowers blood pressure by 6 compared with B". The period effect is how much everyone changes in period 2 (negative = lower). Carryover is the share of A's effect still there in period 2 with no washout; we made it halve with every week of washout. How fast a real drug wears off differs from drug to drug. "Without noise" means the estimate from the same people with the within-person noise set to 0, which is the expected value of the estimate.
Try this. (1) At the start (period effect −2, carryover 0) the A-first group's mean (A − B) is −2.9 and the B-first group's is −8.5. Look at one group alone and the period effect makes it too small in one group and too big in the other (−4 and −8 without noise). The average of the two is −5.7, and without noise it is −6, so the bias is 0. (2) Change the period effect to −6: the estimate is still −5.7 and the expected value still −6 (without noise, 0 in the A-first group and −12 in the B-first group). That is thanks to splitting the orders half and half. (3) Put the period effect back to −2, set carryover to 60% and washout to 0 weeks: the estimate is −3.9 (expected −4.2), so the effect looks smaller. The bias of 1.8 is 6 × 0.6 ÷ 2. (4) Make the washout 1, 2 and 4 weeks: A's leftover effect drops to 30%, 15% and 3.8%, and the expected estimate moves toward −6: −5.1, −5.55, −5.89.
Why the period effect cancels but carryover does not
Let τ (tau) be the true difference between A and B, "period" the change everyone gets in period 2, and "carryover" the leftover A effect in the A-first group's period 2 (on B). Without noise, the (A − B) of each group is:
| A-first group | B-first group | Average of the two | |
|---|---|---|---|
| On A | base + τ | base + period + τ | |
| On B | base + period + carryover | base | |
| A − B | τ − period − carryover | τ + period | τ − carryover ÷ 2 |
The period effect enters with a minus in one group and a plus in the other, so it cancels in the average. Carryover is only in the A-first group, so half of it stays. If the leftover pushes the same way as the treatment, carryover makes the effect look smaller than it is. Each person's base level drops out when you take A − B.
Carryover is hard to detect from the data. In a 2×2 design, carryover cannot be told apart from the treatment-by-period interaction, and the comparison that measures it is between people (one order group against the other), so it carries all the between-person variation and has little power (ICH E9, 3.1.2). That is why carryover is prevented in the design rather than checked in the data.
| When a crossover design works | When it does not |
|---|---|
| Long-lasting, stable conditions (chronic): period 1 and period 2 start from the same place | Illnesses that get cured and end (like infections): if people recover in the first period, there is nothing to compare in the second |
| The treatment's effect builds up fully within the period and fades soon after stopping | Treatments whose effect lasts a long time (surgery, a shot that works for a long time, training) |
| The washout can be long enough for the effect to wear off completely | The condition gets worse or better quickly, so each period starts from a different place |
| Example: bioequivalence studies (do two drugs with the same ingredient reach the same amounts in the body?) | Long studies where many people are likely to drop out between periods |
These conditions are stated in the crossover section of ICH E9: the condition should be chronic and stable, the drug's effects should develop fully within the treatment period, and the washout should be long enough for the drug's effect to reverse completely.
8. Counting similar values as if they were separate
Measure one person 10 times and you get 10 values, but those 10 share the same person's base level, so they are alike. Analyze them as if 10 different people were measured once each, and the standard error comes out smaller than it really is, and the p-value gets falsely small. Textbooks call this pseudoreplication.
We made the two groups with no difference at all (5 people per group, between-person standard deviation 5, within-person standard deviation 5). "Counted separately" puts the 5 × m measurements of each group into a Welch t-test as if they were different people. "Per-person means" puts in the 5 per-person means of each group. Both analyses look at the same 2,000 data sets. "Another data set" only changes the data in the left picture.
Try this. (1) At the start (m = 10), counting separately gives p < 0.05 in 836 of 2,000 runs (41.8%), while per-person means give 88 (4.4%). There is no effect, so about 5% is the right answer. (2) Lower m to 1: the two analyses become the same, both 5.0%. (3) Raise m to 20: the separate count climbs to 57.8%. The more you measure each person, the more often the wrong analysis is fooled. (4) The data set in the starting picture gives p = 0.087 counted separately and 0.292 with per-person means. Press "Another data set" three times: p = 0.005 counted separately, but 0.307 with per-person means.
Why. If you measure one person m times and average, the variance of that average is between-person variance + within-person variance ÷ m. Raising m only shrinks the second part. The between-person part only shrinks with more people. The separate count acts as if both parts were divided by the number of measurements, so its standard error is too small. By how much is roughly 1 + (m − 1) × ICC, called the design effect. This lab has ICC = 0.5 (between 5², within 5²), so at m = 10 it is 5.5: the variance is understated 5.5 times and the standard error √5.5 ≈ 2.3 times.
The sample size is the number of people, not the number of measurements. Measuring more often only makes each person's value more precise. Average per person before the analysis, or use an analysis that treats each person as a cluster (the mixed model in section 9).
Clustered data has the same problem. Patients from the same hospital (each hospital has its own way of treating and its own kind of patients, so they are alike), the two eyes of one person, many cells from one animal, cells grown in the same dish, students in the same class. "What was randomized?" is the unit of analysis. If whole hospitals were assigned to treatments (cluster randomization), the information you really have is less than the number of patients suggests, and the more alike patients within a hospital are, the closer it shrinks toward the number of hospitals. A familiar example for developers: in an A/B test, counting thousands of clicks from one user as if they were thousands of users is the same mistake.
9. Three or more time points, and missing data
With three or more time points (weeks 0, 4, 8, 12), one paired t-test is not enough. Two methods are common. Repeated-measures ANOVA treats time as a factor and each person like a block, which pulls out the between-person variation (analysis of variance, blocking). It needs the assumption that the differences between every pair of time points have the same variance (sphericity); when that fails, the degrees of freedom are reduced to correct for it. A mixed model writes the idea "give each person their own base level" straight into the formula. The value = 140 + this person's offset + change + noise from section 1 is exactly that shape, and each person can get their own slope too. It can use every value that is there, even when people are measured at different times or some values are missing. This page shows only the idea of the mixed model; it does not cover how the numbers are estimated (maximum likelihood and so on).
Adjusting for the starting value. When comparing two groups in a trial, you can put the starting value (baseline) into the regression together with the group and compare the final values. This is called analysis of covariance (ANCOVA) (correlation and regression). In a randomized trial it usually has more power than comparing the change scores (final − start) or only the final values, and when the starting and final values are very highly correlated, its advantage over the change score gets small (Vickers and Altman).
Missing data. Ask people to come back many times and some stop coming. The paired t-test only uses people who have both values, so it drops anyone who left. If the reason people left has nothing to do with the outcome, you just lose some precision. But if many people quit because the drug was not working, an analysis of only those who stayed is biased in the drug's favor. A mixed model, if the model is right, still estimates correctly when the reason for leaving is explained by values already measured, but if people left because of something never measured (how they were after leaving), no analysis can fix it from the data alone. So record why people left, and first design to reduce dropouts (shorter studies, fewer visits).
Where it is used
- Before and after treatment, recovery curves. Measure the same people's blood pressure, weight or pain score over several weeks to see the change and how fast it happens. To talk about an effect, use it together with a control group (clinical trial design).
- Crossover designs. Drugs that ease the symptoms of long-lasting conditions, and studies like bioequivalence where each person can take both drugs in turn.
- Matched-pair designs. Twins, a person's left and right side (drug in one eye, placebo in the other), two people matched on age and sex. Each pair is a block of size 2 (blocking).
- The lab. Measure the same cell culture over time, or the same animal before and after a treatment. Decide first whether the unit of analysis is the cell or the animal (section 8).
- In software. Measure speed before and after a code change on the same machine with the same input and compare in pairs, and the machine-to-machine differences drop out. On the other hand, counting many actions from one user as many users is the mistake in section 8.
Frequently asked questions
How do I choose between a paired t-test and an independent t-test?
By how the data was collected. If the same people (or people matched in pairs ahead of time) were measured twice, use the paired t-test. If the two groups are different people, use the independent t-test. Do not run both and keep the one with the smaller p-value.
If I measure each person many times, can I recruit fewer people?
More measurements make each person's value more precise, but they do not change how much people differ from each other. If the question is whether the treatment works for people, the sample size is the number of people. 1,000 measurements from 10 people is a sample of 10.
Is the paired analysis always better?
It helps when the two values from the same person are alike (a positive correlation). With a correlation of 0 there is nothing to gain and you only lose degrees of freedom; with a negative correlation it is worse. Still, if the data comes in pairs, use the paired analysis because it matches how the data was collected.
When can a crossover design not be used?
For illnesses that get cured and end (if people recover in the first period, there is nothing to compare in the second), for treatments whose effect lasts a long time, and when the condition changes a lot from one period to the next. Carryover is hard to detect from the data, so it is prevented in the design with a long enough washout period.
If the paired p-value is 0.002, is there a 99.8% chance the drug works?
No. A p-value is the chance of seeing a difference this big or bigger by luck alone if there were no effect. It is not the chance that there is an effect, and it is not the size of the effect. For size, look at the mean difference and its confidence interval. In a before-and-after study of a single group, you also have to ask whether the drop came from the drug or just from time passing.
Words
| Plain words used here | Textbook term |
|---|---|
| Measuring the same people more than once | Repeated measures, within-subject design. Measured over time: longitudinal data |
| One line per person | Spaghetti plot, individual profiles |
| Between-person / within-person variation | Between-subject variation / within-subject variation |
| How alike one person's values are | Intraclass correlation (ICC) |
| Comparing before and after in pairs | Paired t-test |
| Comparing two groups of different people | Independent two-sample t-test. Without assuming equal variances: Welch's t-test |
| How much the mean difference wobbles | Standard error (SE) |
| Everyone gets both treatments in turn | Crossover design. Two orders × two periods: 2×2 crossover (AB/BA) |
| A first, B first | Sequence |
| The break in between | Washout period |
| A change everyone gets in the later period | Period effect |
| An earlier treatment spilling into the next period | Carryover effect |
| Order, practice and tiredness getting mixed in | Order effect, practice effect, fatigue effect |
| Coming back toward the average | Regression to the mean |
| Counting similar values as separate | Pseudoreplication |
| How many times the variance was understated | Design effect |
| Grouped data, assigning whole groups | Clustered data, cluster randomization |
| A model that gives each person their own base level | Mixed model, mixed-effects model. Each person's base level is a random intercept |
| Analysis of variance with several time points | Repeated-measures ANOVA. Its assumption: sphericity |
| Adjusting for the starting value | Analysis of covariance (ANCOVA) |
| Missing values, people who stop coming | Missing data, dropout |
| A trial comparing two drugs with the same ingredient | Bioequivalence study |
Sources
- ICH, E9: Statistical Principles for Clinical Trials, 3.1.2 Crossover Design. Carryover as the chief difficulty, the 2×2 carryover test being a between-subject comparison with little power, the conditions of a chronic and stable disease and a long enough washout, and dropouts complicating the analysis.
- Stuart H. Hurlbert, Pseudoreplication and the Design of Ecological Field Experiments, Ecological Monographs. The term pseudoreplication and its definition.
- Stanley E. Lazic, The problem of pseudoreplication in neuroscientific studies: is it affecting your analysis?, BMC Neuroscience. Counting many values from one animal as separate.
- NIST/SEMATECH e-Handbook of Statistical Methods, 1.3.5.3 Two-Sample t-Test for Equal Means. The independent two-sample t-test and its degrees of freedom when the variances differ.
- SciPy documentation: scipy.stats.ttest_rel, scipy.stats.ttest_ind. We checked the hand example's t and p against these.
- Andrew J. Vickers, Douglas G. Altman, Analysing controlled trials with baseline and follow up measurements, BMJ. Adjusting for the baseline (ANCOVA) compared with change scores.
- NIST DLMF, §8.17 Incomplete Beta Functions. The incomplete beta function the labs use for areas under the t distribution.