Description

useR!2017: How to Use (R)Stan to Estimate Models in...

Keywords: Bayesian, developeRsWebpages: rstan, rstanarm, rstantools, StanHeaders, bayesplot, shinyStan, loo, home pageThe rstan package provides an interface from R to the Stan libraries, which makes it possible to access Stan's advanced algorithms to draw from any posterior distribution whose density function is differentiable with respect to the unknown parameters. The rstan package is ranked in the \(99\)-th percentile overall on Depsy due to its number of downloads, citations, and use in other projects. This talk is a follow-up to the very successful Stan workshop at useR2016 and will be more focused on how maintainers of other R packages can easily use Stan's algorithms to estimate the statistical models that their packages provide. These mechanisms were developed to support the rstanarm package for estimating regression models with Stan and have since been used by over twenty R packages, but they are perhaps not widely known and difficult to accomplish manually. Fortunately, the rstan_package.skeleton function in the rstantools package can be used to automate most of the process, so the package maintainer only needs to write the log-posterior density (up to a constant) in the Stan language and provide an R wrapper to call the pre-compiled C++ representation of the model. Methods for the resulting R object can be defined that allow the user to analyze the results using post-estimation packages such as bayesplot, ShinyStan, and loo.References Carpenter, Bob, Andrew Gelman, Matthew Hoffman, Daniel Lee, Ben Goodrich, Michael Betancourt, Marcus Brubaker, Jiqiang Guo, Peter Li, and Allen Riddell. 2017. "Stan: A Probabilistic Programming Language." Journal of Statistical Software 76 (1): 1–32. doi:10.18637/jss.v076.i01.