The Squealer: Sensification of model exploration and model misfit

This is one of my favorite recent projects. It’s with Andrew Jaffe, Eliot Carlson, Philip Greengard, and Jeremy Magland:

We introduce a method for visual and auditory feedback when exploring the fit of a model to data. Starting with a best-fit curve fit to data, the user can drag the curve to a new position and the computer will emit a squeal, becoming more unpleasant as the discrepancy between curve and data increases. We demonstrate with four examples: a two-parameter curve fit to golf putting data, a four-parameter curve fit to dilution assays, a fit to cosmological data sensitive to the parameters of the Big Bang model, and a nonparametric Gaussian process fit to temperature readings. In this form of dynamic exploratory data analysis, the user employs domain knowledge to consider directions for exploration and to interpret the results.

The above image is a screenshot from the awesome Squealer demo that Jeremy built, featuring three of the examples from our article. Thanks also to the Flatiron Institute, which put me in contact with these wonderful collaborators.

Our paper appears in the new Journal of Reproducible Statistics. The review process was fast, effective, and with a minimum of paperwork. The founders of the journal are Matthias Templ and Jürgen Degenfellner, and they’re doing a great job. I hope it works out better than the sad story of the Berkeley Electronic Press, an innovative publishing idea from twenty-five years that worked for awhile but ultimately collapsed under its own weight.

As to the Squealer itself: This is an idea I really love; it’s the start (I hope) of a set of tools for dynamic model understanding and exploratory model analysis, with the goal of realizing some of the big ideas in my paper with Gwynn Sturdevant and Jonathan Godfrey, Delivering Data Differently.

Go to the demo link and check out the Squealer in action!

Survey Statistics: linking people part 2

Last week I said I’ve been reading about record linkage, specifically Gutman, Afendulis, and Zaslavsky (2013). They wanted to see how cost relates to cause of death, but cost y_A is in Medicare data A and cause of death y_B is in death certificate data B. So they needed to link databases A and B. Much of this linkage is based on variables in both databases, i.e. “blocking variables” Z. But linkage can be helped by using y_A and y_B as well.

Let rho be the parameter of interest: how costs y_A relate to cause of death y_B. (In their Simplest NonTrivial Example, the bivariate normal, rho = corr(y_A, y_B)). Let C be a parameter not of direct interest, the permutation linking database A to B. The authors show the usefulness of modeling everything together, since parameters rho and linking permutation C inform each other.

(Observant readers, this polar bear from the 1980s is linked to the polar bear from the 2020s that features in the rest of this blog series. Here he is in the Sierras on the PCT.)

The Human Rights Data Analysis Group (HRDAG) also needs to link databases (see Michelle’s post in Structural Zero) so they can use multiple systems estimation to estimate numbers of missing records of human rights violations (see Maria’s post in Structural Zero). Applying insights from Gutman, Afendulis, and Zaslavsky (2013) to HRDAG’s work would require some care. We need variables in each database that are not in the others (i.e. like y_A and y_B above). We need to relax the assumption from Gutman, Afendulis, and Zaslavsky (2013) that within blocking cells “all records in the smaller file have a match in the larger”, which was roughly plausible for the Medicare records and death certificates, but not for HRDAG’s databases.

I look forward to reading more about record linkage. Thanks to Thomas Lumley for suggestions last week !

How would you help a ten-year-old get comfortable saying “probably” or “I’m not sure yet,” and see it as a sign of good thinking rather than a lack of it?

Dhiraj Khivasara writes:

I’m a finance consultant in Pune, India, doing my MBA at SPJIMR alongside work. I also teach values and life skills to children at a community pathshala, and I’m finishing a book, The Marwari Lugai, about the women of Marwari merchant families.

The children I teach have learned that every question has one right answer and that hesitating looks weak. My question: how would you help a ten-year-old get comfortable saying “probably” or “I’m not sure yet,” and see it as a sign of good thinking rather than a lack of it? The children are around nine to eleven, they attend a weekly community class, and most of them are used to school tests where hesitation costs marks.

I have no idea; perhaps youall have some suggestions?

P.S. Lots of interesting suggestions in comments, including a link to a promisingly-titled new paper, Developing intellectual humility: questions, dilemmas, and future directions, by Ronfard, Joshua Rottman, Tenelle Porter, Jason Baehr, Andrei Cimpian, Judith Danovitch, Don Davis, Paul Harris, Frank Keil, Candice Mills, Azzurra Ruggeri, and Walter Sinnott-Armstrong.

Substitution Solver

In class the other day, Fangyuan Lin showed us these cool programs to encode and decode text:

Step 1: Scramble some text using a random substitution cipher—this is just the first sentence from yesterday’s post:

Step 2: Pipe that text into a substitution solver, which cracks the code:

Once you see it being done, it’s pretty clear how it can work, at least in a basic setting. Take a look at the cipher text. It has a one-letter word, “k,” which is probably “a.” Then it has a couple of two-letter words, both of which begin with “q,” which is probably going to be “i” or “o.” The “nw” string appears twice at the beginning of words; it could represent “th.” And so on. There’s also information from the sequence of words; for example, “qn qh” could be “it in” but it’s unlikely to be “of or,” say. And you can also see that this particular code-breaker is pretty crude: it transcribes “ulbkrqaqkzqyl” to “defamiliarive,” even though the more reasonable and likely “defamiliarize” was available. I’m guessing it just picked “v” over “z” based on pure letter frequency without looking at the word at all, which in turn suggests to me that it’s checking on a small dictionary.

So, yeah, it makes sense that it works. Still, it’s impressive. Without having seen it in action, though, I would’ve been surprised that it could transcribe such a small text.

That said, it doesn’t always work! Here’s what happens with the first of John Lennon’s New Sentences For The Testing Of Typewriters:

Epic fail.

And another:

And yet another, this one with no names, just standard English words:

I was surprised it couldn’t get even a bit of this last one. I guess it’s relying heavily on English letter frequency and little else, hence it gets destroyed by these sentences that include one of each of the 26 letters.

I’m not plugged into a chatbot, but I’m guessing that a modern chatbot could do it easily. OK, let’s try using ChatGPT:

OK, but that was cheating. I hadn’t realized that the cipher site was using the reverse coding by default. This was information not used by the codebreaker so it didn’t matter before.

It’s easy to redo this with a random cipher:

This still defeats the simple substitution solver, of course, but I’m guessing that ChatGPT can again decode it. I’ll start over in a clean session:

Ahhh, not so easy! If you go through, it keeps asking for hints.

Now I’m curious how ChatGPT would work on my original sentence, so let’s try it:

Fangyuan did some experimentation using a corpus of six novels and reports:

Decipherment becomes reliable once the plaintext is longer than the classical unicity distance H(K)/D. This provides a channel transmission interpretation of unicity distance: once the plaintext is longer than the unicity distance, encryption becomes a reliable communication system. For a single ciphertext, we derive a communication theory based prediction of unique decipherment using public English letter-transition statistics. The prediction closely matches experiments on six novels, with both reaching 99% recovery at 18 letters, which is well before the classical estimate of about 28 letters.

It feels to me like “cheating” because the novels represent a fixed amount of text to search through. Indeed, if you know that you’re pulling sequential characters out of these texts, I’m surprised you can’t do it with 10 consecutive letters. But maybe my combinatorial intuition is wrong on this one.

Survey Statistics: linking people

In 2011, while taking Alan Zaslavsky‘s survey course, I had just started talking to folks at the Human Rights Data Analysis Group (HRDAG). I saw their work using overlaps among data sources to estimate numbers of missing records of human rights violations. These methods are called “multiple systems estimation” (or “capture-recapture” in ecology). See Maria Gargiulo‘s post in Structural Zero for an introduction to HRDAG’s work on this.

In his post about Alan, Andrew linked to Alan’s PhD (and beyond) work: Combining Census, Dual-System, and Evaluation Study Data to Estimate Population Shares. 2011 me saw this work too, so I asked Alan to advise me on multiple systems estimation work with HRDAG. I was the luckiest baby PhD student.

To do multiple systems estimation, we need to link records across data sources. For example, is a violation recorded by one organization the same violation recorded by another ? This step wasn’t one I worked on during my PhD. But it comes up often in survey statistics, e.g. are these two survey records the same person ? So I’ve been reading Gutman, Afendulis, and Zaslavsky (2013): A Bayesian Procedure for File Linking to Analyze End-of-Life Medical Costs. More next week.

A statistician with Tourette’s syndrome

(Interview of Andrew Gelman for the American Statistical Association Committee on Statistics and Disability, July 2026)

1. Where did you grow up?

I grew up in Silver Spring, Maryland, a suburb of Washington, D.C. My parents both worked for the government. Earlier my dad had worked for General Electric in their aerospace division, building circuits to compute missile trajectories. Around 1970 he was laid off for a while, then later transferred to the D.C. area, and a couple years after that he took a job at the Environmental Protection Agency, working in the division that enforced the phase-out of leaded gasoline. He learned there were openings at the EPA from an announcement one day in Mike Causey’s Federal Diary column in the Washington Post. My mom was a housewife, and then when I was old enough to take care of myself after school she worked as a secretary, then as a substitute teacher, then as an economist for the Bureau of Labor Statistics. One of her jobs there was to call up companies and check on the employment numbers that they were sending to the government. One of my sisters worked during high school at a McDonalds restaurant that was two blocks from our house. That was fine except that she had to wear a hairnet and the boss was sexist: the grill was for boys only. Girls were allowed to make fries but not burgers. Later she got summer clerical jobs: she was really focused and could type a zillion words a minute. Every time she got a temp job the organization always wanted her to stay on permanently. One summer after graduating from college my brother worked as clerk for the National Oceanic and Atmospheric Administration His job was to enter the weather numbers that came in. He had a boss who was very orderly. At one point there was a hurricane that wiped out some weather station in the Caribbean, and his boss told him to put in the numbers anyway. My brother protested that they didn’t have the data, to which his boss replied: “I know what the numbers are.” Nowadays we call this sort of thing “imputation” and we like it. But not in the raw data! I bet nowadays they have an NA code.

Silver Spring is in Montgomery County, Maryland, which at the time I was growing up was the richest county in America as measured by median income. Montgomery County was not a haven for the ultra-rich, but it had very few poor people. It seemed nearly uniformly upper middle class. Where I grew up was not the richest part of the county, but we were all comfortably middle class. Our family did not have extra savings in the bank, but there was no concern about paying the bills each month. My parents, like many people in the area, worked at desk jobs for the U.S. government. These were non-supervisory jobs, with nothing close to the autonomy and pay that I receive as a tenured professor, but secure jobs with steady incomes. In Montgomery County, compared to the country (or, even more so, the world) as a whole, we had something approximating political, social, legal, and economic equality. The police were part of the community, the doctors and nurses were part of the community, etc. We felt neither like an occupied country or like a colonial power.

I’m not completely sure why this should be, but it often seems to be the case that local equality is a sort of privilege, bought by amassing enough of a surplus that society can afford to underwrite the efforts that it takes to keep a more natural state of inequality at bay. I think that equality is desirable, and I count myself very lucky to have grown up in a community that was both prosperous and equal.

2. Where did your interest in statistics/data science come from?

I studied math and physics at MIT. To be more precise, I started in math as default—ever since I was two years old, I’ve thought of myself as a mathematician, and I always did well in math class, so it seemed like a natural fit.

But I was concerned. In high school I’d been in the U.S. Mathematical Olympiad training program, and there I’d met kids who were clearly much much better at math than I was. In retrospect, I don’t think I was as bad as I’d thought at the time: there were 24 kids in the program, and I was probably around #20, if that, but I think a lot of the other kids had more practice working on “math olympiad”-type problems. Maybe I was really something like the tenth-best in the group.

Tenth-best or twentieth-best, whatever it was, I reached a crisis of confidence around my sophomore or junior year in college. At MIT, I started right off taking advanced math classes, and somewhere along the way I realized I wasn’t seeing the big picture. I was able to do the homework problems and do fine on the exams, but something was missing. Ultimately I decided the problem was that, in the world of theoretical math, there were the Cauchys, the Riemanns, etc., and there were everybody else. I didn’t want to be one of the “everbody else.” Unfortunately I didn’t know about applied math at the time—at MIT, as elsewhere, I imagine, the best math students did the theory track.

I was also majoring in physics, which struck me as much more important than math, but which I felt I had even less of an understanding of. I did well in my classes—it was MIT, I didn’t have a lot of friends and I didn’t go on dates, so that gave me lots of time to do my problem sets each week—and I reached the stage of applying to physics grad schools. It was only at the very last second in April of my senior year that I decided to go for a Ph.D. in statistics rather than physics.

I had some good experiences in physics, most notably taking the famous Introduction to Design course at MIT—actually, that was a required course in the mechanical engineering department but many physics students took it too—and working for two summers doing solid-state physics research at Bell Labs. We were working on zone-melt recrystallization of silicon and, just as a byproduct of our research, discovered a new result (or, at least it was new to us) that solid silicon could superheat to something like 20 degrees (I think it was that, I don’t remember the details) above its melting point before actually melting. This wouldn’t normally happen, but we had a setup in which the silicon wafer was heated in such a way that the center got hotter than the edges, and at the center there were no defects in the crystal pattern for the melting process to easily start. So it had to get really hot for it to start to melt.

Figuring this out wasn’t so easy—it’s not like we had a thermometer in the inside of our wafer. (If we did, the crystalline structure wouldn’t have been pure, and there wouldn’t have been any superheating.) We knew the positions and energies of our heat sources, and we had radiation thermometers to measure the exterior temperature from various positions, we knew the geometry of the silicon wafer (which was encased in silicon dioxide), and we could observe the width of the molten zone.

So what did we do? What did I do, actually? I programmed a finite-element model on the computer and played around with its parameters until I matched the observations, then looked inside to see what our model said was the temperature at the hottest part of the wafer. Statistical inference, really, although I didn’t know it at the time. When I came to Bell Labs for my second summer, I told my boss that I’d decided to go to grad school in statistics. He was disappointed and said that this was beneath me, that statistics was a step down from physics. I think he was right (about statistics being simpler than physics), but I really wasn’t a natural physicist, and I think statistics was the right field for me.

Why did I study statistics? As part of my understanding of statistical workflow, I’ve come to consider Why questions as pointers to potential interventions. The intervention that happened to me was that I took a data analysis course from Don Rubin when I was a senior in college. MIT had very few statistics classes. I’d taken one of them and liked it, and when I went to a math professor to ask what to take next, he suggested I go over to Harvard and see what they had to offer.

I sat in on two classes: one was deadly dull and the other was Rubin’s, which was exciting from Day 1. The course just sparkled with open problems, and the quality of the ten or so students in the class was amazing. I remember spending many hours laboriously working out every homework problem using the Neyman-Pearson theory we’d been taught in my theoretical statistics course. It’s only by really taking this stuff seriously that I realized how hopeless it all is. When, two years later, I took a class on Bayesian statistics from John Carlin, I was ready to move to a model-based philosophy.

3. Would you share information about your disability?

I have Tourette’s syndrome, which manifests for me as uncontrollable need to twitch. I’ve had it since around the age of 6, which I’ve been told is the usual pattern. Over the years, the twitches have moved around—they’ve included coughing, swallowing, and other small vocalizations; chewing on things; head shaking; and movements of my shoulders or other joints.

Perhaps relatedly, I’ve never been able to sit still and I almost never look people in the eye. I’d lose a staring contest with just about anybody. When I was a kid, adults would sometimes get mad at me for not looking them in the eye. I remember being shouted at by an assistant principal in elementary school. As an adult, I still usually let my eyes dart around rather than locking eyes with people in conversation. Also, I can’t visualize people or faces. If I close my eyes and try to picture people I know, I can’t visualize their faces. I can only think of them as collections of attributes (shape of face, hair color, hairstyle, etc.). When I run into people I know, I recognize them—I’m not “face blind.” But I’m not so good at the task. Often it takes me a while to be sure, and I can be thrown off when someone is wearing different clothes or has new glasses or a new haircut, which I guess is consistent with me remembering people as collections of attributes rather than visual images. Maybe this is because, unlike most people, I don’t have decades of practice looking people in the eyes.

I’m not sure how much of the above is Tourette’s-specific and how much is just me, but I’m mentioning it because it all seems connected in how I feel. It goes like this: sometimes I feel a need to twitch—it either comes all by itself or because I’m thinking about it (as right now). With great effort, I can suppress the twitch for a half a minute or so—maybe the best analogy I can give you is how it feels when you’re hanging from the pull-up bar or holding your breath: the longer you do it, the harder it is, and eventually you just have to let go. Twitching exists in some interesting zone between tremors and voluntary motion. When I twitch, I’m deciding to do so; it’s just that I can’t decide not to do it.

One thing, though: I don’t have coprolalia, which is when people blurt out inappropriate swear words. I like to swear as much as anyone, I guess, but it’s just part of my speech; it doesn’t come out as a twitch. I’ve read that most people with Tourette’s don’t have coprolalia; it’s just a dramatic thing that gets associated with the condition. This is not to say that I never say anything inappropriate—I remember in a faculty meeting about thirty years ago, someone said something and I responded, “Get the fuck outta here!”, in my best Eddie Murphy voice. Unfortunately, I don’t think anyone else in that room had seen Beverly Hills Cop, so they just thought I was cussing the guy out! My bad. This had nothing to do with Tourette’s, though; it was just poor judgment in the moment. It’s not like I was feeling a need to curse.

But here’s the biggest thing. I never thought of myself as having Tourette’s until I was 28! It’s not that I thought I didn’t have Tourette’s. I’d heard of the condition, and it had never crossed my mind that I might have it. What happened was that one day I was chatting with a colleague at the medical school and he offhandedly mentioned that I had Tourette’s. I don’t remember how it came up, but once I heard it, I was like, yeah, I guess that’s right. And after that I read up on it a bit. Years later I asked my parents how they thought about my twitching. They told me they never talked with me about it because they didn’t want me to be self-conscious about it. That sounds about right. It would’ve been horrible if they’d tried to get me to stop. I’ve tried to keep this in mind—not always with success, I’m sorry to say!—when my kids do things that annoy me.

I’m not part of any Tourette’s community. Every once in a while I see someone on the street who’s twitching, and that kind of makes me happy, and I added my name to the Wikipedia page of people with Tourette’s syndrome. But every time I do this, someone takes it down because I can’t point to any authoritative source and, as you might know, blogs don’t count. Once this interview officially appears, I can link to it and finally remain listed on that page.

Every once in a while I see something in the news media on Tourette’s and I react to it. For example, the neurologist Oliver Sacks has written very perceptively on the topic, and that’s great, but then after he died, some material from his journal was published, including this bit about Tourette’s patients: “With my help and almost my collusion, they can extract the maximum possible from their sickness—maximum of knowledge, insight, courage. Thus I will first help them to get ill, to experience their illness with maximum intensity; and then, only then, will I help them get well!” And my reaction was, Maybe we don’t want to “get well,” dude! And a few years ago I was motivated to write the following letter to the London Review of Books:

“‘Aggressive, fizzing nonconformity, the diplomatic equivalent of Tourette’s syndrome, is an essential part of North Korea’s nature,’ Richard Lloyd Parry writes. This is a terrible analogy. If you have Tourette’s syndrome, twitching is not something you have any desire to do and it doesn’t serve your interests. Rather, you twitch because it becomes escalatingly uncomfortable to keep from twitching. In contrast, as Lloyd Parry explains, the North Korean government has a strong rational incentive to develop nukes as a deterrent. I don’t know what the diplomatic equivalent of Tourette’s syndrome would be, but it wouldn’t be an action that instrumentally benefits one of the players in a negotiation; it would have to be some action that is noticeable, can’t be stopped, and does no harm to anyone else involved.”

4. How has your disability affected your work as a statistician, if at all?

For me, Tourette’s syndrome has not been a disability, as it has not interfered with my ability to function in the world, and I have not needed to accommodate or work around it in any way. When I was a kid I’d get teased and get into fights, but if it hadn’t been the twitching, I’m sure it would’ve been something else. I kind of wonder what other people say about my twitching when I’m not around—I give a lot of talks, and you can see me twitching all over Youtube—but that’s one of the blessings of the world, that we don’t hear what people say about us behind our backs.

I don’t know if this is true, but I kind of like to think that Tourette’s has actually helped me with my work. I say this because I associate my Tourette’s with a lack of ability to concentrate—but another way of saying this is that I always have about a hundred ideas in my mind at once. I carry a notebook around with me to write down ideas as they come up, because otherwise I might forget. It’s not that I can never focus, but my work as a statistician typically involves bouncing from one idea to another. This can also help with writing. People sometimes ask how I can be so productive, writing all these books, articles, and blogs. One answer is that a limiting factor in writing can be waiting for inspiration, but I never need to wait, because some new idea is always popping in, so when I get stuck I can jump from project to project. I have lots of bad ideas too—that’s just how it goes—and there are lots of other ways to do research; this is just a style that’s worked for me.

5. What message would you share with your younger self about life as a statistician with a disability?

You know that saying, that being a white guy is like playing the game of life on easy setting? No way that’s true of all white guys, but it’s definitely been true of me. I’ve had the occasional setback in life, but mostly I’ve had all the breaks. Obviously I’ve been lucky enough to have a career doing something that I’m very good at. OK, that’s not all luck: I’ve worked hard, and I consciously moved away from options where I wouldn’t have been the best at what I do. But to have grown up in a society where this has been possible, with such wonderful public and private education systems from high school onward, that’s all gone so smoothly.

When I was a kid, my mother told me that I could do great things and that I had a responsibility to the world to do so. I’ve taken that to heart. One thing it took me a bit longer to realize is that just about everyone has something unique and valuable to contribute to the world. I try to convey this to students. I’m not a great teacher—I tend to focus on the material being taught rather than on the individual students, and indeed one reason I wrote two pretty good books (I think) on how to teach is that I’ve needed to work through a lot of specific techniques to get students involved. Even if I’m not tuned in to what each student can do, I remember the larger goal of giving them the tools to be able to do their best work.

In answer to your question above, if I could talk with my younger self, I’d say, “Hey—you know that twitching that you do? It’s called Tourette’s syndrome and it’s no big deal.”

6. What would you like people to know about working with others with your kind of disability?

If you see someone who twitches, and it bothers you, or if you’re curious about it, just ask! People are typically very willing to talk about their health or body issues, and you might learn something. It’s been very rare that anyone has ever come up to me and asked about my twitching. Maybe they think it would offend me to bring it up, or perhaps it’s more that people who don’t twitch won’t find Tourette’s syndrome very interesting. It could well be something that’s much more fascinating from the inside than to others.

7. Which one of your achievements are you the most proud of and why?

A great achievement is anything that is difficult, requires sustained effort, and has intrinsic value as judged by people you respect. I will leave it to those people to decide what they consider to be my most important personal and professional achievements.

8. Is there anything else you’d like to share about your experiences as a statistician with a disability?

I do not think of myself as being disabled or as having a disability. There’s an expression, “temporarily abled,” that describes all of us whose bodies are working well. As babies and young children we are disabled in the sense of needing others to take care of us at all time, and if we reach old age we again lose the ability to function autonomously throughout the day. If we are lucky, we get several decades of non-disability in the middle of our lives, something I’ve experienced ever since the age of 5 or so and which I hope to maintain for a few decades longer.

To the extent that Tourette’s is associated with disability for me, it’s that I’ve been told that all this twitching will give me arthritis, so maybe when I’m in my seventies I’ll barely be able to move my neck and be in pain all the time. That would be horrible. But I don’t think about it much now except to do my stretching and core exercises every day.

When is a class a “commodity” and when does it depend on the instructor?

Sometimes I get emails from students asking to work on a project with me, and I usually respond that they should take one of my classes first. If they try to work on a project without having taken a class first, I usually end up having to teach them a bunch of things. Sure, they could read my books, but I guess people don’t really like to read, also there’s something extra you get from hearing it live, doing the homework, getting feedback in class, etc.

This always puzzled me, that students would think they could jump in a project without taking any of my classes first . . . but then I realized that it’s usual to think of a math class as being pretty much the same no matter who teaches it. You take calculus or linear algebra or real analysis or whatever, and it can be taught well or poorly, there are good teachers and bad teachers, but they’re pretty much all teaching the same thing.

But statistics is different. Even if you limit yourself to a narrow topic–for example, regression analysis or survey sampling or Bayesian statistics (just to name three fairly generic-sounding classes that I’ve taught)–the course varies a huge amount from instructor to instructor. Not just teaching style (cos, yeah, my style is much different from that of every other statistics teacher I’ve seen. I’m not saying it’s better, mind you, just that it’s different. You can get a sense of it by reading Part 1 of Active Statistics), but actually what gets taught. First off, most people don’t teach regression out of Regression and Other Stories, and other regression textbooks don’t look much like ours. Second, somehow what gets covered in class isn’t just what’s in the book. This is even true with Bayesian statistics. Lots of people teach out of Bayesian Data Analysis–and I hope that, soon, lots of people will be teaching from Bayesian Workflow–but there are still so many different directions to go.

And I’m not saying I’m unique here. In general, if you want to work with statistician X, it’s probably a good idea to first take a course from X, for just about any X.

In that way, a statistics class is less like a math class or a physics class or a chemistry class and more like a history class or a literature class. Even if the books are set ahead of time, different teachers teach it so differently that they’re just different courses entirely.

But I could see how many students, whose experience is taking straight math courses in high school and college, and maybe some very empty course such as AP statistics or the college equivalent, would look at the roster of statistics classes at a university and just see a collection of topics rather than what it really is, a collection of topics interacted with instructors. And our course descriptions usually don’t do such a good job of conveying that either. Hence this post.

P.S. I’m not saying that a course being a standardized commodity is a bad thing. In a way, that what my colleagues and I have been trying to do with our textbooks, as well as with Active Statistics: we’re trying to give other people the tools to teach as we do. But, the way things stand, it still matters a lot who teaches your class–maybe not such a bad thing, as the students should get some benefit from their big tuition payments. It just seems like a secret to many students that the instructor matters, not just in how well the topic is taught but also in the content of the course.

Bayesian Workflow (my talk in NYC, Wed 18 Nov 2:30pm)

This talk is sponsored by the New York City Chapter of the American Statistical Association, and it’s at CUNY Graduate Center, 365 Fifth Avenue, room 8301 & 8304 (8th Floor).  If you want to attend (in person or remotely; I recommend in person!), just go to the form before 15 Nov and fill it out.

Also here’s a zoom link so if you’re attending remotely, maybe you don’t need to sign up.

Here’s the summary:

Bayesian statistics and statistical practice have evolved over the years, driven by advancements in theory, methods, and computational tools. This book explores the intricate workflows of applied Bayesian statistics, aiming to uncover the tacit knowledge often overlooked in published papers and textbooks. By systematizing the process of Bayesian model development, the book seeks to improve applied analyses and inspire future innovations in theory, methods, and software. It emphasizes the importance of iterative model building, model checking, computational troubleshooting, and simulated-data experimentation, offering a comprehensive perspective on statistical analysis.

Through detailed examples and practical guidance, the book bridges the gap between theory and application, empowering practitioners and researchers to navigate the complexities of Bayesian inference. It is not a checklist or cookbook but a flexible framework for understanding and resolving challenges in statistical modeling and decision making under uncertainty.

The key innovations of Bayesian Workflow include:

    • Going beyond Bayesian data analysis (model building, inference, model checking, and model expansion) to consider the larger process of statistical modeling, including comparisons of multiple models fit to a single dataset.
    • A fuller use of informative priors.  One reason we’ve moved toward stronger priors is that the replication crisis has taught us that the amount of prior information available in any given problem is often approximately the same as the information coming from an experiment (see here, for example). Informative priors also fit our increased focus on generative modeling, and we’re doing a lot more prior predictive checking to understand the implications of our models.
    • More integration between modeling, data analysis, and computing. One way to see this is that the Bayesian Workflow webpage has the code to run all our examples.
    • Simulation-based experimentation.  At its most basic, simulation-based experimentation provides a best-case baseline for statistical methods: if you can’t recover your quantities of interest with sufficient accuracy under ideal conditions (when your data are simulated from the model you’re fitting), then you know you’re in trouble. And often this is the case! Beyond that, we can simulate from one model and fit another, and see what happens. Simulation experiments aren’t always so easy to construct, as they involve specifying the entire data-generation process.

All the information on the book, including the book itself, is at the Bayesian Workflow webpage.

The non-Bayesians among you might be interested in Appendix A of the book, on Statistical and computational workflow for Bayesians and non-Bayesians, and also our short general article, Statistical Workflow, and its accompanying journal issue.

In the talk I’ll follow my usual practice and tell lots of stories.  Stories are how we learn about the world, and I’ll try to also go meta and discuss the anomalous and immutable aspects of the stories I tell.

If you can make it to the talk, please come prepared with some tough questions!

“You’re kind of a hero at my company”

This post is by Phil Price, not Andrew. 

The work I’m proudest of is not necessarily the work that is most useful or best known or that others consider the best. A few years ago I learned that a model I threw together in about 15 minutes, and whose simplicity I had been quietly embarrassed by for years, was used by a successful company.  But I just learned that the model is much more widely used and appreciated than I thought. And I’ve just lost my two steady consulting clients, who were together responsible for about 60% of my income each year, so now is the time to do some self-promotion. And I think there are broader lessons here about the virtues of simplicity, and how we sometimes aren’t good judges of our own work, and maybe some other themes besides. So here’s the story.


About three years ago, a friend and colleague named Steve Greenberg died of cancer, only 64 years old. Steve was a very hands-on kind of guy (as you can learn from his obituary, ) with a deep practical understanding of HVAC systems, which made him very valuable in our quasi-academic setting where a lot of us understood the theories but wouldn’t know the first thing about how to actually install or manage the equipment. Steve was also a committed bike commuter. At his “celebration of life” I wore a bike jacket and a hard hat to recognize those aspects of Steve. Of course my hard hat has my name on it, not Steve’s name.

In the drinks and snacks portion of the party, after the speeches and slideshows, a stranger came up to me and said “Phil Price! You’re kind of a hero at my company.” This was, to say the least, surprising. OK, I’ve done some consulting work for various companies, but none of them would consider me a “hero,” not even remotely close, so what could this possibly be about? But it turns out they weren’t talking about my consulting work at all, but about some work I had done at LBNL years ago: inventing the “Time-of-week and Temperature” (TOWT) model to predict building electric load. “That model is the basis for most of what my company does to measure and verify energy-saving measures in buildings.” That’s not an exact quote, I’m sure, but it’s how I remember it.

Here is an explanation of the model that is clearer and more compact than anything I ever wrote about it. Or, if you want to see more detail and some extensions of the model and how to use it for various purposes, here’s a video of talk I gave back in 2015 (11 years ago!) as I was leaving LBNL to become a consultant. (For me, the video doesn’t display right in Safari but works fine in Firefox, not sure what’s up with that).

The TOWT model is useful in spite of its simplicity, or perhaps even because of its simplicity. It’s very easy to explain, it’s pretty robust, it’s very easy to code up and to fit, it is easy to extend in various ways (e.g. by including additional explanatory variables). But I never bring it up, it has barely been mentioned on my CV (although I’m fixing that), and I haven’t previously bragged about / emphasized my role as creator of the TOWT model, because I’m kinda sheepish about it. As you can see from the web page above or the video, the model is extremely simple: there’s a time-of-week indicator variable, and a piecewise-continuous linear function of temperature…and that’s it, at least in the simplest version of the model. I literally came up with it in an afternoon; actually less than an afternoon, it was more like 15 minutes from conception to implementation. It is very simple and I’ve worried that if I use it as an example of what I’ve done, people will think that level of sophistication is all I can do!

But maybe that’s a silly thing to worry about. People had been analyzing the same kinds of data for decades and in all that time nobody had come up with this model (as far as I know!), simple though it is. And jeez, I had no idea it was so widely used, it’s not just that one company. This is what a search turns up, for tools and methods that rely on the TOWT model:

  •  RM&V (Reference Measurement & Verification Tool): An open-source M&V reference tool released by LBNL that implements piecewise linear regression using TOWT and machine learning methods for multi-site facility analysis.
  • NMECR: An R-based package by kW Engineering implementing peer-reviewed Normalized Metered Energy Consumption (NMEC) algorithms, featuring an expanded TOWT model that supports operational schedules.
  • OpenEEmeter / OpenDSM: An open-source analytics toolkit (formerly OpenEEmeter, now operating via OpenDSM) that incorporates the CalTRACK hourly methodology, which is directly adapted from LBNL’s TOWT model for demand response and energy efficiency baselines.
  • Energy Twin (ET Analytics / ET Core): A commercial energy analytics platform and Python/R library package (ecpEnergyTwinAnalytics) that uses custom TOWT-based implementations to derive operational KPIs and anomaly detection across commercial portfolios.
  • Power TakeOff (Verify™): An automated M&V 2.0 platform that uses TOWT-based modeling to isolate weather versus schedule loads for utility energy efficiency programs.
  • CalTRACK Hourly Methodology: A standardized protocol for calculating normalized metered energy savings using an adapted hourly TOWT architecture for commercial and residential buildings.
  • NMEC (Normalized Metered Energy Consumption): A protocol used by utilities (such as in California) where the TOWT model serves as a benchmark standard to quantify weather-normalized energy savings.
  • TOWST (Time-Of-Week, Solar and Temperature): An extension of the standard TOWT model that integrates physical constraints like solar gain and building orientation via iterative clustering to improve prediction accuracy.

So, OK, I’m in. That’s my model. I’ll try not to be sheepish about it anymore.

As far as the general lessons to be learned, I think there are a few:

  1. Simplicity can be good. So what if the TOWT model was originally conceived and implemented in a few minutes. Indeed, that’s a good thing! If a simple model does the job, use the simple model.
  2. Don’t hide your light under a bushel basket. If you’ve done something that people find useful, it doesn’t matter if you don’t think it’s your best work or if it doesn’t demonstrate the full range of your skills. This shamelessly self-promotional post was prompted by comments from people who looked at my LinkedIn profile and the letters I’ve sent to potential clients and told me I wasn’t nearly clear enough about what I’ve accomplished. In trying not to come across as bragging, I was selling myself short.
  3. You often don’t know which of your work matters. I had no idea TOWT was in widespread use until a stranger told me at a memorial gathering. I would have guessed that some of my more elaborate work was my most influential. It wasn’t… as far as I know (but how would I know?). It’s worth writing up even the simple stuff (and publishing it, or anyway putting out there somehow).
  4. “It only took 15 minutes” leaves out the work before it. The model took 15 minutes to conceive and implement because I’d spent a couple of months looking at building energy data and knew what mattered and what didn’t, and of course I was proficient in linear regression and other stats methods. Maybe I under-valued my work because I forgot about this fact.

This post is by Phil

Survey Statistics: Sampling from a Bayesian Menu

A week ago Andrew wrote about Alan Zaslavsky, who recently passed. Alan’s obituary has information about an upcoming celebration of life.

Alan Mark Zaslavsky Profile Photo

Andrew highlighted Alan’s work on the census. In Sampling from a Bayesian Menu, Alan wrote about objections not only to model-based adjustments for undercount, but the Supreme Court’s ruling in 1999 against even purely “design-based” estimates using sampling for nonresponse followup.

Alan was on the panel who wrote “Sampling for Nonresponse Follow-up: Achieving Adequate Precision at Acceptable Cost”. They explained that after initial response to the census, the bureau conducts nonresponse follow-up on remaining housing units. In the 1990 census, this was massively delayed, costing both money and accuracy. They recommended that the 2000 census should conduct nonresponse follow-up on a random sample of nonresponding housing units for unbiased estimation of the total number of people in all nonresponding housing units. This is what Alan described in Sampling from a Bayesian Menu as the “design-based” approach that was rejected by the Supreme Court in 1999.

Despite this bad (old) news, the paper is fun to read, and will make you hungry.

Constructing a latent-variable model to fit measurement data: A Stan story, part 1

This simulation is a little different than what came before. For my earlier post I simulated hypothetical future data from the beauty-and-sex-ratio study. For my new post I’m simulating data from a hypothetical strong relationship between two variables. Here I’m entirely focused on the question of what happens to a nonlinear (but monotonic) pattern when independent measurement error is added to the predictor. To make the patterns clear, I will assume a large effect; indeed, I’m only concerned here with the effect size, not its variation.

The one thing I’ll preserve from the previous simulation is the distribution of attractiveness measurements in the sample: 2%, 5%, 45%, 37%, and 11% in the five attractiveness categories.

I want to set up a model where there’s an assumed true nonlinear relationship between some outcome of interest and a continuous underlying latent attractiveness variable.

The nonlinear model isn’t hard to come up with. The hard thing is creating a distribution for the latent attractiveness, under the constraint that it be roughly consistent with the data.

I’ll assume a symmetric model, a normal distribution on the measurement scale. This might seem like a strong assumption but it seems reasonable enough given the data, which have an average that’s between 3 and 4. The tails are asymmetric but that’s just because the scale has 5 as an upper bound.

My first step is to compute the mean and sd of the observed data:

n <- round(2792*c(.02,.05,.45,.37,.11))
mean_ratings <- sum(n*(1:5))/sum(n)
sd_ratings <- sqrt(sum(n*((1:5) - mean_ratings)^2)/sum(n))

These come to 3.5 and 0.83. Assuming random zero-mean measurement error, the latent attractiveness distribution should have the same mean but a lower variance. We should subtract 1/12 to account for the rounding (as this is approximately equivalent to adding an independent uniform(-0.5,0.5) random variable, which has a variance of 1/12) and then more to account for measurement error.

But how much to subtract? For this, we need to make some assumption about variation in the attractiveness measurement. Attractiveness seems pretty subjective to me (also it can vary a lot over time, as we know from those high-school yearbook photos of people who later became movie stars). I gotta assume something here, so let's assume that the standard deviation of the measurements is 0.5. I'm picking this because 0.5 is a large value, but it's not as large as the sd of 0.83 in the data. Indeed, 0.5^2 + 1/12 = 0.33 and 0.83^2 = 0.69, so I'm assuming that about half of the variance in the data is coming from measurement error.

But is 0.5 a reasonable value? To answer that question, it helps to have data.

The data at hand come from wave 3 of the Add Health study. I already downloaded those data awhile ago in preparing my earlier analysis, but I've had difficulty working with the numbers. I can't remember why, but there's no single dataset and no single codebook. It's kind of a mess. I spent a few minutes going through to see if there were any repeated measurements of attractiveness there, but I wasn't sure where to look.

So I googled *reliability of add health attractiveness measure*. I was hoping to find the names of the relevant variables in the survey, and that didn't come up in the search. What did appear was a bunch of research papers on the topic. I looked at a few of them and then came across this one: "Ugly criminals," by Naci Mocan and Erdal Tekin. I'm not so interested in the topic of the paper---I'll leave it to others to decide if its conclusions are reasonably supported by its data---; what's relevant here is that they discuss the Add Health attractiveness measure. Which is indeed how it came up in my search.

They looked at data from respondents whose attractiveness had been recorded in two waves. That's exactly what we need for a reliability analysis:

There's only one mild annoyance here: they pooled categories 1 and 2, and they pooled categories 3 and 4. So we don't have the full 5 x 5 table, only a 3 x 3 collapsing of it.

But we can deal with that. We'll just simulate and see what happens.

First we write a couple of simple functions:

round_and_bound <- function (a, lower=1, upper=5){
  pmin(upper, pmax(lower, round(a)))
}

clumped <- function(a) {
  ifelse(a==1 | a==2, 1, ifelse(a==3 | a==4, 2, ifelse(a==5, 3, NA)))
}

We set up the parameters for the latent data:

mu_obs <- c(3.87, 3.69)
s_latent <- 0.53
s_obs <- c(0.82, 0.52) 

Then we simulate two independent measurements on each of 14654 people---that's the number of cases in the above table:

y_latent <- rnorm(N, 0, s_latent)
y_obs <- array(NA, c(N, 2))
for (j in 1:2) {
  y_obs[,j] <- round_and_bound(rnorm(N, mu_obs[j] + y_latent, s_obs[j]))
}

And then we look at the two margins and the table showing the joint distribution of the two measurements:

print(table(clumped(observed_1)))
print(table(clumped(observed_2)))
print(table(clumped(observed_1), clumped(observed_2)))

I also looked at the unclumped data but I won't bother showing you that here.

Here are the results:

> print(table(clumped(observed_1)))
    1     2     3 
  668 11186  2800 

> print(table(clumped(observed_2)))
    1     2     3 
  723 11221  2710 

> print(table(clumped(observed_1), clumped(observed_2)))
       1    2    3
  1  227  437    4
  2  490 9292 1404
  3    6 1492 1302

These don't quite match the table above. The simulations have not enough "unattractive" people and too many "very attractive." Also they two waves in the simulations are essentially the same (by construction, as we simulated them from the same distribution), but the real data show a few more unattractive people and a lot more very attractive people in wave 1.

There would be a way to set up my simulation to alter its parameters and get the closest possible match to the observed two-way table---I guess it wouldn't be hard to program this in Stan, actually! But here I took the lazy way out and just tinkered with the numbers to get things to work. It took about five tries of playing with the inputs, and eventually I converged on this:

sd_measurement <- 0.5
mu_latent <- 3.8
sd_latent <- 0.67
latent_beauty <- rnorm(n_sim, mu_latent, sd_latent)
observed_1 <- round_and_bound(rnorm(n_sim, latent_beauty, sd_measurement))
observed_2 <- round_and_bound(rnorm(n_sim, latent_beauty - 0.1, sd_measurement*0.6))

As you can see, I hacked the simulations to give the wave 2 measurement a lower mean and lower variance.

Here's the result:

> print(table(clumped(observed_1)))
    1     2     3 
  845 10839  2970 

> print(table(clumped(observed_2)))
    1     2     3 
  731 11852  2071

> print(table(clumped(observed_1), clumped(observed_2)))
       1    2    3
  1  330  514    1
  2  400 9727  712
  3    1 1611 1358

OK, now I have the margins pretty good, but the joint table doesn't have enough people whose measurements shifted between the lowest and highest categories.

I played around some more with the parameters of the model but I couldn't get the counts to line up with the data.

So I bit the bullet and did what I should've done from the start, which was to write a Stan program to find a best fit. That was its own struggle---as is often the case, I learn a lot from these little examples---so I'll devote a separate post to it.

Here's what I ended up using:

mu_obs <- c(3.87, 3.69)
s_latent <- 0.53
s_obs <- c(0.82, 0.52) 
y_latent <- rnorm(N, 0, s_latent)
y_obs <- array(NA, c(N, 2))
for (j in 1:2) {
  y_obs[,j] <- round_and_bound(rnorm(N, mu_obs[j] + y_latent, s_obs[j]))
}

And here's the result, which is still not perfect (as will be discussed in my followup post) but is enough for my goals here:

> for (j in 1:2) print(table(clumped(y_obs[,j])))
   1     2    3 
 1225 9684 3745  

   1     2    3 
 815 11857 1982 

> print(table(clumped(y_obs[,1]), clumped(y_obs[,2])))
       1    2    3
  1  208  990   27
  2  563 8141  980
  3   44 2726  975

Which is far from a perfect match to the actual table of responses from the two waves:

> print(N_table)
     [,1] [,2] [,3]
[1,]  208  640   40
[2,]  501 9879  464
[3,]   51 1439 1432

But it's close enough, as we're just trying to make a general point about attenuation of effects under measurement error.

P.S. For the next story, see Constructing a latent-variable model to fit measurement data: A Stan story, part 2.

Survey Statistics: Times/Siena Polls and Times Voter Trends

Yesterday Andrew wrote about Alan Zaslavsky, who recently passed.

This is typical of his work in that it was innovative, with applied importance, and understated.

As Fan Li quoted, Alan was “the best applied statistician on earth”. I’ll write more Alan stories soon. He was my PhD advisor and hero.

Since it is election day, let’s talk about methods to analyze polls, where Alan’s legacy can’t be overstated. Fan Li mentioned work with Alan on balancing covariates, cited by Huling & Mak (2024) in their work on energy balancing weights, which are used by the Times/Siena Poll. This Survey Statistics series has discussed a few Times/Siena Poll decisions over the last year.

This week, in “The Final Polls Show a Blue Surge. Can We Trust Them?” Nate Cohn compares how the 2026 polls would look without these big changes, and sees they would be on average more than 3 points higher for Democrats.

Last week Andrew wrote about MRP at the NYT. So cool ! Their methodology article says:

The estimates do not report a margin of sampling error because they are not based on a sample of the population. The estimates are derived from multiple models, which are each subject to different kinds of error.

Yes, there are many kinds of error to consider, in “Margin of Error” we discussed how to get an MRP margin of error assuming no nonresponse bias after the MRP adjustments, no measurement error, and no model misspecification. In “Total Margin of Error” we saw that in election polls from 1998 to 2014, Shirani-Mehr et al. found that total survey error is about twice the reported margins of error. Even if you have margins of error to report, visualizing them is challenging (see Gelman and Price 1999 “All maps of parameter estimates are misleading”).

I was curious about the relationship between their MRP methods and their weighting methods. (See “MRPW”, “struggles with equivalent weights”, continued struggles, and “equivalent models, equivalent weights (locally)”, and “structured MRP to smooth survey weights”.) The only mention I found of their weights is:

The polls were joined to the given year’s voter file and reweighted to match the voter file by L2’s modeled race, party, age and interactions thereof, with the original survey weight as the base weight. The adjusted survey weight was used in all subsequent race models.

So they calibrate the base weights to match the voter file, see Lumley 2010 Chapter 7.

It’s been a few months since I’ve blogged about the logit shift, so it is time. (See: “2 flavors of calibration”, 2nd helpings (multinomial outcomes), 3rd helpings (multivariate outcomes), 4th helpings (more on multivariate outcomes), “logit shift and raking”.) The NYT uses a version of this shift:

The resulting individual-level probabilities were adjusted in multiple steps to match the actual election result by precinct. First, the probability that a voter would support a minor party candidate was adjusted to match the minor party proportion of the vote. Second, the probability that a voter would support a major party candidate was adjusted to match a candidate’s major party vote share in the precinct. Finally, the probability that a voter would support the Democratic or Republican candidate was calculated by multiplying the adjusted Democratic and Republican share of the major party vote by the adjusted major party vote share of the precinct.

Presumably they’re doing something like:

  1. E(shift_a(P(major party | X))) = P(major party) solve for a.
  2. Then either:
    1. E(shift_b(P(Dem | major party, X))) = P(Dem | major party) solve for b. Or
    2. E(shift_a(P(major party | X)) * shift_b(P(Dem | major party, X))) = P(Dem) solve for b.

2A isn’t quite right: it implies E(shift_a(P(major party | X))) * E(shift_b(P(Dem | major party, X))) = P(Dem). But we want 2B to hold, and the two are equivalent only if the individual-level probabilities for major party and for Dem given major party are uncorrelated.

It’s hard to write prose to describe something technical. The NYT level of methods transparency is great !

“Evolutionary psychology hypotheses are testable and falsifiable.”

Eric Charnov points to this recent article by William Costello et al., which begins:

The field of evolutionary psychology has often been the target of allegations that its hypotheses are unfalsifiable. . . .

We . . . present evidence of several evolutionary psychological hypotheses that have generated specific, falsifiable predictions; undergone multiple empirical tests; and been refuted. Specifically, we discuss the evidentiary status of (a) the ovulatory shift in mate preferences (dual-mating) hypothesis, (b) the mate deprivation hypothesis of rape, and (c) the kin altruism hypothesis for the evolution of male homosexuality. We contrast these with the wide range of evolutionary psychology hypotheses whose specific predictions have been robustly supported by empirical data.

. . . many academics continue to perceive evolutionary psychology as unfalsifiable, despite evidence to the contrary, a misconception that has also permeated mainstream culture. . . . By illustrating that hypotheses generated by evolutionary psychology can be directly tested with appropriate scientific rigor, we dispel these pervasive misconceptions and highlight the field’s heuristic potential for generating valuable insights into human behavior.

It’s interesting to see this article. I have to admit I have a generally negative view of evolutionary psychology, a view that probably isn’t so fair. The problem is that I’ve been exposed to a lot of bad evolutionary psychology . . . David Weakliem and I wrote a whole article about it.

Also some blog posts. Let’s search on “evolutionary psychology” and see what comes up:

2025:  I have a horrible feeling sometimes that heavily promoted crap research on space aliens, cold showers, mind-body healing, schoolyard evolutionary psychology, extra-sensory perception, magic golf balls, air rage, himmicanes, subliminal smiley faces, etc etc etc, has softened the ground so that the seeds of more evil trees could then be planted and take root.

2023:  Hey—here’s some ridiculous evolutionary psychology for you, along with some really bad data analysis.

2022:  Evolutionary psychology in economics: Mo papers, mo problems

And some things I’ve written:

2025:  I don’t mean this in a sinister way, necessarily, the idea that crafty researchers are using their networking powers to insert bad work into the literature—even though, yes, I think this happens all the time—but rather in more general terms, that it takes a lot of active effort to keep these bad ideas in embodied cognition, evolutionary psychology, subliminal effects, etc., continuing in the scientific literature. In the same way that the Loch Ness monster, UFOs as space aliens, and various political conspiracy theories require constant refreshing to stay in the news. Yes, people hold all sorts of silly beliefs—a third of Americans say they believe in ghosts!—but passive belief is not enough. Well-connected people need to be actively promoting them, or they drift to the back of the collective consciousness.

2025: The [erroneous] belief that if a general phenomenon (e.g., “nudge,” or “evolutionary psychology,” or “social priming”) is real, that it will show up in the same direction no matter how it is studied (for nudging this could be investment decisions or food choice or risky behaviors; for evolutionary psychology this could be the sex of babies or religious behavior or voting behavior; for social priming this could be walking speed or hormone levels or political attitudes; etc.).

2025:  I also don’t see any substantive theory behind the claims, other than that it seems very intuitive to people that (1) the sex of a baby should be predictable and (2) sex ratios should vary a lot.

I think the basis for that first intuition is gender essentialism: men and women are so clearly different that it just stands to reason that they should somehow be externally distinguishable (in the pre-ultrasound era) even in the womb, and that the sex of the baby should be influenced by various ways as might be explained by gender essentialism.

I think the basis for the second intuition is what Tversky and Kahneman called “the law of small numbers”: everybody knows someone with several siblings, all of the same sex. People don’t have a sense of the huge sample size that would be needed to learn anything useful from such data, even setting aside selection and recall issues. Also, gender essentialism: it just stands to reason that parents of boys should be more masculine, in some way, than parents of girls. This bit of intuition can be backed up by endless speculation of the sort that is called evolutionary psychology and which plays well in Freakonomicsland.

2024:  In some settings, I fear that “replication” is serving a shiny object to distract people from the central issues of measurement, and I think that’s what’s going on here. The authors of this study were working with some vague ideas of evolutionary psychology, and they seem to be working under the assumption that, if you’re interested in theory X, that the way to science is to gather some data that have some indirect connection to X and then compute some statistical analysis in order to make an up-or-down decision (“statistically significant / not significant” or “replicated / not replicated”).

Again, that’s not enuf! Science isn’t just about theory, data, analysis, and conclusions. It’s also about measurement. It’s quantitative. And some measurements and designs are just too noisy to be useful.

2012:  Schoolyard Evolutionary Biology: The idea that, because of evolution, all people are equivalent to all other people, except that all boys are different from all girls.

OK, so that’s some attitude.

That said, I don’t recall ever characterizing the hypotheses coming from evolutionary psychology as unfalsifiable.

Let me put it this way: I think that evolutionary psychology can produce falsifiable predictions (there I agree with Costello et al.); I also think it is often employed in an unfalsifiable way, either by motivating flexible stories that can explain any possible data pattern, or though flexible data analysis (“forking paths”) that can fit any theory.

Stepping back, I don’t think evolutionary psychology, as a whole, is falsifiable. But that’s ok. I don’t think that any science is falsifiable as a whole. I don’t think chemistry or physics are falsifiable either. Evolutionary psychology, like chemistry and physics, is a framework under which falsifiable theories can be developed. Which is fine; indeed, Costello et al. carefully write, “Evolutionary psychology hypotheses are testable and falsifiable,” not that evolutionary psychology as a whole is testable and falsifiable. I would just amend their statement to, “Some evolutionary psychology hypotheses are testable and falsifiable.”

But then you get to the specific cases in the paper, the several evolutionary psychological hypotheses that they say were “refuted,” and . . . I don’t know!

What they describe as “refutations” look to me more like unsuccessful replications. Or, more specifically, results that are not statistically significant. But a not-statistically-significant finding is, at most, a refutation of the hypothesis that the average effect is large (relative to the standard error of estimation); it does not refute the hypothesis that there is a nonzero effect, or that there is an effect in a specified direction.

This is not to say that data can’t inform theorizing in this area. I just think that the framework of “falsification” isn’t so useful here, as it doesn’t address three key factors in the experimental human sciences:

1. The uncertainty involved in learning from statistical evidence in the presence of variation or noisy measurements;

2. The often shaky connection between underlying scientific theories and the particular statistical models being tested;

3. Variation in effects, which can be positive in some settings and negative in others, making it difficult to pin down exactly what is the hypothesis being tested.

For better or worse, I think we need to give up on strict falsificationism and move to a more Lakatosian perspective in which theories are informed by data. And all this presupposes that we’re doing serious science and not screwing around with experiments that are essentially pure noise.

Again, these are issues with the human sciences in general, nothing special about evolutionary psychology here.

This guy has a transformer-based election forecasting model

Harvey Olden writes:

I’ve developed an election prediction model based on a transformer architecture; I thought you might find it interesting. The model will update its information automatically in the run-up to the midterm elections; you can also click on a state/district to see what information the model is leaning on to make its predictions. You can find an explainer for exactly how it works in the website.

I can’t follow the explanation myself, but that’s on me, that I’ve never actually learned exactly what a transformer is. This is not a boast—I’d be a better statistician if I understood such things—just my honest admission of imperfection.

So, given that, I can’t say much about the above forecast, but I thought it might interest some of you, at least from a methodological perspective. There must be some aspects of forecast uncertainty that are well captured by this model and also some weaknesses, corners of probability space where the model architecture induces artifacts (by analogy to the edge-case absurdities we found in a different sort of forecasting models a few years ago and which made their way into Section 8.1 of our Bayesian Workflow book, under the heading, “Exploring inferences to reveal problems with a model”). I haven’t been following the 2026 races closely enough to know what problems to look for, and I don’t see a Github site or anything else with the model’s data, code, or predictive simulations. But if that’s out there somewhere, then youall can take a look.

Survey Statistics: how to measure hospital quality ?

Last week we chatted about hopes for a new edition of Lumley 2010.

Preview

Alan Zaslavsky recommends this textbook in his course. After taking the course in 2011, I asked Alan to advise my PhD. Alan’s work extends across most topics in Lumley’s textbook and beyond. One focus is statistical issues in measuring the quality of a hospital: how can we compare hospitals who see different distributions of patients (i.e. casemix) ? Zaslavsky 2001 explains a few approaches, including direct standardization.

Let:

  • Y = complications
  • X = sickness of the patient
  • R = hospital, can be A or B
  • Y(A) = complications if treated by hospital A
  • Y(B) = complications if treated by hospital B

To compare hospitals A and B, we want to compare Y(A) versus Y(B). We cannot do this for one patient, because at least one of Y(A) or Y(B) is not observed. But we can compare averages. We can compare E(E(Y(A) | X, R = A)) versus E(E(Y(B) | X, R = B)) where the outer expectations are with respect to some standard casemix of X. Direct standardization estimates the inner expectations with the mean in each X stratum. As Zaslavsky 2001 points out, this needs modification if there are no patients in a stratum, or when X is continuous. Instead, the inner expectations can be estimated with regression models.

See Figure 2 from Zaslavsky 2001:

Lumley 2010 points out that direct standardization is mathematically equivalent to poststratification:

 

A big problem with conventional experimentation or A/B testing is that the treatment effect can vary over time and it can depend on the entire history of the treatment. Usual comparisons miss this point.

Andrea Bronzini points to this article and writes:

I’m working on experimentation tooling and wrote a brief note about a failure mode I keep seeing: “winning” A/B tests often lose uplift after rollout.

My claim is that the typical setup mixes novelty response with steady-state effect because assignment happens after first exposure, and the outcome is time-dependent.

My reply: I think he is identifying a real problem. The problem he identifies is a special case of the issue that the treatment effect can vary over time and it can depend on the entire history of the treatment, and I guess that ultimately the best solution is to model these sources of variation.

I also like this bit from his webpage:

He saw how the industry’s obsession with certainty slowed businesses down… so he decided to fix it. . . .

Confidence ≠ Certainty.
Data is never complete.
And that’s why we need to embrace taking decisions with risk.
Progress belongs to those who act while others wait.

Also relevant is my talk (not yet a paper), It’s About Time.

Survey Statistics: textbooks adding non-probability sampling chapters

Last week I asked for your favorite survey statistics textbooks. Thank you for many fun recommendations here and on Bluesky ! I am compiling a reading list for after the election. Here’s some not-blue-sky on the AT in TN:

Ben Schneider and Winston Lin share my love for Lumley 2010. I agree that it’s fun and a second edition would rock.

Preview

Some recommended books added sections on non-probability sampling in their new editions:

Lumley 2010 already includes material applicable to non-probability sampling, see e.g. “2 flavors of calibration”. If there is a second edition maybe it will follow the books above and add a chapter about non-probability sampling ?

(See “probability samples vs epsem samples vs SRS samples” for more about the term “non-probability sampling”.)

“Death and Taxes: Taking Causal Inference into the Real World”

Nandita Mitra is giving a webinar this Tuesday at noon with the above title and the following abstract:

Statisticians develop methods with the hope that they will ultimately inform decisions and improve the world around us. But taking causal inference into the real world requires more than choosing the right estimator: it requires identifying the question that matters, engaging deeply with its context, and communicating statistical reasoning to very different audiences.

In this talk, I will draw on two experiences in which causal inference took me well beyond traditional statistical applications. I will first discuss my experience serving as an expert witness in a death penalty case involving racial disparities in jury selection, where ideas including confounding, mediation, and individual- versus population-level effects had to be translated into compelling and understandable arguments in a court of law. I will then describe my involvement in evaluating Philadelphia’s excise tax on sweetened beverages, where cross-border purchasing led us to confront interference and develop methods to better inform policy decisions.

Through these examples, I will reflect on how statisticians can seek opportunities to bring their expertise to consequential real-world problems, and on the importance of collaboration, communication, and stepping outside our usual academic boundaries. Most importantly, you don’t have to choose between being a methodological statistician and having an impact outside statistics.

This looks interesting. Click on the link above to register for the talk and get the zoom link.

Seeking to interview social scientists experimenting with LLM simulations of opinions or behavior

This is Jessica. As part of our interest in how social scientists are using LLM simulations of human behavior, some collaborators and I are seeking interview participants. We are thinking about tools to support rigorous design and evaluation of such studies, and would like to hear examples of goals and challenges that researchers who are experimenting with LLM simulations are facing.

Specifically, we’re looking for researchers in academia or industry who are currently using LLM simulations in their work and could bring a simulation dataset (and optionally, human ground truth data) that they are working with to the interview. We are interested in use cases like piloting surveys or experiments with LLMs, replacing or supplementing human participants in surveys or experiments with LLMs, or using LLM simulations for post-study analysis or theorizing. The interviews should take no more than 1 hr.

Email me and Xudong Tang ([email protected]) if interested, and/or pass this on if you know of social scientists who might be.

How surprising is it that LeBron averaged 27 points, 7 rebounds, and 7 assists in his career but never had one game where he had 27 points, 7 rebounds, and 7 assists?

Joshua Brooks writes:

Listening to a Bill Simmons podcast and the stat came up (not confirmed) that over sixteen years Lebron averaged 27 points, 7 rebounds, 7 assists but never had one game where he had 27 points, 7 rebounds, and 7 assists.

Bill and his guest thought that’s a crazy improbable stat and I guess maybe intuitively it does, but while I’m no statistician I’d imagine the three dimensional nature of the stat would mean it’s not all that in improbable.

But what’s interesting is the category: what is the category of probabilities that seem intuitively (to the average Joe) as improbable but mathematically, are probable? And what are the characteristics of stats that fall into that category?

Hmmm . . . just to do a very crude calculation, suppose that in any game LeBron could score between 17 and 37 points, between 2 and 12 rebounds, and between 2 and 12 assists, with uniform distributions, then his probability of scoring exactly 27/7/7 would be approximately 1/2000. It turns out that he’s played approximately 2000 games, so it wouldn’t be a surprise if he’s ever had a 27/7/7 game but it’s not a surprise if it’s never happened. (I don’t know if it’s really never happened; I’m just relying on a third-hand report here.) I guess we should really bump up the probability a bit here, given that 27, 7, and 7 are in the middle of the distribution, but even if an appropriate probability is 1/1000, it’s still no shocker for it not to happen in 2000 games.

Brooks points to this clip where Simmons describes it as a “crazy” stat, but I agree that it’s not so crazy as all that. Bill Simmons is entertaining and thought provoking, but he’d never be mistaken for a quant.