SparseNUTS: Preconditioning hierarchical models in HMC with a sparse “Laplace approximation” at the marginal mode

This post is from Bob.

Cole Monnahan (who came up with the idea and did the heavy lifting), two of his colleagues from the Template Model Builder (TMB) project, Kasper Kristensen and James T. Thorson, and I just put a paper up on arXiv.

If you have any feedback on either, we’d love to hear it.

The method

It’s quite simple if you know how the components work. The tricky part is getting them all to play together nicely, efficiently, and robustly.

1. Take a max marginal mode of a hierarchical model, of the kind produced by the linear mixed effects package (lme4) or Template Model Builder (TMB). Both packages are implemented in C++ under the hood and distributed with an R interface.

2. Center a second-order Taylor series approximation at the marginal mode using a precision matrix (inverse covariance) rather than covariance matrix. This is like a Laplace approximation, but it’s not centered at a global mode.

3. Take the resulting sparse precision matrix and use it to precondition the target density. This is equivalent to using the precision as a mass matrix in HMC, as Radford Neal showed in his introduction in the MCMC Handbook. This approach is necessitated by Stan’s lack of sparse mass matrix support.

4. Use TMB’s R interface and Andrew Johnson’s StanEstimators package to make the model available to Stan’s samplers and other tooling.

There’s nothing Stan-specific about this technique. It could be rolled into PyMC and NumPyro with a lot of work if JAX’s experimental sparse library is up to the task of duplicating what TMB is doing.

Empirical evaluation

The paper is evaluated on 15+ realistic models, some of which can be scaled. The results show that with this preconditioning, Stan can scale to 10K+ parameter hierarchical models when there is sparseness and high correlations.

The paper demonstrate how much better SparseNUTS is than trying to use Stan’s built-in diagonal or dense mass matrix estimators. Obviously, the dense mass matrix won’t scale to 10K parameters as the mass matrix will have 100M entries and that becomes nearly impossible to estimate or manage computationally in Stan. Stan is very slow to estimate mass matrices in these cases (WALNUTS should be better, which we hope to roll out soon), but the real problem is that diagonal preconditioning is insufficient for hierarchical models.

Should you use it?

Yes! The form of hierarchical models addressed by SparseNUTS are widely used and Stan by itself simply cannot fit them. SparseNUTS also provides much more flexibility than INLA in writing custom likelihoods and priors.

Why not code this method in Stan?

We do not have the sparse Hessian tooling within Stan’s automatic differentiation library to implement this directly. Nor are we likely to roll out something for specific model classes, as we try to stick to black-box techniques in the core of Stan. This isn’t because we don’t like model-class specific methods. We are happy to implement them in special packages like brms. It’s just because one has to limit one’s scope somehow to keep a software project manageable with limited developer hours.

Some alternatives on the horizon

We are evaluating how far we’ll be able to scale Charles Margossian’s black-box approach to marginalization, which Steve Bronder and Charles have gotten into shape so it will be in the next Stan release. As INLA demonstrates, marginalization can be an efficient alternative to sampling the whole model if you can get the marginalization right.

We’re also evaluating how far we can get with Adrian Seyboldt’s Nutpie sampler’s approach to estimating low-rank plus diagonal mass matrices based on Fisher divergence, which could also potentially solve this problem as most of the structure in hierarchical models is low rank. Adrian and Eliot Carlsen (both of PyMC Labs) and I are writing that up now and we will release the paper soon. So far, Nutpie’s low-rank plus diagonal adaptation works incredibly well for some problems, but fails spectacularly on others for reasons we do not yet understand.

Bayesian inferences and frequentist evaluations

Martin Forster, Marco Novelli, and Charlie Welch recently posted this preprint, which begins:

We use innovations from the frequentist and Bayesian decision-theoretic sequential experimental design literature to study whether, and when, recruitment to a pandemic-disrupted clinical trial should restart. We consider four frequentist and two Bayesian designs, two of which are new, and apply them to data from the UK’s ‘DISC’ trial, a publicly-funded trial whose recruitment was seriously disrupted by the COVID-19 pandemic. The results delivered by all six designs concur with the DISC trial’s results concerning treatment superiority. However, they do so with different levels of information, owing to different recommendations about restarting recruitment. Referencing work on the seven virtues of good statistical practice, we consider how confronting the same experimental data with a range of statistical models could assist policy-makers tasked with managing non-pandemic clinical trials during a future pandemic.

Christian Hennig pointed me to this because it makes reference to our Beyond Subjective and Objective in Statistics paper and our list of virtues:

I’m happy to hear that our framing of statistical practice in terms of these different virtues, as opposed to the unclear (to me) characterizations of methods as “subjective” or “objective,” has been helpful to these researchers.

I did not try to follow the details of the Forster et al. paper, so I will just offer some general thoughts on their endeavor, which is to compare frequentist and Bayesian sequential experiments in their applied context.

Many years ago Don Rubin pointed out that, although Bayesianism and frequentism may represent different philosophies of statistics, they are not directly comparable as methods. Bayesian statistics is a framework for producing inferences given data and assumptions; frequentist statistics is a framework for evaluating inferences given assumptions. The assumptions in the two approaches can be different; the key point is that Bayesian and frequentist ideas can go together. You can use Bayesian methods to create an inference (for example, an estimate or a hypothesis test or a confidence interval or a probabilistic prediction) and then use frequentist methods to evaluate it. Or you can use non-Bayesian methods to create a inference and then use the Bayesian framework to interpret it as an approximate Bayesian inference under some assumptions.

The pairing of Bayesian and frequentist ideas is not necessary. You can set up a model and do Bayesian inference without any further frequentist evaluation (beyond the automatic property of Bayesian inferences that they have the correct frequency properties when averaging over the assumed prior and data distributions). Conversely, you can perform frequentist evaluation of an inference that was not constructed from any Bayesian model; indeed you can sometimes construct purely frequentist inferences derived from some non-Bayesian principle such as minimax loss.

But, if you are considering various inferences, Bayesian or otherwise, it makes sense to look at their frequency properties. This is a point that Rubin made in his classic paper from 1984.

This is not automatic. Just as Bayesian inference is not a single thing but rather a framework (that is, the inference depends on your prior and data model, not on the observed data alone); similarly, frequentist evaluation involves choices, both in what frequency properties to look at (for example, unbiasedness is often taken as a desirable feature in estimation but does not make sense for probabilistic prediction, a point we make in chapter 4 of Bayesian Data Analysis; see the example on page 94 of BDA3) and in what assumptions to be made about the underlying system and the data-collection process. Bayesian methods are correct when averaging over the joint distribution of parameters and data, and frequency evaluation involves averaging as well: that’s why I say that Bayesians are frequentists.

Just as I don’t think all Bayesian inferences are good (you can have a model that makes no sense, or is inappropriate for the problem under study, or has mathematical artifacts that can be tricky to discover, as in section 3 of this paper), I also don’t think that all frequentist evaluations are appropriate. I’ve already mentioned the problem with applying the concept of unbiased estimation to prediction problems; also I’m on record as generally opposing the so-called Fisher exact test (see section 3.3 here) on the grounds that it corresponds to a data distribution–a generative model for data given parameters–that almost never applies in real life. I similarly don’t like classical multiple comparisons methods, because they are designed to guard against the generally irrelevant condition that all true effects are exactly zero.

So, yeah, doing good Bayesian inference is not always easy–you need to construct that generative model of parameters and data–and doing good frequentist evaluation is not always easy either: you need to think about what’s a reasonable model to use for the data distribution to average over, and come up with a range of plausible parameter values. But it can be done, and, indeed, if you want to compare methods, it must be done. Frequentist evaluation is the only game in town. Although it can be done approximately or implicitly, for example using cross validation or external validation of predictions without ever formally setting up a model to be averaged over.

P.S. The authors respond to the comment thread here.

Remembering David MacKay

Pilgrim Beart informs us that is Cambridge Philosophical Society is organizing a meeting on Energy and Information to mark the 10th anniversary of David MacKay’s untimely death. Beart asked me to share any tribute to MacKay, and I sent him this:

In his classic 2003 book on information theory, David wrote that, “in many problems, we really only need about twelve independent samples.” He explains: “Now, how accurately would a manager like to know [a parameter] Φ? I would suggest there is little point in knowing Φ to a precision finer than about σ/3. After all, the true cost is likely to differ by ±σ from Φ. If we obtain R = 12 independent samples from P(x), we can estimate Φ to a precision of σ/√12 – which is smaller than σ/3. So twelve samples suffice.”

This led me to wonder . . . . . . where did the “12” come from in MacKay’s passage? When I first saw the number there, I assumed it would have something to do with the variance of the uniform distribution. But that doesn’t seem to come up at all. Accepting MacKay’s stipulation that σ/3 would be enough precision in this sort of example, shouldn’t he have said that 9 random draws would suffice? I could see him rounding that up to 10. Or even 16, if he wanted to get all base-2 on us. But why 12? I didn’t get this at all.

So I asked David. Here was his reply: “You said that can imagine rounding up 9 to 10 – which would be elegant if we worked in base 10. But in the UK we haven’t switched to base 10 yet, we still work in dozens and grosses. . . . Probably in an earlier draft of the book in 2001 I said ‘a dozen’, rather than ’12’. Then some feedbacker may have written and said ‘I don’t know what a dozen is’; so then I sacrificed elegant language and replaced “dozen” by ’12’, which leads to your mystification.”

This reminds me that, when I was a kid, my dad told me that in Britain there was a Duodecimal Society, devoted to promoting base 12. This was told to me in a “There will always be an England” sort of thing. In writing this note, I was curious so I looked it up on the web, and it turns out that there is such a society, but it was first established in the United States. So there! I guess David was more American than he realized.

I thought that would be better than ranting about why I agree with Radford Neal and disagree with David MacKay about Occam’s razor (although David claimed I actually agreed with him). I guess I can send them that story in the next commemoration, a decade from now.

It’s actually a good story in that I thought we disagreed, but David disagreed with me on whether there was a disagreement.

David Mackay was a smart, generous, and committed person. It’s good to remember that such people exist: not every important person science is like this guy or these guys or these guys or these guys. The greedy people who did all those things often seem to feel like their behavior is ok because everybody does it. David Mackay is a reminder that, no, better things are possible.

A link to the conference is here. There’s also a form where you can share your memories of him.

Fitting a model to estimate the seats-votes curve, back in the bad old days before we had Stan

Look how hard we had to work:

OK, it wasn’t all that bad. We did it, after all. Still, it was a lot of work. The next page of the paper describes how we used a third-degree-polynomial to approximately compute expectations with the logit transformation.

The real point is not that we can fit this particular model much more easily now, as that with Stan and similar tools we can fit more complicated models to larger datasets and answer more sophisticated questions. Indeed, nobody even talks about the seats-votes curve any more!

Some Open Problems in Probability that are Relevant to Applied Statistics (my talk this Wed noon at the Columbia statistics department student seminar)

Wed 11 Feb noon in room 1025 of the Social Work Building:

Some Open Problems in Probability that are Relevant to Applied Statistics

Andrew Gelman, Department of Statistics and Department of Political Science, Columbia University

How does probability theory apply to statistical practice? Not just through the usual limit theorems of fixed-model asymptotics. Probability theory also has interesting and important challenges related to models of growing complexity. Solving some of these probability problems should allow us to fit more accurate models and make better predictions and inferences in the real world. We motivate and explain several of these open problems: piranha theorems, incoherent Gibbs sampling, the martingale property of probability forecasts, predictively consistent priors, and infill or sprawl asymptotics.

Here are some references that start to address these topics:
– [2025] The piranha problem: Large effects swimming in a small pond. Notices of the American Mathematical Society 72, 15-25. (Christopher Tosh, Philip Greengard, Ben Goodrich, Andrew Gelman, Aki Vehtari, and Daniel Hsu)
– [2001] Using conditional distributions for missing-data imputation. Discussion of “Conditionally specified distributions” by B. Arnold et al. Statistical Science 3, 268-269. (Andrew Gelman and T. E. Raghunathan)
– [2014] On the stationary distribution of iterative imputations. Biometrika 101, 155-173. (Jingchen Liu, Andrew Gelman, Jennifer Hill, Yu-Sung Su, and Jonathan Kropko)
– [2024] It’s martingale time, baby! How to evaluate probabilistic forecasts before the event happens? Rajiv Sethi has an idea. (Hint: it involves time series.) Statistical Modeling, Causal Inference, and Social Science, 24 Sep. (Andrew Gelman)
– [2025] R2 priors for grouped variance decomposition in high-dimensional regression. Arxiv, 24 Jul. (Javier Enrique Aguilar, David Kohns, Aki Vehtari, and Paul-Christian Bürkner)
– [2013] Infill asymptotics and sprawl asymptotics. Statistical Modeling, Causal Inference, and Social Science, 30 May. (Andrew Gelman)

And here’s some background on why I chose this subject:
Continue reading →

A consensus–but it’s a consensus of uncertainty.

Jay Kadane sends along this this new paper on subjectivity and objectivity in Bayesian statistics, which of course reminded me of my 2017 paper with Christian Hennig on the same topic.

In response to my article, Jay wrote that he agreed with much of what we wrote, but:

My [Jay’s] qualm is the emphasis on consensus, which in my view, is not necessarily a virtue at all. Let me give an example from my own work. In Grossman et. al. (2011) [Bayesian Analysis 6 (#5), 547-572, doi 10.1214/11-BA62], we address the question of whether the number of hurricanes in the North Atlantic had increased in the last 150 years (because, perhaps, of the industrial revolution and the resultant increase of carbon in the atmosphere.) A reasonable question, I think.

It turned out the there’s a standard database of Hurricanes (HURDAT) run by physicists, who require at least 2 independent measurements of wind speeds greater than some threshold I forget, for a storm to be listed The issue we found is that our ability to detect hurricanes has increased enormously in that period. In the beginning, there were landfall and ship observations only. At the end of the period there were satellites that see everything. So we had to model the probability of observation as a function of time. When we did that, we found that by changing the prior on one parameter in seemingly innocuous ways, we could get increasing, constant or decreasing frequency of hurricanes. So our bottom line is that we don’t know, and we expect nobody’s going to know, the answer to the question we posed. Pressure to achieve consensus here is counterproductive. Sometimes we just have to live with not having a consensus, not knowing what we wish we did. Sometimes lack of consensus is the story, and it would be wrong to make this non-virtuous.

Fair enough, and indeed Jay’s example demonstrates the virtue of “investigation of stability,” listed in table 1 of my article with Hennig:

Regarding consensus . . . I think that in Jay’s example, the appropriate consensus is that we just don’t know! There are some settings where I feel we just don’t know, but there is no consensus on that (see for example here), but for this hurricanes thing, perhaps a good statistical analysis accounting for uncertainty can help to create such a consensus agreement of ignorance. Scientific consensus can include uncertainty.

I agree, though, that a lot of people–even in fields such as computer science or finance where uncertainty is prevalent–often seem to want a consensus of certainty, even when it is not possible. This came up last year in the context of election forecasts. Back in 2024, for our Economist magazine election model, we put together economic and political fundamentals and state and national polls and came to the conclusion that the presidential election was likely to be very close, and the two candidates each had about a 50% chance of winning. Lots of people understand this idea, that a careful forecast can end up giving probabilities close to 50%, but some people were confused on the point. One person faulted our forecast for not predicting a “landslide,” which was kind of funny given that the election was not a landslide at all; it was very close. Another person characterized the 50-50 forecast as “giving up,” which was completely wrong because to say that you think the election will be close is itself informative. It’s similar to a football game where the point spread is zero: this represents information on the relative strengths of the teams.

Anyway, my point here is that in 2024 there was a consensus among reasonable forecasters that the election was highly uncertain–some forecasters gave Trump a 2/3 chance, which was also reasonable, but that would be considered close too–, but there were some people who couldn’t handle this uncertainty and didn’t recognize it as a consensus. So I see Jay’s point.

The anti-Bayesian is standing at the back window with a shotgun, scanning for priors coming over the hill, while a million assumptions just walk right into his house through the front door. (also, an interesting point by Yann LeCun in 2012 about human language)

I just like the above line, which comes from this post from 2012. The comment thread is a bit of a mess, with people jumping in and attributing to me things that I’d never said–it’s that “vibes” thing–but it also featured an interesting exchange with the computer scientist Yann LeCun.

In one part of my post I’d discussed the example of language learning, in which our brains figure things out using a pre-existing structure (not for Chinese, Arabic, or English, but for human language in general), and I wrote that this structure represents prior information: “That’s the whole point: our brains are tuned to decode human language.”

LeCun wrote:

Actually, it’s the other way around: human language is designed (by humans themselves) to be easily decodable by the human brain.

Also, language is hardly “one of the most complicated tasks imaginable.” Language evolved in a very short time (perhaps 300,000 years), and is performed by a tiny part of the cerebral cortex. It can’t possibly be that complicated. We want it to be complicated because we think of it as uniquely human: It’s what makes us human superior to other animals.

In reality, vision is enormously more complicated than language. It evolved over hundreds of millions of years, and takes up 1/4 to 1/3 of our entire brain. Yet we take it for granted, because other animals seem to be able to do it.

Interesting point!

“Parallelizing MCMC Across the Sequence Length”: This one is really cool.

David Zoltowski, Skyler Wu, Xavier Gonzalez, Leo Kozachkov, and Scott Linderman write:

We propose algorithms to evaluate MCMC samplers in parallel across the chain length. To do this, we build on recent methods for parallel evaluation of nonlinear recursions that formulate the state sequence as a solution to a fixed-point problem and solve for the fixed-point using a parallel form of Newton’s method. We show how this approach can be used to parallelize Gibbs, Metropolis-adjusted Langevin, and Hamiltonian Monte Carlo sampling across the sequence length.

Bob Carpenter presented their paper at the computation seminar last week. Bob was enthusiastic about this work, and his enthusiasm was contagious.

The above graph shows what’s happening.

“Sequential Sampling” is when they run HMC on this example. The gray line shows the trajectory or sequence of simulation draws. (Here they just do one chain to demonstrate the idea, but later in the paper they talk about the benefits of simulating multiple chains.) The trajectory is a random vector, but it can be thought of as deterministic, conditional on the sequence of random numbers that is used to do the jumping and make the accept/reject decisions.

Here’s the idea: Given the input sequence of random numbers, the goal is to compute that trajectory. But rather than doing it the usual way, by running HMC, they do it by starting with an initial guess–here, the flat or constant trajectory shown as the horizontal line of the top graph above in the “Parallel Sampling” column–and then moving the points around until they reach the correct trajectory. This can be done because the correct trajectory is Markovian (in this case, first-order Markov), and the value at each time point from t=1 through t=1000 is a known deterministic function of the value at time t-1 and the set of input random numbers corresponding to that iteration. They write this as s_t = f_t(s_{t-1}), where f_t is that deterministic function, and the random numbers for time t are implicitly included in f_t.

Each iteration of the parallel algorithm is a step in which the values of the trajectory at each point are jiggled up and down in an attempt to make each s_t as close as possible to f_t(s_{t-1}), for each t. The beauty of this algorithm is that these updates can be done locally, so you can do them in parallel. It turns out that this can be done in O(log(T)) ticks of wall time. The update requires O(T) computations but with enough processors the parallelism saves lots of time.

When does this make sense? I know next to nothing about parallel computing, but apparently it can be done on GPUs, and there are now programming languages that can distribute the computing steps.

There are lots of details that make this work, including using autodiff on the functions f_t.

Discarding bad approximations in the middle of the chain?

Here’s something I noticed about their example.

Look at Figure B above: it shows that after 147 iterations of the parallel updating, the computation has reached the correct values of the chain for this set of input random numbers. But what about after 10 iterations? It’s pretty damn close already! There seem to just be 4 or 5 points that are in the wrong place.

So here’s my question. Could there be a way, if you want to stop early, to identify those bad points and throw them out?

Usually when we’re doing HMC, you have to keep the whole chain or throw it all out, or maybe you keep running it and you throw away the initial part that hasn’t completely warmed up. But in this new algorithm, the entire chain is a static target, so it seems that it might be possible to just throw away a few bad iterations in the middle.

At first this idea might seem hopeless: if you don’t know the final answer, how would you know which points to throw out? But we can compare each s_t with f_t(s_{t-1}), so maybe just take the points where the discrepancy is large and toss them?

As a start, I’d be interested in how things work with the example shown above. Do the bad points in parallel iteration 10 correspond to large values of |s_t – f_t(s_{t-1})|? If so, maybe there’s something we can do here! Nothing stopping us from continuing to run all the way to parallel iteration 147 or whatever, but in the meantime maybe we can do better along the way.

Postdoc in Milan on scalability for high-dimensional Bayesian learning

Giacomo Zanella writes:

I am currently advertising a postdoc position based at Bocconi University in Milan, supervised by myself and funded by the ERC Starting Grant, “Provable scalability for high-dimensional Bayesian learning.” The duration of the position is until 30 April 2028. Short extensions might be possible depending on availability of further funding.

The deadline for application is 03 March 2026 and the planned starting date is 1 July 2026 or later. Candidates are welcome to write to me at [email protected] with any question about the position.

Here’s the webpage of their Bayesian learning laboratory. Looks cool!

I heard about this position from Bob Carpenter, who adds:

Giacomo’s done some of my favorite work in the field recently. His use of Picard iterations is where I first saw the MCMC as optimization thing last summer. He’s also the one who’s been publishing with Gareth about situations where Gibbs is faster than HMC, so you should be simpatico.

That sounds just great. They’re doing interesting work on an important set of topics.

A counterintuitive example where a strong prior pulls an estimate in the wrong direction–and how to see the problem

It goes like this. We start with a simple linear regression. In the Stan code we first simulate data given the true parameter values and then express the model:

data {
  int N;
  real a_true, b_true, sigma_true;
}
transformed data {
  vector[N] x;
  vector[N] y;
   for (n in 1:N) {
    x[n] = uniform_rng(0, 50);
    y[n] = normal_rng(a_true + b_true * x[n], sigma_true);
  }
}
parameters {
  real a, b
  real<lower=0> sigma;
}
model {
  for (n in 1:N) {
    y[n] ~ normal(a + b * x[n], sigma);
  }
}

And here are the input data:

{
  "N": 100,
  "a_true": 20,
  "b_true": 0.8,
  "sigma_true": 15
}

We compile and run it in Stan Playground, setting the seed to 123, and here are the results:

This all seems reasonable. The true values of a, b, and sigma are 20, 0.8, and 15, and the estimates are 19.0 +/- 2.9, 0.85 +/- 0.10, and 15.5 +/- 1.2.

Now let’s try throwing in a prior. I’m gonna use my default prior for parameters on unit scale:

  a ~ normal(0, 1);
  b ~ normal(0, 1);
  sigma ~ exponential(1);

This goes into the model block of the above Stan program.

Before going on, let me point out that the parameters of this problem are not on unit scale. By “unit scale,” I mean, “being drawn from a distribution with scale that is of order 1,” and a_true = 20 here. Not unit scale at all! Also, sigma_true = 15, but this will be less of an issue because the exponential prior is much weaker than the normal in the tail.

So, yeah, this is a terrible prior. But, y’know, that happens. Not on purpose (usually), but we’re all busy and sometimes we apply models that don’t make sense or don’t fit the data, or both.

So let’s see what happens with this strong prior.

Actually, we kind of know what to expect. The likelihood is centered at (a, b, c) = (19.0, 0.85, 15.5), and the prior mode is at (0, 0, 0), so we expect the parameter estimates all to be pulled toward zero. Especially the intercept, a, since the prior for a is much stronger than the likelihood. And it’s a linear normal model so the posterior should be pulled smoothly toward the prior, not the sort of funny stuff that would happen with a Cauchy prior, say.

But let’s run it and see what happens. Here goes:

Let’s look at each parameter:
– The estimate for “a” has gone from 19.0 to 1.7: So, yeah, the prior was strong, it pulled the estimate almost all the way to the prior mode of 0.
– The estimate for “b” has gone from 0.85 to 1.4: Wha….?? It got pulled away from the prior!
– The estimate for “sigma” has gone from 15.5 to 16.5: Again, it got pulled in the wrong direction!

What’s going on here?

The key to understanding this problem is to realize that, although the three parameters a, b, and sigma are independent in the prior distribution here, they’re strongly dependent in the likelihood.

So let’s talk through what’s happening.

First, the prior for “a” is very strong, so the intercept is pulled almost all the way to 0.

Second, look at the data. The predictor x ranges from 0 to 50, and the true regression line is y = 20 + 0.8x, so if you grab the line at x=0 and pull it down from y=20 to y=0, while still trying to go through the data, you’ll increase the slope. Just draw the scatterplot and you’ll see what I mean.

So the strong prior on “a” causes the estimated slope to go up. Also there’s a prior on “b” that pulls the slope toward 0, but it’s a weak prior relative to the likelihood (recall that the likelihood-based estimate of b had a standard error of 0.1), so it doesn’t have much effect. The net effect of the joint prior is to increase the slope of the fitted line, thus pull the estimate of b away from 0 in this case.

Finally, the new line doesn’t fit the data so well–that’s what happens when you move away from the maximum likelihood estimate, the fit gets worse!–and so the estimate of sigma goes up. Again, there is a prior on sigma that pulls its estimate toward zero, but it’s not as strong as the signal from the data telling us that the fit is getting worse.

We can see this even more clearly by removing the priors on b and sigma, so that all we have is the prior on the intercept, a:

data {
  int N;
  real a_true, b_true, sigma_true;
}
transformed data {
  vector[N] x;
  vector[N] y;
   for (n in 1:N) {
    x[n] = uniform_rng(0, 50);
    y[n] = normal_rng(a_true + b_true * x[n], sigma_true);
  }
}
parameters {
  real a, b;
  real<lower=0> sigma;
}
model {
  a ~ normal(0, 1);
 // b ~ normal(0, 1);
 // sigma ~ exponential(1);
  for (n in 1:N) {
    y[n] ~ normal(a + b * x[n], sigma);
  }
}

And here’s what happens:

So, yeah, the inference for “b” is about the same, “sigma” gets pulled up even more, and “a” gets pulled even more toward zero. That last bit makes sense too: in the model with informative priors on all three parameters, the priors on b and sigma have the effect of somewhat decreasing the amount that the intercept can be pulled down to zero.

Lessons from this example

First, put your parameters on unit scale so that you won’t accidentally use priors that are so contrary to the data. At this point you might say that you don’t know anything about your parameters so you can’t put them on unit scale. But I disagree! In every application I’ve seen, we have some sense of the scale of the effects and adjustments in the model. If you don’t have this information–if you’re flying blind, as happens when you’re developing default software–then there should be a way to scale the parameters based on the data. That’s how we do things in rstanarm, as discussed in Section 9.5 of Regression and Other Stories.

Second, plot the data and fitted model. Check the fit of the model to the data! You’re under no obligation to stick with a model that clearly doesn’t fit.

Third, experiment! As shown above, you can learn a lot by perturbing the model and re-fitting. No need to just stare at your code and your computer output to try to figure out what is happening. You can and should use experimentation as a regular tool.

A Stan transpiler in Julia!

Nikolas Siccha writes:

I got inspired by Bob’s latest blog post to bring your attention to this code generation tool. It’s currently supremely buggy and only really usable by myself – but it may still be interesting for you to see, as it IMO solves many of Stan’s “problems.”

“Supremely buggy and only really usable by myself” . . . that describes lots of the software that I write!

Follow the link and here’s what you see:

StanBlocks.jl (Stan backend)

Brings Julia syntax to Stan models by implementing a (limited) Julia to Stan transpilation with many caveats. See test/slic.jl for implementations of a few simple posteriordb models and see src/slic_stan/builtin.jlfor a list of built-in functions and examples of user defined functions.

Current features include

  • activity analysis (automatically determines what is data, transformed_data, parameters, transformed parameters, model, or generated quantities),
  • automatically inferred types, shapes and constraints – including for user defined functions (including the function arguments, function body, and function return type),
  • automatic posterior pointwise likelihood and predictive generation,
  • (variadic) user defined functions,
  • higher order (user defined) functions (such as map, broadcasted, sum and more),
  • sub models,
  • post-hoc model adjustment,
  • named tuples,
  • (approximate) automatic code formatting à la Blue,
  • and more.

Upcoming features include, in order of priority and estimated arrival,

  • easy runtime assertions (like Julia’s @assert) – and support for other macros,
  • model docstrings,
  • custom types (for method dispatch – this would help with more “Julia-style” broadcasting, e.g. via Ref),
  • closures via Julia’s Do-Block Syntax (to make within chain parallelization via reduce_sum less painful),
  • lower transpilation runtimes (currently, transpilation can sometimes take longer than compilation – there is currently at least one algorithmic inefficiency on top of the systemic implementation inefficiency),
  • a much better user experience,
  • more and better tests,
  • keyword arguments,
  • default arguments,
  • inlining (to reduce potential runtime overhead),
  • easier custom parameter transformations (going from sampler parametrization to user parametrization – aka as constraining),
  • array comprehensions,
  • a more complete (and more correct) coverage of built-in Stan functions,
  • better name resolution (currently user defined functions or sub models have to be defined in Main),
  • functions that mutate their arguments (solved via inlining),
  • and more.

Almost anything that’s possible in Julia should be possible to be transpiled to Stan. Of course, unless Stan is much faster than Julia (+Mooncake or Enzyme) for the model in question, just sticking to Julia comes with many advantages.

Features which I am on the fence about, but currently not planning to implement:

  • a Julia backend,
  • target += statements,
  • top level control flow,
  • top level mutability,
  • getting rid of superfluous parentheses.

Features which are NOT planned:

  • (automatically) transpiling Julia functions which have not been defined via @deffun.

The earn_height.stan model below becomes

using StanBlocks
import PosteriorDB, StanLogDensityProblems, JSON

# Get data from PosteriorDB
pdb = PosteriorDB.database()
post = PosteriorDB.posterior(pdb, "earnings-earn_height")
(;earn, height) = (;Dict([Symbol(k)=>v for (k, v) in pairs(PosteriorDB.load(PosteriorDB.dataset(post)))])...)

# Model definition
earn_height_model = @slic begin 
    beta ~ flat(;n=2)
    sigma ~ flat(;lower=0.)
    earn ~ normal(beta[1]+beta[2]*to_vector(height), sigma)
end
# Not compiled yet
earn_height_posterior = earn_height_model(; earn, height)
# Prints the Stan model code
println(stan_code(earn_height_posterior))
# Compiled (requires StanLogDensityProblems and JSON)
earn_height_problem = stan_instantiate(earn_height_posterior)

I don’t quite get that code at the end, but then again I don’t speak Julia.

One reason I think this is cool is that Julia and Stan started at the same time! Both projects were originally supported by a Department of Energy grant that funded Alan Edelman and me to hire postdocs and programmers. Alan’s group built Julia; we built Stan. Thanks, Bob, Matt, Daniel, and everybody else who did this!

Stepping back, it’s good to be able to go between languages and not be stuck in just one framework. We wrote Stan for two reasons:

1. To be able to easily and flexibly express Bayesian models and fit them to data.

2. To be able to perform statistical workflow, which includes fitting multiple models, postprocessing inference, plotting data and fitted models, etc.

For step 2, it was absolutely necessary for Stan to link smoothly to general-purpose computing environments such as R and Python, which is why we built rstan and pystan (which have since mostly been replaced by the lighter interfaces cmdstanr and cmdstanpy; thanks, Jonah, Mitzi, and everybody else who did this!). You can also run Stan from Julia. What Niko is doing here is going beyond that in allowing some sort of improved version of Stan that can be written in Julia, which seems like it could be really useful.

Beyond all this, as a scholar I’ve always tried to avoid any territorial attitude. I’ve just seen this too often, with researchers who have some method or another and are out there dissing the competition. OK, don’t get me wrong here, I’m happy to diss, when it’s appropriate, but not just cos it’s competition. Science isn’t a competition; we’re all in this together.

So, yeah, Stan is great. I love Stan, and I use it. I eat my own dogfood. But the purpose of Stan is Bayesian workflow. And if Stan can be helpful to Bayesian workflow in other ways, that’s great.

OK, I reread that classic paper by Paul Meehl, and . . .

. . . it makes a really important point that I hadn’t even noticed.

The article in question is Theory-testing in psychology and physics: A methodological paradox and it’s from 1967.

It’s entirely my fault that I missed the point, as it’s in the very first paragraph of the paper, and Meehl even helpfully puts it in italics:

In the physical sciences, the usual result of an improvement in experimental design, instrumentation, or numerical mass of data, is to increase the difficulty of the “observational hurdle” which the physical theory of interest must successfully surmount; whereas, in psychology and some of the allied behavior sciences, the usual effect of such improvement in experimental precision is to provide an easier hurdle for the theory to surmount.

He continues:

Hence what we would normally think of as improvements in our experimental method tend (when predictions materialize) to yield stronger corroboration of the theory in physics, since to remain unrefuted the theory must have survived a more difficult test; by contrast, such experimental improvement in psychology typically results in a weaker corroboration of the theory, since it has now been required to survive a more lenient test.

This post will proceed as follows. First, I’ll explain Meehl’s point and say why I think it’s important. Second, I’ll discuss how it is that I’ve read this famous paper so many times and never noticed its key message. Third, I’ll consider what we should do in social science, given this new understanding.

1. The message of Meehl’s paper

Here’s the key idea. In physics, the model you’re interested in is the null hypothesis. Get enough data and you can reject it. For a simple example, start with Copernicus’s model of the planets going in circles around the sun. Gather enough data and you can reject that model, replacing it with Kepler’s model of elliptical orbits. Gather more data and you can reject that model–but, hey! you can fix the model by hypothesizing another planet–Uranus. Then Neptune. Gather more data and you can reject the elliptical paths too. Now we have general relativity, and I don’t think it’s been rejected yet. Similarly with models in particle physics, solid state physics, etc. Gather enough data and you’ll reject your model, and that’s where you learn something.

In psychology, it’s the opposite. The model you’re interested in is that two variables are related to each other: do more of X and you get more of Y. The null hypothesis–that X is independent of Y–that’s not very interesting. I mean, sure, it would be interesting if it’s true, but typically it’s not, and you know it’s not. Gather enough data and you can reject the null.

We know that.

But here’s the interesting point made by Meehl in his 1967 paper: the process of hypothesis testing in psychology is the opposite of that in physics. In physics, as you gather more and more data, you put your model more and more to the test, and eventually it breaks down. This is also how I’ve always framed things in Bayesian data analysis: The point of any statistical model is to be there and do its job long enough for it to be replaced. A model is like a car that you drive until it runs out of gas, then you give it some more gas, you fix it when it breaks down, and eventually it’s more effort to fix than to just build or buy a new car. This is the Lakatos philosophy: it’s Lakatos’s version of Popper.

But in psychology, when you gather more data, it’s easier and easier to reject the null, which makes it easier and easier to confirm your favored hypothesis. All you learn by rejecting the null hypothesis is that you now have enough data to estimate a bigger model. That’s not nothing, but it’s not falsification in the Popperian sense, or a motivation for improvement in the Lakatosian sense. A psychology researcher proceeding by successfully rejecting the straw-man null is not working within the falsificationist paradigm.

It’s funny because the math for hypothesis testing in physics is the same as in psychology, but the interpretation is the opposite.

This is a big deal. Meehl wrote it in 1967, and his paper got lots of attention (according to Google, it’s only been cited 1500 times, but that’s a lot for a paper published so long ago; also, papers on philosophy don’t get cited that much, compared to papers on methods), but I don’t think most people got the point.

2. How did I miss the message?

Indeed, until I reread the paper the other day (in preparation for including it the readings for Week 13 of my Rationalizing the World course), I didn’t get it either.

Maybe one reason is that I’m trained in physics and I read Jaynes, so I’d already internalized the use-the-model-you-love-and-put-it-to-the-test-and-when-it-finally-fails-you-can-rejoice-and-think-about-how-to-do-better philosophy (I call it “model checking” rather than “hypothesis testing”). Another reason is that I already knew that Meehl, like me, opposed null hypothesis significance testing (unlike me, he was Saul Bellow’s therapist, but that’s another story), and so every time I’d read that paper, I’d just kinda skimmed it and seen that he was attacking the use of hypothesis tests in psychology research.

I’d understood that Meehl was criticizing null hypothesis significance testing as being confirmationist rather than falsificationist, but what I hadn’t caught was his comparison with physics.

Meehl’s point is not just the commonplace that social sciences have physics envy, that they’re unrealistically looking for law-like relationships that you can’t hope to find when studying human behavior or society; rather, he’s saying that the entire endeavor of data-based science changes if you move from precise, physics-type models to more vague, directional, social-science hypotheses.

3. What to do?

What’s the answer here? The answer is not to tell psychologists (or political scientists, or economists, or sociologists) to form strong, physics-like models and test them. Whatever strong, physics-like models we create, from the median voter theorem to prospect theory to social network models, are gross oversimplifications: they’re guides to thinking that we don’t expect to fit reality.

Rather, I think we need to act like statisticians (ok, maybe you could see that coming!) and consider model building to be an ongoing process. We don’t need to waste our time rejecting straw-man null hypotheses, and we certainly shouldn’t be comparing models based on their p-values or other measures of distance of data from uninteresting nulls; rather, we should build the best models we can, knowing that they’re imperfect, and gathering more data until we can do better.

This is not a falsificationist paradigm, nor is it confirmationist. It’s more like “normal science” in the Kuhnian sense. Or, to put it another way, we will be doing small falsifications every step of the way, occasionally slipping into a new paradigm when the old models get too damn clunky. It’s the fractal nature of scientific revolutions.

And that’s the final reason I didn’t catch Meehl’s point on my first (or second, or third) reading of his article. He identifies the problem without offering much of a solution. That’s fine–identifying the problem is the first step. I’m glad I read it again, this time actually reading that first paragraph carefully, as it deserved to be read.

Post-doc positions in Finland

This post is by Aki.

ELLIS Institute Finland is a newly established world-class research hub in AI and machine learning – and we are growing! The positions are within in one of the member universities (including Aalto University where I am).

We are now seeking postdoctoral researchers to join ELLIS Institute Finland and its wider research community. We welcome applications across all areas of machine learning, artificial intelligence, and related fields like statistics. Your research can be theoretical, applied, or span both. There are few PIs including me working also on Bayesian inference, modeling and workflow, and thus this call is great also for someone who likes these topics.

See more at the postdoc call web page.

A decision theorist walks into a seminar

This is Jessica. Recently overheard (more or less):

SPEAKER: We study decision making by LLMs, giving them a series of medical decision tasks. Our first step is to infer, from their reported beliefs and decisions, the utility function under revealed preference assump—

AUDIENCE: Beliefs!? Why must you use the word beliefs?

SPEAKER [caught off guard]: Umm… because we are studying how the models make decisions, and beliefs help us infer the scoring rule corresponding to what they give us.

AUDIENCE: But it’s not clear language models have beliefs like people do.

SPEAKER: Ok. I get it. But, it’s also not clear what people’s beliefs are exactly or that they’re consistent. There’s a large body of research on how the beliefs you get are affected by the method you use. So there’s no reason to think that human beliefs are stable, and what people report as their beliefs does not necessarily explain their decisions by common models.

AUDIENCE: But people can believe things. Models are just patterns of activation.

SPEAKER: Ok. Well, perhaps we can just call them subjective distributions.

AUDIENCE: But subjective implies a person, experiencing something. We can’t establish that they have subjective experience.

INFORMED AUDIENCE MEMBER: Wait a second, when you say beliefs do you just mean a probability distribution? Like in decision theory?

SPEAKER: Yes. We can just call it a probability distribution to avoid the term beliefs.

STUBBORN AUDIENCE MEMBER: I don’t know. They may not act like real probabilities.

SPEAKER: But often the probabilities people give us don’t conform to probability axioms either. But ok, fine. How about we say belief-like representation?

AUDIENCE: What is that supposed to mean?

SPEAKER: Well, we could look for the same kinds of properties we hope to see in human beliefs, even if we can’t elicit them perfectly. Like, we assume that beliefs should have some correspondence to behavior, so we could look for that. Which is part of what we do in the work I’m going to talk–

AUDIENCE: Now you’ve really lost us.

SPEAKER: Ok. How about “risk representations” then?

AUDIENCE: Risk! Models don’t feel things!

SPEAKER: Ok. Pseudo-probability representations?

STUBBORN AUDIENCE MEMBER: I don’t know how I feel about the word representation here. Does representation imply intent? LLMs don’t have intentions.

SPEAKER: Ok. Vectors. Pseudo-probability vectors. Anyway, we were interested in seeing what happens when you apply revealed preference assumptions to LLMs, to infer the scoring rule they are using…

AUDIENCE: Scoring rule! They can’t respond to incentives!

SPEAKER: They are trained with scoring rules, like cross entropy loss. But then fine-tuning like SFT and RLHF induce something different. Plus when we prompt them with a specific decision context, we will induce a different posterior distribution. So it makes sense to–

MODERATOR [holding up their hand]: Five minutes left.

INFORMED AUDIENCE MEMBER: But why not prompt them with a proper scoring rule?

SPEAKER: Well, it’s not clear that they would react to a scoring rule we give in the prompt, because they don’t experience rewards like a person.

AUDIENCE: Exactly!

SPEAKER: Right. So the only incentives available are epistemic.

AUDIENCE: Epistemic? That assumes a knower.

SPEAKER: Ok. We are interested in the induced loss-minimization-like dynamics…

AUDIENCE: Dynamics? These models can’t be assumed to represent time.

SPEAKER: That’s beside the point, but ok. Static mapping from tokens to tokens?

AUDIENCE: Mapping? That assumes a function.

SPEAKER: Yes. I am, in fact, assuming a function.

INFORMED AUDIENCE MEMBER: Could we just stipulate the model has internal states and move on?

STUBBORN AUDIENCE MEMBER: Internal? But that assumes an inside.

MODERATOR: Two minutes left.

SPEAKER: Okay. Just states then.

AUDIENCE: But these models have no explicit representation of the state!

SPEAKER: Ok. I’ll wrap this up. Under revealed preferences, we find the utility function puts essentially all the mass on semantic hygiene and—

STUBBORN AUDIENCE MEMBER: That seems like a leap.

SPEAKER: It’s literally been revealed.

AUDIENCE: Revealed to whom?

MODERATOR [standing up and starting to clap]: Let’s thank our speaker…

Coming soon to a computer science / behavioral econ / statistics / cogsci seminar near you!

Some questions and ideas about initialization for ADVI

Matthias Müller-Schrader writes:

I’ve recently read your ADVI paper in JMLR with great enjoyment.

However, I stumbled over one important detail:

In case of the full-rank Gaussian, the Cholesky factorization ensures that Sigma is positive-semi-definite for an unconstrained lower-triangular matrix L. But this doesn’t guarantee positive-definiteness as one of the diagonal entries (=eigenvalues) of L could be zero, rendering L and Sigma being not invertible.
As the inverse of L is needed to compute the gradients (eq. 9), there are some constraints on the variational parameters (diagonal entries of L have to be non-zero) and the optimization might suffer some problems in the neighborhood of these points.

Could that be a problem or did you even observe problems related to that? Or is there reason to believe that the optimization will never reach this areas of parameter space if initialized properly?

Alp Kucukelbir, the first author on the ADVI paper (in statistics, the first author is typically the person who writes the paper; we don’t assume a default alphabetical order) replied:

Thank you for your email, which I also read with great enjoyment.

Implementers of statistical algorithms often follow best practices, such as adding small constants to avoid situations like what you describe. That said, your intuition around the importance of initialization is key — there has been considerable subsequent study of this topic. I suggest the following two manuscripts as follow ups:

https://www.jmlr.org/papers/volume23/21-0889/21-0889.pdf
https://studenttheses.uu.nl/bitstream/handle/20.500.12932/47140/MSc-Thesis-Gertjan-Brouwer-9386386.pdf

To which Matthias responded:

Thank you for the follow ups – I’ll have a look at them.

Could the problem be also avoided by reparametrizing the diagonal entries/eigenvalues of L as \omega_i = log(\sigma_i) (as done in the mean-field approximation/corresponding to the Log-Cholesky parametrization in Pinhero & Bates 1995) and leaving the off-diagonal entries unconstrained?

The new expression for the gradient should be straightforward to compute. This would give an unconstrained (and even unique) parametrization of L which could have two advantages: (1) Avoiding the ambiguity could increase stability [situations where the optimization jumps between e.g. + and – the diagonal entry/rows of L are impossible], (2) It would be very hard for the optimization algorithm to enter these problematic areas of parameter space because we shift them to a neighborhood of -infinity. Could that be favorable to adding the small constants, because while they avoid dividing by zero, they could still have some side effects?

I haven’t thought about initialization for ADVI in awhile, but from when I was thinking about it, several years ago, I remember that initial values can be important, especially when parameters are far from unit scale (that is, when the mass of the target distribution is orders of magnitude away from 1).

FDA guidance on Bayesian clinical trials

This is Witold.

The Food & Drug Administration just released a guidance for industry document on “Use of Bayesian Methodology in Clinical Trials of Drug and Biological Products”:

This draft guidance provides guidance to sponsors and applicants submitting investigational new drug applications (INDs), new drug applications (NDAs), biologics licensing applications (BLAs), or supplemental applications on the appropriate use of Bayesian methods in clinical trials. Bayesian methods can be used in various ways in clinical trials. For example, Bayesian calculations can be used to govern the timing and adaptation rules for an interim analysis in an adaptive design, to inform design elements (e.g., dose selection) for subsequent clinical trials, or to support primary inference in a trial. The primary focus of this guidance is on the use of Bayesian methods to support primary inference in clinical trials intended to support the effectiveness and safety of drugs.

Find it here. It’s not a very long read, about 20 pages of pretty accessible text.

I saw several people on Twitter talking it up, with someone claiming that “FDA is Bayesian now!”. Well, apparently that level of analysis is the entry bar for punditry, so that instantly made me feel qualified.

More seriously though, I bet some of the readers will have interesting takes on this, so I thought it’s good to post it and have a discussion in comments. From my side, I will try to give a short understanding of what such a document is and a few impressions.


First of all, what is a guidance document? The FDA issues and updates dozens of such documents every year. First time you encounter one, it is a bit entertaining, because it opens up with a Big Disclaimer stating not only that this sets out FDA’s “thinking” and is not binding, but even all the way down to explaining the meaning of word “should”. Why? Well, as a gov’t agency the FDA sensibly doesn’t want to give an impression of creating a law. More broadly, however, it wants to keep their options open in what they approve and what they don’t.

But then why issue guidance at all? In some sense it is pharma companies that want to have their hands tied. Drug developers are very risk averse—and for a good reason. Given the scale of investment involved in clinical trials, high uncertainty, and timelines that can stretch into decades, producers just crave predictability. So instead of taking time to interact with the FDA to vet every trial decision, it’s good to have a set of rules.

By the way, each FDA division can have its own guidance. This new one deals with drugs and vaccines. FDA released a guidance for Bayesian stats in medical device clinical trials back in 2010. This makes sense, these trials are quite different from drug or vaccine trials and people have used Bayesian techniques there for a long time, or so I’m told—I have not read that 2010 guidance (although I can report that the actual header for the doc says “baysian statistics”, sic).

Is this related to the current US gov’t and recent changes at the FDA? That’s very unlikely. (Sorry to disappoint another Twitter commenter who concluded that “Trump admin is Bayesian”.) When I blogged about this three years ago, the guidance was already scheduled to come out in 2025. Documents like this do take a long while to create.


Onto the document. As I said, I will just share a few impressions and hope that others will have more interesting comments. (Or I may also just write a second blog post on this.) Here is what jumps out scrolling through the doc:

(1) There are some basic definitions to start with, but I don’t think this matters much. It’s interesting, however, to see what type of uses the guidance lists in the second section. That probably covers the type of trials that drug and vaccine developers want to run—or that the FDA would like to see more of.

(2) The list of use cases has six categories, five of which are roughly about “borrowing”: across clinical trial phases, across subpopulations of patients, across age groups (especially extrapolating to children), or across diseases. It’s very nice that this general idea is broken down across several practical categories and given actual real-life examples in each. Lastly, there is a slightly different category of a problem, which is dose-finding, especially in cancer drugs, where you try to balance toxicity with drug’s effect.

(3) What about “fancier” adaptive types of trials? For example, trials where you add/remove treatment/dosages arms dynamically and seamlessly move across clinical trial phases. They are already covered elsewhere and the FDA is working on a separate broader guidance on “complex innovative designs”. So I don’t think there is too much about them here, although they are covered in discussion of priors.

(4) Then there are sections on success criteria and operating characteristics, which set out how to design the trials. The first proposed approach to design is… “Calibration to Type I Error Rate”. That does not sound encouraging! Frank Harrel had a great short blog post that gave a practical example of a trial where mixing Bayesian and frequentist reasoning can lead to a mess. So at first glance this is a bit disappointing…

(5) …but right next the document talks about cases where sponsor and the FDA agree to not calibrate to Type I error. There is guidance on doing things more “Bayesianly”: for example, there is even “Success Criteria Based on Benefit-Risk Assessment or Decision-Theoretic Approaches”. “A decision-theoretic approach might include assessment of the potential negative consequences of approving an ineffective drug or of not approving an effective drug.” That’s very nice! However, at the same time it’s also highly generic—the bit I just listed is limited to a single paragraph. It’s hard for me to imagine someone just reading this and confidently concluding that they can build a trial around it.

OK, I am skimming at this point, as I think this is 1,000 words already. This will probably be a follow-up blog.

(6) Then there is a long section on priors. There are many reassuring bits, because examples seem quite specific. There is a discussion of what should be considered in construction of priors. There is a discussion of “dynamic discounting”. Pretty complex and detailed. But then in talking about borrowing, the guidance says: “Areas where informative priors have been most often proposed include pediatrics and rare diseases. Additional areas can be considered on a case-by-case basis, and FDA advises early discussion of such proposals with the Agency.” Again, if this is on “case-by-case” basis, apart from two areas where we already are Bayesian, then a guidance does not seem very helpful.


So… is the FDA Bayesian now? Well, the real question should be, does a guidance document give trial designers enough confidence to run Bayesian clinical trials in situations where there is a rationale to run a Bayesian trial? Time will tell, for now there is probably a great “the guidance is directionally correct, but is it significant?” joke in there somewhere.

Survey Statistics: Margin of Error

What is a poll’s margin of error ? Let’s narrow the discussion (and the margins of error themselves) to MRP with Bayesian inference and simplifying assumptions:

  1. Estimate E(Y) via E(E(Y | X, sample)) with MRP using two steps:
    • MR: Fit a model E(Y | X, theta, sample) to our sample with Bayesian inference to get posterior draws of parameters theta^(s)
    • P: For each theta^(s), average over known population distribution p(X) to get E^(s)(Y)
  2. Use this first flavor of calibration only (no second flavor of calibration, i.e. logit-shifting)
  3. Assume E(Y | X, sample) = E(Y | X), i.e. missing at random, i.e. no coverage or nonresponse bias after adjusting for X
  4. Assume no measurement error in X or Y
  5. Assume our model for E(Y | X) is correct

Next week we will see additional uncertainty because these assumptions don’t hold, see Disentangling Bias and Variance in Election Polls by Shirani-Mehr, Rothschild, Goel, and Gelman.

(The polar bear is back in the Appalachians, where summit views are uncertain.)

Below are some snippets of how our simplified case is discussed in the MRP papers we’ve looked at so far.

Kuriwaki et al. 2024:

Ghitza and Gelman 2020:

…

Kuh et al. 2023:

MRPW draft paper by Andrew Gelman, Yajuan Si, and Brady T. West:

The Mets are hiring

Sam Saskin writes:

I’m reaching out because we are hiring for a couple of jobs on the Mets analytics team and I was wondering if you’d be willing to share the job postings on your blog. The two positions (posting links below) are Senior Data Scientist, which would be a match for anyone looking for a full-time position, and Data Science Intern, which would be a match for current students (either undergraduate or graduate) who would be interested in spending a summer working with our team. I really appreciate the assistance, as we’ve had a lot of luck finding great candidates through visibility on your blog in the past.

Also if you have a 100 mph fastball they might be able to find a place for you somewhere in the organization.

My general advice if you’re stuck on a problem understanding a model you’ve fit to data

Someone wrote in with a complicated question about some model he’d fit, he was trying to test for endogeneity in the residuals, a bunch of things. It was a short email, just two paragraphs long, but with lots of details, and then he asked me a bunch of questions of what to do.

I replied:

Hi, sorry, I don’t know. I will just give you the general advice to write a small computer program to simulate fake data from your model and then you can apply your statistical procedures to your simulated data and repeat the process to understand the statistical properties of your methods. Best of luck.

A few days later he replied:

Many thanks for your advice, it was very helpful.

That’s satisfying. I’m posting this, partly because it’s a pleasant story and partly out of the possibility that others out there with difficult questions will see this helpful (I hope) advice.

What is “workflow” and why is it important?

A few years ago we decided to write a book on Bayesian workflow, and we got ready for it by writing this article, which begins as follows:

The idea was the traditional framing of statistical inference was too narrow, in that it treated the statistical model as given, without capturing the real-world practices of building, evaluating, improving, and understanding models. Methods such as predictive checking, exploratory data analysis, and sensitivity analysis, are important steps in data analysis without being part of inference. We use the term “workflow” to represent our larger process of data analysis. An extended workflow would also include pre-data design of data collection and measurement and after-inference decision making, but in our article and book on Bayesian workflow we focus on modeling existing data.

“Workflow” has different meanings in different contexts. We have been influenced by the ideas about workflow in computing that are in the air, including statistical developments such as the tidyverse which are not particularly Bayesian but have a similar feel of experiential learning. Many recent developments in machine learning have a similar plug-and-play feel: they are easy to use, easy to experiment with, and users have the healthy sense that fitting a model is a way of learning something from the data without representing a commitment to some probability model or set of statistical assumptions.

In our paper we supply some background:

We can also connect to general ideas of building, checking, and expanding statistical models, as expressed by Tukey (1977), Box (1980), and Jaynes (1983). Or, from another direction, we can look up “workflow” on wikipedia, which says:

Workflow is a generic term for orchestrated and repeatable patterns of activity, enabled by the systematic organization of resources into processes that transform materials, provide services, or process information. It can be depicted as a sequence of operations, the work of a person or group, the work of an organization of staff, or one or more simple or complex mechanisms. . . . The modern history of workflows can be traced to Frederick Taylor and Henry Gantt, although the term “workflow” was not in use as such during their lifetimes. One of the earliest instances of the term “work flow” was in a railway engineering journal from 1921.

Here’s the relevant bit from the 1921 citation:

We and other statisticians have used the term “workflow” to encompass the various steps of data processing and analysis that we use to make our work scientifically replicable, both in the direct sense of providing all necessary practical details so that the computations can be reproduced, and in the larger sense of fitting models and applying procedures that are appropriate to the data at hand and to the questions being asked.

All of this is important for (at least) three reasons:

1. Practical workflow includes all sorts of things that aren’t written down, or are scattered across various sources. It’s good to document what we are doing.

2. Once these steps are written in some sort of organized way, this can help future researchers be more systematic in their data analysis. We would not expect every workflow tool to be used in every data analysis; the point is to make these tools more available, through explanations, examples, and software.

3. Future research should be benefit from a clearer exposition of present best practices. Theoretical statistics is the theory of applied statistics, and so it’s good to know what is being done, to expand the boundaries of theoretical investigation, which eventually should result in improved methods.

Also, data analysis workflow is closely related to ideas in computing workflow such as version control, testing, readability, and maintainability of code. Software is written collaboratively and to be used in a variety of contexts by a range of users; similarly, statistical methods build upon multiple contributors and, once released, get used in the wild in various unexpected ways. So there’s a connection between the workflow involved in developing a method or writing software, and the workflow of the later users of the method or software.