Tuesday, July 4, 2017

DBDA2E Scripts in Stan

Many more scripts from DBDA2E have been re-written for Stan, by Prof. Joseph Houpt at Wright State University. Joe has posted his scripts at GitHub: https://github.com/jhoupt/DBDA2Estan

To run Joe's Stan scripts you will need the usual other supporting scripts and data files from DBDA2E, available at the book's web site (see Step 5 of Software Installation). Just copy Joe's scripts into your folder of scripts from the book.

Joe's GitHub site includes only the new scripts he modified from the book's JAGS scripts. The book had several Stan scripts already, and Joe has not re-written those. The book describes Stan in Chapter 14, and has several Stan scripts accompanying applications in later chapters. (Regarding discrete parameters: The book points out that Stan does not directly implement discrete parameters like JAGS, but the book does not discuss how to marginalize over discrete parameters instead. Some of Joe's scripts implement marginalization over discrete parameters.)

Big thanks to Joe Houpt for writing these scripts and making them available!

Notes regarding the figure at the top of this post:
1. Yes, the "<-" operator is deprecated in Stan, and I avoid using it in R, but it still looks like an arrow, and programmers who are familiar with R and JAGS will recognize it.
2. The Stan icon comes from the Stan web page. If the Stan folks don't like my use of the icon here, please contact me and I'll remove it or modify it as required.

Reminders of some recent posts:


  1. Funny you should ask! We just received a registered trademark for Stan and there are now some usage guidelines posted. We're basically following what Apache does with their trademarks.

    Short answer is that you're OK with non-commercial references of this kind.

    And thanks for the post. I just noted it in the weekly Stan roundup on Gelman's blog.

    1. I have updated the image so that the Stan icon now has the (R) mark. And thanks for putting the link on your Stan roundup.

  2. Interesting, why are you not using `<-` anymore in R? It is very powerful assignment operator to distinguish scope. See here

    1. I've never like using "<-" in R because I learned other programming languages before learning R, and those other languages used "=" for assignment. And I've never wanted to do nested assignments. But if you want/need to, it's nice to have that facility in R --- go for it. Note that the post alludes to Stan not using "<-", presumably because Stan is written in C++.

  3. Thanks for the pointer, and thanks to Joe.