Skip to content
Archive of posts filed under the Stan category.

“Model takes many hours to fit and chains don’t converge”: What to do? My advice on first steps.

The above question came up on the Stan forums, and I replied: Hi, just to give some generic advice here, I suggest simulating fake data from your model and then fitting the model and seeing if you can recover the parameters. Since it’s taking a long time to run, I suggest just running your 4 […]

Stan’s Within-Chain Parallelization now available with brms

The just released R package brms version 2.14.0 supports within-chain parallelization of Stan. This new functionality is based on the recently introduced reduce_sum function in Stan, which allows to evaluate sums over (conditionally) independent log-likelihood terms in parallel, using multiple CPU cores at the same time via threading. The idea of reduce_sum is to exploit […]

Stan receives its second Nobel prize.

Aki writes: Nobel prize and other science prices are problematic and this is not endorsement of such prices, but this might be useful for someone who needs to tell (hype) about the impact of Stan (or just as another funny fact about Stan). Previously Stan was used in the the LIGO gravitational wave research awarded […]

They’re looking for Stan and R programmers, and they’re willing to pay.

Tom Vladeck writes: I am one half of a company building a media mix model, primarily for online e-commerce brands. Our modeling is done in Stan, and we are looking to hire part time developers (paid, of course, at a real rate) to build and maintain our Stan models and R code. They can be […]

Postdoc in Bayesian spatiotemporal modeling at Imperial College London!

Seth Flaxman writes: We are hiring a postdoctoral research associate with a background in statistics or computer science to join a vibrant team at the cutting edge of the emerging field of spatiotemporal statistical machine learning (ST-SML). ST-SML draws in equal parts on Bayesian spatiotemporal statistics, scalable kernel methods and Gaussian processes, and recent deep […]

Coronavirus disparities in Palestine and in Michigan

I wanted to share two articles that were sent to me recently, one focusing on data collection and one focusing on data analysis. On the International Statistical Institute blog, Ola Awad writes: The Palestinian economy is micro — with the majority of establishments employing less than 10 workers, and the informal sector making up about […]

Why we kept the trig in golf: Mathematical simplicity is not always the same as conceptual simplicity

Someone read the golf example and asked: You define the threshold angle as arcsin((R – r)/x), but shouldn’t it be arctan((R – r)/x) instead? Is it just that it does not matter with these small angles, where sine and tangent are about the same, or am I missing something? My reply: This sin vs tan […]

From monthly return rate to importance sampling to path sampling to the second law of thermodynamics to metastable sampling in Stan

(This post is by Yuling, not Andrew, except many ideas are originated from Andrew.) This post is intended to advertise our new preprint Adaptive Path Sampling in Metastable Posterior Distributions  by Collin, Aki, Andrew and me, where we developed an automated implementation of path sampling and adaptive continuous tempering. But I have been recently reading a writing book […]

Parallel in Stan

by Andrew Gelman and Bob Carpenter We’ve been talking about some of the many many ways that parallel computing is, or could be used, in Stan. Here are a few: – Multiple chains (Stan runs 4 or 8 on my laptop automatically) – Hessians scale linearly in computation with dimension and are super useful. And […]

Post-stratified longitudinal item response model for trust in state institutions in Europe

This is a guest post by Marta Kołczyńska: Paul, Lauren, Aki, and I (Marta) wrote a preprint where we estimate trends in political trust in European countries between 1989 and 2019 based on cross-national survey data. This paper started from the following question: How to estimate country-year levels of political trust with data from surveys […]

Bayesian Workflow (my talk this Wed at Criteo)

Wed 26 Aug 5pm Paris time (11am NY time): The workflow of applied Bayesian statistics includes not just inference but also model building, model checking, confidence-building using fake data, troubleshooting problems with computation, model understanding, and model comparison. We move toward codifying these steps in the realistic scenario in which we are fitting many models […]

Cmdstan 2.24.1 is released!

Rok writes: We are very happy to announce that the next release of Cmdstan (2.24.1) is now available on Github. You can find it here: 2 New features: A new ODE interface Functions for hidden Markov models with a discrete latent variable Elementwise pow operator and matrix power function Newton solver Support for the […]

“I just wanted to say that for the first time in three (4!?) years of efforts, I have a way to estimate my model. . . .”

After attending a Stan workshop given by Charles Margossian at McGill University, Chris Barrington-Leigh wrote: I just wanted to say that for the first time in three (4!?) years of efforts, I have a way to estimate my model. Your workshop helped me and pushed me to be persistent enough to code up my model. […]

epidemia: An R package for Bayesian epidemiological modeling

Jamie Scott writes: I am a PhD candidate at Imperial College, and have been working with colleagues here to write an R package for fitting Bayesian epidemiological models using Stan. We thought this might interest readers of your blog, as it is based on work previously featured there. The package is similar in spirit to […]

More on absolute error vs. relative error in Monte Carlo methods

This came up again in a discussion from someone asking if we can use Stan to evaluate arbitrary integrals. The integral I was given was the following: where the -ball is assumed to be in dimensions so that . (MC)MC approach The textbook Monte Carlo approach (Markov chain or plain old) to evaluating such an […]

StanCon 2020 is on Thursday!

For all that registered for the conference, THANK YOU! We, the organizers, are truly moved by how global and inclusive the community has become. We are currently at 230 registrants from 33 countries. And 25 scholarships were provided to people in 12 countries. Please join us. Registration is $50. We have scholarships still available (more […]

StanCon 2020 program is now online!

This year’s Stan Conference is on August 13, 2020 (next Thursday)! The program has been finalized and is online. So far, we’re at 89 registrants spanning across 17 countries! Registration is $50, which includes swag. There are scholarships available for those that need financial support. If you’re a Stan developer, there’s a discount (see the […]

The typical set and its relevance to Bayesian computation

[Note: The technical discussion w.r.t. Stan is continuing on the Stan forums.] tl;dr The typical set (at some level of coverage) is the set of parameter values for which the log density (the target function) is close to its expected value. As has been much discussed, this is not the same as the posterior mode. […]

StanCon 2020 registration is live!

Dear Stan Community,  The StanCon Organizing Committee is glad to communicate the registration for the virtual StanCon 2020 is now live. Please visit the registration page (see: to purchase your tickets.  The conference will be a 24-hours event with three main sessions spanning across different time zones (British Summer Time, Eastern Time and Pacific […]

Regression and Other Stories is available!

This will be, without a doubt, the most fun you’ll have ever had reading a statistics book. Also I think you’ll learn a few things reading it. I know that we learned a lot writing it. Regression and Other Stories started out as the first half of Data Analysis Using Regression and Multilevel/Hierarchical Models, but […]