People over Time
When is a finding about people a finding about a person?
In 1973 Herbert Clark showed that a generation of language studies tested generalization to new people but not to new words. The part simulates his fallacy (half of null studies significant), builds multilevel models and partial pooling, crosses participants with items and plans the number of stimuli, then turns to the deeper point: Simpson's paradox inside a person and person-mean centring, a non-ergodic population whose group correlation describes almost no one, experience sampling and the bias of inertia, cause over time, and critical slowing down before a tipping point, with the false alarms that noisy diaries bring.
What you need. Part 31's growth curves and Part 44's latent variables; regression, variance components and autoregression.
- Hook
- the language-as-fixed-effect fallacy, 1973
- Ideas, models and mathematics
- repeated measures, crossed random effects, growth models, experience sampling, within against between persons, ergodicity, cross-lagged panels, early-warning signals
- Psyche gains
- mixed models on the Pool
- On you
- Simpson's paradox inside one person
What you will be able to do
Psych 101 and the major
- Explain why stimuli must be treated as a sample, and what goes wrong when they are not.
- Recognize when a relation across people differs from the relation within a person.
Graduate
- Fit a multilevel model with random slopes, and explain partial pooling.
- Compute min F', plan the number of stimuli, and separate within- and between-person effects by person-mean centring.
- Estimate inertia from diary data and correct for its small-sample bias.
Research
- Argue which psychological processes could be ergodic, and design a test of critical slowing down that controls false alarms.
Practice
- Audit a product or health metric for whether it describes users or a user.
Contents
Each chapter has a home level. Choose a track to see what to read and watch: Psych 101 and the major 10 min · Graduate 26 min · Research 26 min · Practice 11 min.
- 0Twenty words, one conclusionPsych 101 and the major2 min
- 1On you: one cloud, and four numbersPsych 101 and the major1 min
- 2Repeated measuresGraduate2 min
- 3Random intercepts and slopesGraduate1 min
- 4Participants and items, crossedGraduate2 min
- 5Stimuli are a sample tooPsych 101 and the major2 min
- 6GrowthGraduate1 min
- 7Simpson inside a personPsych 101 and the major1 min
- 8Within against betweenPsych 101 and the major2 min
- 9ErgodicityGraduate2 min
- 10Intensive longitudinal dataGraduate2 min
- 11Cause over timeGraduate2 min
- 12Tipping pointsGraduate2 min
- 13The LedgerGraduate
- 14In practice: users, patients and dashboardsPractice1 min
- 15Frontier: the science of oneResearch1 min
- Recap, problems, and the road aheadAll tracks3 min
Also on this page: Lecture · Key results · Try it · Lab · Problems · Notes and sources · Build the film.
Lecture
The text of each chapter is the film's narration, as it is spoken, so you can read along or revise without the film. The pictures are in the film.
Twenty words, one conclusionPsych 101 and the major2 min
In 1973 the psychologist Herbert Clark looked at a generation of studies of language. They tested whether an effect would generalize to new people. They never tested whether it would generalize to new words. Psyche runs two hundred priming studies in which nothing works at all: thirty people, twenty words, and words that differ from one another. Analysed by participants only, about half come out significant. The promise was five percent. Treat the words as a sample too, and the rate returns to five percent or below. The fix took thirty years to become routine.
Clark's point is about generalizing across stimuli. There's a deeper version, the hardest in the series. A relation that holds across people need not hold within any one of them. Most psychological theories are about the second: what happens inside a mind when something changes. And most studies measure the first: many people, each measured once. This part is about telling them apart.
So this part asks when a finding about people is a finding about a person. Repeated measures and multilevel models. Participants and stimuli, both as samples. Within against between, and ergodicity. And lives in time: diaries, inertia, and tipping points.
This is Part 47 of Psychology, Built: people over time. We'll simulate the language-as-fixed-effect fallacy. We'll build multilevel models, watch them shrink, and cross participants with items. We'll ask how many stimuli a claim needs. We'll separate within-person from between-person relations. We'll build a population whose averages describe no one. And we'll follow lives in time: diaries, emotional inertia, and the warning signs before a tipping point.
What it does: Clark's fallacy, simulated; the deeper point; the question; objectives
1On you: one cloud, and four numbersPsych 101 and the major1 min
First, a cloud of points. Each dot is one occasion for one person: twelve people, fifteen occasions each. Across everyone, y falls as x rises. Now guess. For one person, on a day when their x is higher than usual, is their y higher or lower? On the course site you can see the same cloud, coloured by person.
Now four numbers. One: thirty people, twenty words, no effect, analysed by participants only. What's the false-positive rate? Two: in the cloud you just saw, when one person's x rises, does their y rise or fall? Three: two traits correlate zero point six across people. What share of people show about that correlation within themselves, over time? And four: a person's true day-to-day inertia is zero point four. Estimated from twenty days, what does it come out as, on average? Pause here, and write them down.
What it does: Guess one person's slope; four predictions
2Repeated measuresGraduate2 min
Most experiments measure each person many times. The traditional analysis averages the trials into one number per person per condition, and compares the averages. What's lost: how much people differ in the effect, how much trials differ, which stimuli were used, and how the effect changes over the session. And with unequal numbers of trials, every person counts the same, however well measured. A model of every trial keeps all of it: the multilevel, or mixed, model.
Here's the model. At the level of trials, each person has their own line: an intercept and a slope. At the level of people, those lines are drawn from a population of lines. Beta is the average effect. G says how much people differ in it. Sigma squared is the noise between trials. Nan Laird and James Ware wrote the general form in 1982. Statistics, Built fits it in its Part 25, and this part uses that code.
How much is one more observation worth? A person's observations share that person. Here the intraclass correlation, the share of the variance that belongs to the person, is zero point three. For the grand mean, the observations are worth fewer independent ones, by this formula. The dots are simulated studies. Ten each from a hundred people is a thousand observations, worth about two hundred and seventy. Fifty each, about three hundred and twenty, near a ceiling of three hundred and thirty. For questions about people, more people beat more observations. For questions about change within a person, it's the reverse.
What it does: Averaging throws away the structure; regressions within regressions; how much is one more observation worth?
3Random intercepts and slopesGraduate1 min
What's one person's slope? Psyche makes forty people, with fifteen noisy observations each, whose slopes truly differ. Each person's own regression is unbiased but noisy. The multilevel model pulls each slope toward the average, more for noisier people. It's called partial pooling. The error falls by about a third. Borrowing strength from everyone else describes each person better. It's the shrinkage of James and Stein, here for people. But it assumes each person is like the others.
How hard does the model pull? The multilevel estimate is a weighted average of the person's own slope and the population's. The weight is the share of the variation in own slopes that's real rather than noise. With fifteen observations each, the model gives each person's own slope a weight of a little over a half. With sixty, most of the weight. So people with fewer data are pulled further. That's fair to the data, but an unusual person with few observations will look more ordinary than they are.
What it does: Partial pooling; how much to trust one person
4Participants and items, crossedGraduate2 min
Why does the by-participant test fail? Words differ: some are easy, some hard, and there are only ten in each condition. Every participant sees the same twenty words, so the words' quirks are in every person's average. The by-participant test sees thirty people who agree, and mistakes the words' quirks for an effect. A model with random effects for both participants and items knows there are only ten words a side. The test that matters has about eighteen degrees of freedom, not twenty-nine.
How much structure should the model have? Clark's own remedy combined the by-participant and by-item tests into one, slightly conservative. Crossed mixed models fit random effects for participants and items together, as Harald Baayen, Douglas Davidson and Douglas Bates showed in 2008. Dale Barr and colleagues argued in 2013: keep it maximal. Include every random slope the design allows, or error rates rise again. Hannes Matuschek and colleagues replied in 2017 that maximal models lose power and often fail to converge. Simplify by evidence, not habit. And a model that won't converge is saying the data can't estimate what was asked.
The danger runs both ways. Now the words barely differ, but participants differ in the effect itself: positive for some, negative for others, zero on average. The by-item test now fails, at about twelve percent false positives, and the by-participant test isn't safe either. Treating both as random holds the line. That's the argument for keeping random slopes: every source of variation the design allows must be in the test.
What it does: Why the by-participant test fails; when people differ in the effect; how much structure?
5Stimuli are a sample tooPsych 101 and the major2 min
Stimuli limit power too. Psyche runs a real priming effect with thirty participants, in studies with eight to forty-eight words. With twenty words, the effect is found less than a third of the time. With forty-eight, about two thirds. Adding participants can't fix this. The uncertainty about the words stays, however many people see them. Charles Judd, Jacob Westfall and David Kenny made the point in 2012: plan the number of stimuli as carefully as the number of participants.
So which should a study add, people or items? Here's power for the same real effect, as both vary. Down a column, more participants barely help. The words' variation is still there. Along a row, more words help a lot. In designs like this, a study of fifteen people and forty words beats one of a hundred and twenty people and ten words.
Tal Yarkoni pushed the point further in 2022. A study of ego depletion with one task, or of faces with twelve photographs, supports a claim about that task and those photographs. The verbal claim is far broader than the statistical model that tests it. So either widen the model, sampling tasks, stimuli, experimenters and settings, and treating them as random. Or narrow the claim to what was sampled. Part 43's replications varied the labs. Few studies vary their stimuli.
What it does: Power comes from stimuli too; people or items?; the generalizability crisis
6GrowthGraduate1 min
Growth is the same model, with time as the predictor. Part 31's growth curves and Part 44's latent slopes are this model: each person's own start and rate. Now add a predictor that changes too: sleep, stress, or practice on each occasion. Its single coefficient mixes two questions. Do people who sleep more do better? And does a person do better on the nights they sleep more? Split the predictor into the person's average and the occasion's departure from it, and give each its own coefficient. The next two chapters show why.
Here's what goes wrong if you don't split. Psyche makes two hundred children, measured for five weeks. Children who practise more on average are the ones who struggle, but any child does better in a week they practise more. Entered once, practice gets a single coefficient, a blend of two opposite effects. Split, the week's departure gets about plus zero point four, a little short of the planted half, since five weeks pin down each child's average only roughly; and the child's average gets about minus zero point four, as planted. Advice for a child, practise more this week, needs the first number. The blend would understate it by more than half.
What it does: Trajectories, and what changes with them; splitting the predictor
7Simpson inside a personPsych 101 and the major1 min
Here's the cloud from chapter one again. Colour the dots by person, and each person's own cloud slopes up. Across people the slope is negative; within every person it's positive. An example: faster typists make fewer errors, because they're more skilled. But any typist makes more errors when typing faster than usual. It's Simpson's paradox, at the scale of one mind. The answer for a person was in the data, but not in the correlation.
Make it concrete. Fit each person's own line: twelve slopes. Every one is positive. The pooled slope, negative, lies outside all of them. It's the slope of no one in the study. That's the test for a claim about persons: does it hold person by person?
What it does: The same cloud, by person; every person, one by one
8Within against betweenPsych 101 and the major2 min
The repair is simple. Split each predictor into the person's own average, and today's departure from it, and give each its own slope. The within slope answers the question about a person: here about plus zero point six, as planted. The between slope answers the question about people: about minus one. And the pooled slope answers neither. It's a blend, weighted by how much of x varies within and between people.
There's an old name for the mistake. In 1950 William Robinson showed that American states with more immigrants had higher literacy, though immigrants were less often literate. The correlation across states said nothing about individuals. The same holds one level down. A correlation across people says little about how one person works. Finding that anxious people sleep less doesn't show that a person sleeps less on anxious nights. The question decides the data. A claim about a person needs repeated measures of persons.
One more way to get a person wrong: ignore them. Thirty people, twenty occasions each. Each has their own slope, and on average the slope is zero. Pool all six hundred points into one regression, and its test is significant fifteen percent of the time. Fit each person's slope, then test the thirty slopes, and it's five percent, as promised. The unit of replication is the person. The test must count people, not points. The multilevel model with random slopes does this, and more.
What it does: Person-mean centring; the ecological fallacy, inside one mind; ignoring the person
9ErgodicityGraduate2 min
Peter Molenaar gave the problem a mathematical name. A process is ergodic when its statistics across a population equal its statistics over time within a member. That needs two conditions: every person follows the same model, and the model doesn't change over time. In 2004 Molenaar argued that psychological processes almost never meet both. People differ, and they develop. So group analyses, however large, don't by themselves describe any individual.
Psyche builds a population to see what that means. Two hundred people, a hundred occasions each. People differ stably in two traits, and each person's two traits move together in their own way. At any moment, across people, the traits correlate about zero point six. Within people, the correlations spread from strongly negative to strongly positive. Fewer than one in ten are close to the group's, and almost half are negative. Aaron Fisher, John Medaglia and Bertus Jeronimus found real samples behaving like this in 2018, with variation between individuals several times larger than the group's would suggest.
So what should you use to predict one person? Say you want to predict how a person's two traits will move together later. Use the group's correlation, or the person's own first few occasions? In this population the group's number is off by about zero point six five on average, however much data the group has. Five occasions of the person's own are off by about zero point four; forty, by about zero point one three. When people differ this much, a little data about the person beats a lot of data about everyone else.
What it does: Molenaar's manifesto; a population that describes no one; your own few days or everyone's?
10Intensive longitudinal dataGraduate2 min
To study a person, measure a person often. In experience sampling, a phone asks several times a day, for weeks: how do you feel, where are you, what are you doing? Each person becomes a time series, with their own mean, their own spread, and how much each moment carries over to the next. That carry-over is the autoregression, or inertia: a mood that lingers. From several series, a network of how one person's states predict each other: person-specific, not a population average.
Inertia became a measure of risk. In 2010 Peter Kuppens, Nicholas Allen and Lisa Sheeber reported that emotions that linger go with depressive symptoms. But inertia estimated around a person's own mean is biased toward zero. With a true value of zero point four, twenty occasions give about zero point three on average, and ten give less than half the truth. The bias is about one plus three phi, over the number of occasions. People who answer fewer prompts look less inert: a confound if compliance differs between groups. And inertia turns out to add little beyond a person's mean and spread. That's in the Ledger.
How many prompts does a diary need? Say one prompt's mood is forty percent the person and sixty percent the moment. Average k prompts, and Spearman and Brown's formula, from Part 3, gives the reliability of the person's mean. A week of daily prompts gives about zero point eight. Four weeks, about zero point nine five. But the moments aren't noise. Their spread, their inertia, and their reaction to events are what experience sampling is for.
What it does: Experience sampling; inertia and its estimate; how many prompts?
11Cause over timeGraduate2 min
Back to cause, with what this part has added. Part 44 showed the trap. A cross-lagged panel found one trait driving another in people whose traits never touched, because the stable differences between people leaked into the lags. The repair gives each person their own level of each trait, so the lags describe departures from it. It needs at least three waves, and better many. With few, a person's level is poorly known and the lags are biased, just as chapter ten's inertia was. It still can't rule out a third variable that changes over time, or choose the lag. A day, a month and a year can give different answers. The strongest design changes one thing for a person, at random times, and watches: a single-case experiment, or a micro-randomized trial.
How many waves does the repair need? Psyche makes five hundred people with stable traits and a real within-person lag of zero point two, from one trait to the other. Estimate it from each person's departures from their own observed mean. With three waves it comes out at about zero point one two. With ten, nearly right. With fifty, right. Few waves bias the within-person lag toward zero, because each person's mean is too uncertain. Intensive designs fix it.
What it does: The panel, repaired; how many waves?
12Tipping pointsGraduate2 min
Some changes are not gradual. Psyche builds a mood that sits in a low valley. Slowly, the valley flattens, until the state tips into another. Before the tip, the system recovers more slowly from each small nudge, so each moment resembles the ones before it. Autocorrelation and variance rise. It's called critical slowing down. Marten Scheffer and colleagues found the signature before transitions in lakes, climates and fisheries. In 2014 Ingrid van de Leemput and colleagues looked for it in mood.
Can it warn in time? With a long, continuous record, a rising autocorrelation warns before more than half of the tips, and almost never when nothing tips. With a noisy daily diary of the same lives, warnings come before a quarter of the tips, and in about one in six people who never tip. A single person followed through a relapse showed the signal. Prospective tests in many people have found it weak. The theory is sound. Whether a mood is such a system, and whether diaries can see the signal in time, is open. The Ledger says contested.
One choice the analyst makes changes the answer. A fresh set of sixty lives that tip, and sixty that never do. Only the width of the rolling window changes. A narrow window warns before almost no tips. A wide one before seven in ten. But false alarms rise too, from about two percent to about twelve. The window, the detrending and the threshold are all forks in the garden. Fix them before the data, or the warning is found after the fact.
What it does: Critical slowing down; warnings and false alarms; the analyst's window
13The LedgerGraduate
What the three have in common. Each is about the level at which a claim is made: items, persons, or moments. The first is settled because it's arithmetic. Ignore a source of variation, and the error rate rises. The other two ask a lot of short, noisy series from single people. Claims about a person need data about a person: many occasions, for each one.
What it does: Three rows; what they have in common
14In practice: users, patients and dashboardsPractice1 min
The question of this part runs through practice. Product metrics: users who use a feature more are more engaged. Does using it make a user more engaged? Only within-user data, or an experiment, can say. Experiments: randomize users, and analyse at the level randomized. Sessions from one user aren't independent, and many tests treat them as if they were. Personalized health: a wearable records one person for months, enough for that person's own model, if the question is about them. Learning and coaching: advice read off a cross-section is advice about people, not about you. And items and prompts: any test with a few hand-picked stimuli, prompts or scenarios is a sample of them. Include them as random, or narrow the claim.
What it does: The same question, everywhere
15Frontier: the science of oneResearch1 min
Three frontiers. Idiographic science at scale: a model for each person, fitted to their own months of data, then compared across thousands of persons. How much data: how many stimuli, occasions and people a claim needs, planned like power at every level at once. And streams and models: phones and wearables record sleep, movement and speech continuously. Joining them to models of a mind is new, and privacy comes first.
Open questions. Which psychological processes are close enough to ergodic that group studies describe individuals? How many occasions does one person's model need before it beats the population's? Can early-warning signals be read from the data people will actually give? And how should a field choose and report its stimuli, so that its claims say what they cover?
What it does: Three frontiers; open questions
Recap, problems, and the road aheadAll tracks3 min
First, your four numbers. Analysed by participants only, about half the studies of nothing came out significant. In the cloud, one person's y rises when their x does, though across people it falls. Fewer than one person in ten showed the group's correlation within themselves. And twenty days turn a true inertia of zero point four into about zero point three. The level of the data must match the level of the claim: items, persons, or moments.
Part forty-seven in twelve lines. Stimuli are a sample, and ignoring them sends false positives soaring. Averaging over trials throws away structure. Multilevel models are regressions within regressions, and partial pooling describes each person better. Participants and items are crossed, and the model can be maximal or parsimonious. Power comes from stimuli too. Split predictors into person means and departures, because a relation can reverse within a person. Ergodicity rarely holds, so groups may describe no one. Diaries make each person a time series, and inertia's estimate is biased. Cause over time needs within-person change. And tipping points slow down first, though diaries see it poorly.
Kant's wager. The first objection met multilevel models, min F prime, ergodicity and critical slowing down, simulated and fitted. Green. The second, that the mind can't be experimented on, met within-person experiments: single cases and micro-randomized trials. Green. And the third, about introspection. Diaries are self-reports many times a day: less reliance on memory, but still introspection. Amber.
Where this comes back. Models of behaviour, fitted person by person, are next, in Part 48. The brain's data, with subjects and voxels as levels, are Part 49. The weight of evidence across studies is Part 50. And computational psychiatry, one person at a time, is Part 59.
Seven problems, with full solutions in this part's README. One computes min F prime. One shrinks a slope. One splits a prediction into within and between. One predicts inertia's bias. One finds the limit that items put on precision. One finds a mood's variance. And the last, with the star, asks you to design a diary study of sleep and anxiety within persons. Pause here if you'd like to try them.
The books and papers behind this part are listed here and in the README. Niall Bolger and Jean-Philippe Laurenceau's book teaches diary data; Gelman and Hill teach multilevel models by example; and Snijders and Bosker is the standard reference.
Four parts of the graduate toolkit done. This one matched the level of the data to the level of the claim. Next, the models themselves. When is a computational model of the mind more than a curve fit? Part 48: modelling behaviour.
Where it goes next. Models of behaviour fitted person by person are Part 48; the brain's data with subjects and voxels Part 49; the weight of evidence Part 50; computational psychiatry Part 59.
Key results
The part's results in one place, for revision.
Try it
Lab 47 · People over Time
Simulate studies with words as a sample and see the by-participant test fail, pool person-level slopes, separate within from between, build a population that describes no one, and look for early warnings.
python -m videos.psychology.labs 47
needs numpy, scipy, matplotlib · download lab47.py ·
source on GitHubnull studies significant: by participants; by items; min F' 0.48; 0.07; 0.07
power for an effect of 0.4 with 10, 20, 40 words 0.20, 0.20, 0.63
person slopes: RMSE own lines; multilevel 0.267; 0.209
slopes: pooled; between; within -0.74; -0.94; 0.63
group correlation; share of people within 0.1 of it 0.61; 0.05
inertia 0.4 estimated from 10, 20, 50, 100 occasions 0.16, 0.27, 0.35, 0.38
early warnings: continuous (hit, false); diary (hit, false) 0.55, 0.00; 0.20, 0.07
Ignoring the words' variation makes nothing look like something; a relation across people can run the other way within each; and short noisy diaries cannot tell a warning from noise.
The code (60 lines; it asserts its own result)
"""Lab 47: people over time: the language-as-fixed-effect fallacy, stimuli and power, partial pooling, Simpson's
paradox within persons, a non-ergodic population, inertia's bias and critical slowing down."""
import numpy as np
from videos.coursekit import labs
from explainer.psychology.psyche import within as Wi
TITLE = "People over Time"
GOAL = ("Simulate studies with words as a sample and see the by-participant test fail, pool person-level slopes, "
"separate within from between, build a population that describes no one, and look for early warnings.")
TASKS = [
"Make the words more alike (item SD 0.2). How far does the by-participant false-positive rate fall?",
"Give each person 40 observations instead of 15. How much does partial pooling still help?",
"Change the diary to two prompts a day (thin = 8). Do the warnings separate from the false alarms?",
]
def run(seed=0):
out = labs.Lab()
fp = Wi.false_positive_rates(reps=150, seed=seed + 1)
assert fp["F1"] > 0.25 and fp["minF"] < 0.1
out.row("null studies significant: by participants; by items; min F'", f"{fp['F1']:.2f}; {fp['F2']:.2f}; {fp['minF']:.2f}")
pw = Wi.stimulus_power(0.4, [10, 20, 40], n_subj=30, reps=60, seed=seed + 2)
out.row("power for an effect of 0.4 with 10, 20, 40 words", ", ".join(f"{v:.2f}" for v in pw["power"]))
p = Wi.person_slopes(n_obs=15, seed=seed + 3)
out.row("person slopes: RMSE own lines; multilevel", f"{p['rmse_ols']:.3f}; {p['rmse_blup']:.3f}")
s = Wi.simpson_cloud(between=-1.0, within=0.6, seed=seed + 4)
assert s["between"] < 0 < s["within"]
out.row("slopes: pooled; between; within", f"{s['pooled']:.2f}; {s['between']:.2f}; {s['within']:.2f}")
e = Wi.nonergodic(seed=seed + 5)
out.row("group correlation; share of people within 0.1 of it", f"{e['cross_mean']:.2f}; {e['share_near']:.2f}")
ib = Wi.inertia_bias(phi=0.4, Ts=(10, 20, 50, 100), reps=800, seed=seed + 6)
out.row("inertia 0.4 estimated from 10, 20, 50, 100 occasions", ", ".join(f"{v:.2f}" for v in ib["mean_est"]))
wr = Wi.warning_rates(n=40, seed=seed + 7)
wd = Wi.warning_rates(n=40, window=30, threshold=0.3, seed=seed + 7, thin=15, noise_obs=0.3)
out.row("early warnings: continuous (hit, false); diary (hit, false)",
f"{wr['hit']:.2f}, {wr['false_alarm']:.2f}; {wd['hit']:.2f}, {wd['false_alarm']:.2f}")
out.note = ("Ignoring the words' variation makes nothing look like something; a relation across people can run "
"the other way within each; and short noisy diaries cannot tell a warning from noise.")
fig, ax = labs.figure(2, size=(11, 4.0))
for i in range(s["g"].max() + 1):
m = s["g"] == i
ax[0].scatter(s["x"][m], s["y"][m], s=10)
ax[0].set(title="between negative, within positive", xlabel="x", ylabel="y")
d = Wi.double_well(T=3000, seed=seed + 4)
ind = Wi.rolling_indicators(d["x"], 300)
ax[1].plot(d["x"], color=labs.BLUE, lw=0.6)
ax2 = ax[1].twinx()
ax2.plot(ind["ac"], color=labs.RED)
ax[1].axvline(d["tip"], color="grey", ls=":")
ax[1].set(title="critical slowing down before a tip", xlabel="time", ylabel="state")
out.fig = fig
return out
if __name__ == "__main__":
print(run())
Now change it
- Make the words more alike (item SD 0.2). How far does the by-participant false-positive rate fall?
- Give each person 40 observations instead of 15. How much does partial pooling still help?
- Change the diary to two prompts a day (thin = 8). Do the warnings separate from the false alarms?
Problems, with solutions
Try each problem before opening its solution.
-
min F′. A by-participant test gives \(F_1 = 6.0\) on (1, 29) df and a by-item test \(F_2 = 2.0\) on (1, 18). Find min \(F'\) and its denominator degrees of freedom.
Solution
6 × 2/(6 + 2) = 1.5; denominator df = (6 + 2)²/(6²/18 + 2²/29) = 64/(2 + 0.138) = 29.9. Not significant (p ≈ 0.23), though F₁ alone gave p ≈ 0.02.
-
Shrinkage. A person's own slope is 1.0 with sampling variance 0.09; people's slopes have mean 0.5 and variance 0.09. Find the multilevel estimate.
Solution
The weight on the person's own estimate is 0.09/(0.09 + 0.09) = 0.5, so the estimate is 0.5 + 0.5 × (1.0 - 0.5) = 0.75.
-
Within and between. A person averages \(\bar x_p = 4\); today \(x = 6\). With \(\beta_W = 0.6\) and \(\beta_B = -1\), split today's predicted value into its within and between parts.
Solution
The within part is 0.6 × (6 - 4) = 1.2; the between part is -1 × 4 = -4.
-
Inertia's bias. True inertia 0.5, 25 occasions per person. Roughly what will the average estimate be?
Solution
About 0.5 - (1 + 1.5)/25 = 0.5 - 0.1 = 0.4.
-
Items limit precision. Ten items per condition, items vary with SD 0.5, effect 0.4. With unlimited participants, what is the standard error of the effect?
Solution
The difference of two means of ten item effects has SE √(2 × 0.5²/10) = 0.22, whatever the number of participants; an effect of 0.4 is then only 1.8 standard errors from zero.
-
An AR(1) variance. An AR(1) mood with \(\phi = 0.4\) and shocks of SD 1. What is its variance?
Solution
1/(1 - 0.4²) = 1/0.84 = 1.19.
-
★ A diary study. Design a diary study of whether poor sleep raises next-day anxiety within persons: occasions, lag, centring, model, and power at both levels.
Solution
Prompt five times a day for four weeks, with sleep reported each morning and anxiety at each prompt; centre sleep on each person's mean and enter the departure and the mean separately; model next-day anxiety with random intercepts and random slopes for the within-person sleep effect, and an autoregressive term for anxiety; plan power by simulation at both levels (about 100 people for the between-person effect, enough days per person for the within-person slopes), and decide exclusions and the lag before the data.
Notes and sources
Sources
- H. H. Clark (1973); R. H. Baayen, D. J. Davidson and D. M. Bates, Mixed-effects modeling with crossed random effects for subjects and items, Journal of Memory and Language 59 (2008) 390-412; D. J. Barr et al. (2013); H. Matuschek, R. Kliegl, S. Vasishth, H. Baayen and D. Bates, Balancing type I error and power in linear mixed models, Journal of Memory and Language 94 (2017) 305-315.
- N. M. Laird and J. H. Ware, Random-effects models for longitudinal data, Biometrics 38 (1982) 963-974; A. Gelman and J. Hill, Data Analysis Using Regression and Multilevel/Hierarchical Models (Cambridge, 2007); T. A. B. Snijders and R. J. Bosker, Multilevel Analysis (2nd edition, Sage, 2012).
- C. M. Judd, J. Westfall and D. A. Kenny (2012); T. Yarkoni, The generalizability crisis, Behavioral and Brain Sciences 45 (2022) e1.
- W. S. Robinson, Ecological correlations and the behavior of individuals, American Sociological Review 15 (1950) 351-357; E. H. Simpson, The interpretation of interaction in contingency tables, Journal of the Royal Statistical Society B 13 (1951) 238-241.
- P. C. M. Molenaar, A manifesto on psychology as idiographic science, Measurement 2 (2004) 201-218; A. J. Fisher, J. D. Medaglia and B. F. Jeronimus, Lack of group-to-individual generalizability is a threat to human subjects research, Proceedings of the National Academy of Sciences 115 (2018) E6106-E6115.
- M. Csikszentmihalyi and R. Larson, Validity and reliability of the experience-sampling method, Journal of Nervous and Mental Disease 175 (1987) 526-536; N. Bolger and J.-P. Laurenceau, Intensive Longitudinal Methods (Guilford, 2013); P. Kuppens, N. B. Allen and L. B. Sheeber (2010); E. Dejonckheere et al. (2019).
- E. L. Hamaker, R. M. Kuiper and R. P. P. P. Grasman (2015).
- M. Scheffer et al., Early-warning signals for critical transitions, Nature 461 (2009) 53-59; I. A. van de Leemput et al. (2014); M. Wichers et al. (2016); M. A. Helmich et al. (2024).
About this partfrom its README
In 1973 Herbert Clark pointed out that a generation of studies of language had tested whether their effects would generalize to new people but never to new words. Treating both as samples took thirty years to become routine. The deeper version of his point is the hardest in the series: a relation that holds across people need not hold within any one of them, and psychology's theories are mostly about the second.
The viewer guesses one person's slope inside a cloud of points and predicts four numbers. Then the language-as-fixed-effect fallacy, simulated (about half of null studies significant when words are ignored); repeated measures and the multilevel model; partial pooling of person-level slopes; participants and items crossed, min F′ and the maximal-model debate; power that depends on the number of stimuli, and the generalizability crisis; growth with time-varying predictors, and what happens when the predictor is not split; Simpson's paradox inside a person and person-mean centring; ergodicity, and a population whose group correlation describes almost no one; experience sampling and the small-sample bias of inertia; cause over time and its repairs; and critical slowing down before a tipping point, with its false alarms in diary data.
What is computed and built
explainer/psychology/psyche/within.py: a priming-study simulator with participant and item variance, the by-participant, by-item, min F′ and crossed mixed-model tests, false-positive rates and power by number of stimuli, person-level slopes against multilevel BLUPs, a within/between cloud, a non-ergodic population, the small-sample bias of person-level autoregression, a growth model with a split predictor, a person's own data against the group's, cross-lag estimates by number of waves, and a double-well system with early-warning indicators and their hit and false-alarm rates. Mixed models from Statistics, Built'sexplainer/stats/kit/mixed.py. Tested intests/psychology/test_within.py.- The Ledger gains three rows.
- The course's interactive: clouds of people over time, where the reader guesses the slope within one person before the colours show it.
Chapter notes
| # | Chapter | What it does |
|---|---|---|
| 0 | Twenty words, one conclusion | Clark's fallacy, simulated; the deeper point; the question; objectives |
| 1 | On you: one cloud, and four numbers | Guess one person's slope; four predictions |
| 2 | Repeated measures | Averaging throws away the structure; regressions within regressions; how much is one more observation worth? |
| 3 | Random intercepts and slopes | Partial pooling; how much to trust one person |
| 4 | Participants and items, crossed | Why the by-participant test fails; when people differ in the effect; how much structure? |
| 5 | Stimuli are a sample too | Power comes from stimuli too; people or items?; the generalizability crisis |
| 6 | Growth | Trajectories, and what changes with them; splitting the predictor |
| 7 | Simpson inside a person | The same cloud, by person; every person, one by one |
| 8 | Within against between | Person-mean centring; the ecological fallacy, inside one mind; ignoring the person |
| 9 | Ergodicity | Molenaar's manifesto; a population that describes no one; your own few days or everyone's? |
| 10 | Intensive longitudinal data | Experience sampling; inertia and its estimate; how many prompts? |
| 11 | Cause over time | The panel, repaired; how many waves? |
| 12 | Tipping points | Critical slowing down; warnings and false alarms; the analyst's window |
| 13 | The Ledger | Three rows; what they have in common |
| 14 | In practice: users, patients and dashboards | The same question, everywhere |
| 15 | Frontier: the science of one | Three frontiers; open questions |
| Recap, problems, and the road ahead | Your numbers; twelve lines; Kant's three objections; payoffs; problems; references; Part 48 |
NotesWhere the numbers come from
| What | Source |
|---|---|
| The fallacy: 200 simulated priming studies with no effect (30 participants, 20 words, 10 per condition; participant SD 0.5, word SD 0.5, trial SD 1): significant at 5% in 52.5% by participants only, 2.5% by items, 2.0% by min F′ | Psyche (within.false_positive_rates), item fpr |
One such study: p = 0.69 (participants), 0.85 (items), 0.86 (min F′); each word's mean shown by condition; a crossed mixed model (statkit's vc_lmm) matched the by-item test exactly on a check study |
Psyche (within.priming_study, min_f_test, crossed_test), item example |
| Stimuli and power: a real effect of 0.4 with 30 participants: power 16%, 23%, 30%, 60%, 65% with 8, 12, 20, 32 and 48 words (80 studies each) | Psyche (within.stimulus_power), item stimpower |
| Effective sample size: 100 people with intraclass correlation 0.3; m observations each are worth N m/(1 + (m - 1) 0.3) independent ones for the grand mean (100, 154, 227, 270, 299, 318 for m = 1, 2, 5, 10, 20, 50; 4,000 simulated studies agree), with a ceiling of 333 | the formula and a simulation, item neff |
| Partial pooling: 40 people, 15 observations each, slopes with mean 0.5 and SD 0.3: each person's own slope misses by 0.29 on average (RMSE), the multilevel model's by 0.19 | Psyche (within.person_slopes, statkit's lmm), item slopes |
| How much to trust one person: the weight on a person's own slope, G/(G + σ²/(n s²)) with G = 0.09 and σ² = s² = 1, from 2 to 60 observations; 0.57 at 15 | the formula, item shrinkw |
| Participants differ in the effect: 200 simulated studies with no average effect, participant slope SD 0.5 and word SD 0.2: false positives 10.5% by participants, 12.5% by items, 3.0% by min F′ | Psyche (within.false_positive_rates), item slopefpr |
| People or items: power for a real effect of 0.4 with 15, 30, 60, 120 participants and 10, 20, 40 words (40 studies a cell): 10% to 22.5% with 10 words, 27.5% to 40% with 20, 50% to 55% with 40 | Psyche (within.stimulus_power), item powergrid |
| Splitting the predictor: 200 children, 5 weeks, a planted within-child practice effect of +0.5 and between-child -0.4; entered once 0.17; split, +0.41 and -0.38 | Psyche (within.growth_split, statkit's lmm), item growth |
| Simpson inside a person: 12 people, 15 occasions each; slope -0.65 pooled, -0.96 between people and +0.59 within (planted -1.0 and +0.6) | Psyche (within.simpson_cloud), item simpson |
| Ignoring the person: 30 people, 20 occasions, person slopes with mean 0 and SD 0.3; one pooled regression is significant in 15.2% of 2,000 studies, a t-test on the 30 person slopes in 4.7% | simulation, item naive |
| Ergodicity: 200 people, 100 occasions, stable differences correlated 0.8 and person-specific relations centred on zero: the cross-sectional correlation averages 0.63; 8% of people are within 0.1 of it, 47% are negative | Psyche (within.nonergodic), item ergodic |
| Each person's own slope in the Simpson cloud: all twelve between 0.43 and 0.75; pooled -0.65 | Psyche (within.simpson_cloud), item ownslopes |
| Own data or the group's: predicting a person's later within-person correlation from their own first 5, 10, 20, 40 occasions (mean absolute error 0.40, 0.24, 0.17, 0.13) or from the group's correlation (0.65) | Psyche (within.own_vs_group), item owngroup |
| Inertia: a true autoregression of 0.4 estimated around each person's mean: 0.16, 0.29, 0.33, 0.36, 0.38, 0.39 from 10, 20, 30, 50, 100, 200 occasions (2,000 series each), matching Kendall's approximation | Psyche (within.inertia_bias), item inertia |
| How many waves: 500 people with stable traits and a within-person cross-lag of 0.2, estimated from departures from each person's observed mean: 0.12, 0.17, 0.20, 0.20, 0.20 with 3, 5, 10, 20, 50 waves | Psyche (within.crosslag_waves), item waves |
| How many prompts: the reliability of a person's mean of k prompts when one prompt's intraclass correlation is 0.4 (Spearman-Brown): 0.40, 0.67, 0.82, 0.90, 0.95, 0.97 for k = 1, 3, 7, 14, 28, 56 (500 simulated people agree within 0.05) | the formula and a simulation, item relmean |
| Critical slowing down: a double-well system whose lower well flattens; before the tip, Kendall's τ of autocorrelation 0.47 and of variance 0.34; over 100 simulated lives, a continuous record warns before 58% of tips with 1% false alarms; a noisy daily diary of the same lives before 25%, with 16% false alarms | Psyche (within.double_well, rolling_indicators, warning_rates), item tipping |
| The analyst's window: a fresh set of 60 lives that tip and 60 that never do, continuous records; warnings before a tip 5%, 42%, 58%, 70% and false alarms 2%, 3%, 5%, 12% with rolling windows of 100, 200, 300, 500 steps | Psyche (within.warning_rates), item windows |
| Every published number on screen | the studies listed under Sources, quoted as reported |
The typing example is an illustration of the planted pattern; the mood series on the experience-sampling chapter is illustrative and labelled so.
Notes
| Finding | Original | Status |
|---|---|---|
| Analyses that treat a study's stimuli as fixed, rather than as a sample, find effects that do not generalize to new stimuli far more often than their nominal error rate. | Clark 1973 | replicated |
| People whose moment-to-moment emotions carry over more from one moment to the next (higher autocorrelation, 'inertia') are more prone to depression, and inertia adds information beyond how much their emotions vary. | Kuppens, Allen and Sheeber 2010 | contested |
| Rising autocorrelation and variance in a person's daily emotions signal an approaching transition into or out of depression (critical slowing down). | van de Leemput and colleagues 2014 | contested |
Shown without a row, with the reason recorded in explainer/psychology/ledger.py: Laird and Ware; Baayen, Davidson
and Bates, Barr and colleagues, and Matuschek and colleagues; Yarkoni; Robinson; Molenaar; Hamaker, Kuiper and
Grasman.
Notes
The web-search budget for this session was spent on earlier parts, so the facts in this part come from the standard literature and were not re-checked online today; each is listed here to be checked against its source: Clark (1973) and min F′; Baayen, Davidson and Bates (2008); Barr et al. (2013); Matuschek et al. (2017); Judd, Westfall and Kenny (2012); Yarkoni (2022); Laird and Ware (1982); Robinson (1950) and his state and individual correlations; Simpson (1951); Molenaar (2004); Fisher, Medaglia and Jeronimus (2018) and the size of their individual-to-group variance ratios; Csikszentmihalyi and Larson's experience sampling; Kuppens, Allen and Sheeber (2010); Dejonckheere et al. (2019); Hamaker, Kuiper and Grasman (2015); Scheffer et al. (2009); van de Leemput et al. (2014); Wichers et al. (2016); the prospective test cited as Helmich et al. (2024); Kendall's small-sample bias of the autoregression; micro-randomized trials; and every page range in Sources.
Companion material in this repository
The syllabus's plan for this partfrom SYLLABUS.md, the plan of record
- Hook: the language-as-fixed-effect fallacy. A simulated priming study with twenty items and a false-positive rate several times the nominal 5% (computed).
- Repeated measures: why averaging over trials throws away the structure; the multilevel model as regressions within regressions.
- Random intercepts and slopes; partial pooling and shrinkage (link to Statistics, Built Part 25,
statkit.mixed). - Crossed random effects for participants and stimuli; "keep it maximal" against parsimony; what convergence failures mean.
- Stimuli are a sample too: generalizing beyond the twenty faces or the twelve vignettes (Judd, Westfall and Kenny; the generalizability crisis).
- Growth: individual trajectories (Part 31) as a multilevel model; time-varying predictors.
- On you: one cloud of points with a positive slope overall and a negative slope within every person. Simpson's paradox inside psychology.
- Within against between: person-mean centring; the ecological fallacy at the scale of one mind.
- Ergodicity (Molenaar 2004): when group statistics equal individual statistics, and how rarely the conditions hold; the empirical gap between group and individual variation (Fisher et al. 2018).
- Intensive longitudinal data: experience sampling; autoregression and inertia; person-specific networks.
- Cause over time: the cross-lagged panel model's artefacts and the random-intercept repair (Hamaker et al. 2015).
- Tipping points: critical slowing down as an early warning before a transition into depression; the single- case evidence and its limits (Part 39's network, now in time).
Psyche: mixed models on the Pool with statkit.mixed: false-positive rates with and without item effects;
shrinkage of individual slopes; a population built to be non-ergodic; cross-lagged artefacts reproduced and
repaired.
On you: the within-and-between plot; guess the sign for one person.
Ledger: item-as-fixed-effect inflation (replicated as arithmetic); findings that reverse within persons
(examples from the frontier sweep); early-warning signals before depression (contested).
In practice: user-level against aggregate product metrics, personalized health and learning, any dashboard that
reads individual advice off a cross-section.
Frontier: idiographic science at scale; how many stimuli and occasions a claim needs; combining wearable
streams with models.
Reading: Clark 1973; Baayen, Davidson & Bates 2008; Barr et al. 2013; Judd, Westfall & Kenny 2012; Yarkoni
2022; Molenaar 2004; Fisher, Medaglia & Jeronimus 2018; Hamaker, Kuiper & Grasman 2015; Kievit et al. 2013; Bolger
& Laurenceau, Intensive Longitudinal Methods.
Build the film
python -m videos.psychology.psych47.compute # the part's numbers, into .cache/psych47
python tools/build.py psych47 # render and assemble the film
EXPLAINER_TTS=silent python tools/qa_scene.py psych47 Hook # one chapter, silent, with a contact sheet
Scenes: videos/psychology/psych47. Setup: see the course page. Source of these notes: the README and the scenes' narration.
Build it
python -m videos.psychology.psych47.compute # every number (a few minutes)
python tools/qa_scene.py psych47 Simpson # one chapter, silent, at 480p, with a contact sheet
EXPLAINER_TTS=silent python tools/build.py psych47 -q l # the whole part, silent preview
python tools/build.py psych47 # 1080p30 with narration
python tools/qa_scene.py psych47 Ergodic --lang zh # the Chinese edition of one chapter
python tools/make.py psych47 # both editions, with the checks a long build needs
python -m videos.psychology.labs 47 # the lab: items as a sample, pooling, Simpson, inertia
python tools/check_ledger.py psych47 # every study shown has its Ledger row, or a reason
python -m pytest tests/psychology # Psyche's within module, the Ledger, the Archive
The Chinese edition is zh_lines.py (the narration, line by line) and the series table
videos/psychology/psychology_text_zh.json (the text on screen); the terms are in
PSYCHOLOGY_ZH_GUIDE.md.