3 ms·
Stan is a fantastic language/library/tool. (Disclosure, I've taken 2 classes with Andrew Gelman[1]. For those who haven't used it, the typical usage is to use
by chmullig 11y ago
Stan is a fantastic language/library/tool. (Disclosure, I've taken 2 classes with Andrew Gelman[1].
For those who haven't used it, the typical usage is to use Stan in combination with other languages (most commonly R). In the Stan language you define a model, specifying the data you'll get, potentially transformations to that data, then a set of parameters you want to fit, then finally a model saying how those parameters interact with each other and the data. You can also define priors for parameters. Then typically you save that model, and using R pass in the variables to a Stan call. The resulting fit object is returned to your original environment automatically.
It actually fits the work style reasonably well. All data munging happens as before, but instead of having some complicated model expression in, say, a glm() call, you have it in Stan language.
If you're interested in this, Gelman has two great books. Gelman & Hill's Hierarchical Models[2] which is applied and geared towards social science researchers, and Bayesian Data Analysis[3].
[1] http://andrewgelman.com/ http://andrewgelman.com/
[2] http://www.stat.columbia.edu/~gelman/arm/ http://www.stat.columbia.edu/~gelman/arm/
[3] http://www.stat.columbia.edu/~gelman/book/ http://www.stat.columbia.edu/~gelman/book/
- bengHN 11y agoAlso, the rstanarm[1] R package (disclaimer: that I co-wrote) will be released this month, which does not require the user to write any code in the Stan language. Instead, you specify the likelihood of the data (for a few popular regression-type models) using conventional R syntax and utilize Stan's algorithms and optional priors on the parameters to draw from the posterior distribution. In the demos/ directory of [1], we have replicated most of the first half of Gelman & Hill's textbook and are starting on the second half, which heavily utilizes our stan_glmer() function that is compatible with the syntax of the glmer() function in the lme4 R package. [1] https://github.com/stan-dev/rstanarm/ https://github.com/stan-dev/rstanarm/
- chmullig 11y agooh neat!