References (with code) for Bayesian hierarchical (multilevel) modeling and structural equation modeling

A student writes:

I am new to Bayesian methods. While I am reading your book, I have some questions for you. I am interested in doing Bayesian hierarchical (multi-level) linear regression (e.g., random-intercept model) and Bayesian structural equation modeling (SEM)—for causality. Do you happen to know if I could find some articles, where authors could provide data w/ R and/or BUGS codes that I could replicate them?

My reply: For Bayesian hierarchical (multi-level) linear regression and causal inference, see my book with Jennifer Hill. For Bayesian structural equation modeling, try google and you’ll find some good stuff. Also, I recommend Stan (http://mc-stan.org/) rather than Bugs.

12 thoughts on “References (with code) for Bayesian hierarchical (multilevel) modeling and structural equation modeling

    • For ‘standard’ models, stan works extremely fast compared to other altetnatives.

      However, ive been frustrated recently as for more niche models, say spatial car models, stan is extremely slow

      • The inability of Stan (or HMC, technically) to handle discrete random effects also reduces it’s role as a BUGS alternative. If the rumors of this changing are true, the user base and popularity will certainly increase.

      • Ray:

        The short answer is that Stan is scalable, both as model gets more complex and as datasets become large.

        Anon:

        Please send your example to the Stan users list. Spatial conditional autoregressive models should run fast in Stan. If not, I’d like to see what’s going on.

        Dan:

        For the models discussed by my correspondent above, I don’t think discrete components would make much sense. But, yes, now that Stan has user-defined functions (not yet in the current release, but it’s coming), we’ll soon have more convenient implementations of mixture models.

      • I think that’s not the right advice for a beginner. The Gelman and Hill book and the BUGS book are the best starting point at this point in time, and both use BUGS. Anyone starting out must know BUGS just to be able to follow the introductory texts. Even if a Stan translation of G&H happens, the BUGS book is absolutely phenomenal (for a beginner), and it uses BUGS.

        Having said that, I have finally understood your point that Stan is the way forward for scalable models.

        • Hi Andrew,

          Do you mean the models at this github site below? These models are not always correct. For example, the one below is supposed to be a varying intercepts, varying slopes model. Where is the prior for the correlation? The model documentation claims it is fitting “lmer (y ~ x (1 + x | ethn))”

          [what was meant was: lmer (y ~ x + (1 + x | ethn))]

          whereas I think it is fitting

          lmer (y ~ x + (1 | ethn) + (0+x|ethn))

          or, now that I look at it more closely, perhaps even

          lmer (y ~ 0 + (1 | ethn) + (0+x|ethn))

          If I am wrong about this, I am happy to be corrected. Nevertheless, I would never direct a beginner to these models. This example does not match the lmer model that is provided as a guide. The beginner starting out with such an example is going to get hopelessly confused.

          https://github.com/stan-dev/stan/blob/feature/ARM/src/models/ARM/Ch.13/earnings_vary_si.stan

        • Shravan:

          I have not checked these models and there may well be mistakes. In this particular example, yes it looks like the model is in error. If you notice any mistakes of this sort, please send an email to the Stan users list. Thanks!

        • Hm, maybe I’m going to write these models myself instead of waiting for someone else to do it! :)

          But more to the point, it is not true that the H&M book has been completely translated. It is still the best reference (with The BUGS Book) out there for fitting Bayesian hierarchical models, and at this moment a beginner starting out with these books should know BUGS. That’s all I’m saying.

  1. For a treatment on Bayesian structural equation modeling as well as code for a number of software packages, you might be interested in a recent chapter I co-wrote with Jaehwa Choi:

    Levy, R., & Choi, J. (2013). Bayesian structural equation modeling. In G.R. Hancock and R.O. Mueller (Eds.), Structural equation modeling: A second course (2nd ed., pp. 563-623). Charlotte, NC: Information Age Publishing.

Comments are closed.