[Case-study preview] Speeding up Stan by reducing redundant computation

@mike-lawrence The trick here is that there are multiple observations with sort of the same right hand side, right?

This sounds similar to the thing where you replace a bunch of bernoullis that all have the same right hand side with a binomial.

I did some thinking about a similar thing at some point. I decided for intercept only models (or at least for the intercept part of a hierarchical regression) we could get somewhere, but I never wrestled it into a form where I could write a clean function we might put in Math (Group orderings in regression).

@andrewgelman is often forwarding e-mails from people who have large hierarchical regressions and they’re happy with the regression but it’s just too slow cause they have an absurd number of data points.

Since you already started a case study, do you think you could write and show examples of these other things to? Like expand the contents to “Last Mile Optimizations for Hierarchical Regressions” maybe? The idea being, after everything else is done, these are things you can do to make your model faster. They don’t work for everyone, so it’s hard to make them general, but there is a checklist of things people can look through.

In that theme, I think it would make sense to add a section on using the GLMs (https://mc-stan.org/docs/2_22/functions-reference/bernoulli-logit-glm.html) and reduce_sum. So that’s 5 things, which is a pretty sizeable case study.

And this is purposefully separate from the model approximation things you might try to do (or switching to lme4 that ends up happening a lot).

2 Likes