<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/the-current-state-of-the-stan-ecosystem-in-r/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://andrewgelman.com/2018/04/24/current-state-stan-ecosystem-r/"> R – Statistical Modeling, Causal Inference, and Social Science</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>This post is by Jonah.</p>
<p>Last week I <a rel="nofollow" href="http://andrewgelman.com/2018/04/16/loo-2-0-loose/" target="_blank">posted</a> here about the release of version 2.0.0 of the <strong>loo</strong> R package, but there have been a few other recent releases and updates worth mentioning. At the end of the post I also include some general thoughts on R package development with Stan and the growing number of Stan users who are releasing their own packages interfacing with <strong>rstan</strong> or one of our other packages.</p>
<p><strong>Interfaces</strong></p>
<p><strong>rstanarm</strong> and <strong>brms: </strong>Version 2.17.4 of <strong>rstanarm</strong> and version 2.2.0 of <strong>brms</strong> were both released to provide compatibility with the new features in <strong>loo</strong> v2.0.0. Two of the new <a rel="nofollow" href="http://mc-stan.org/loo/articles/" target="_blank">vignettes</a> for the <strong>loo</strong> package show how to use it with <strong>rstanarm</strong> models, and we have also just released a draft of a vignette on how to use <strong>loo</strong> with <strong>brms </strong>and <strong>rstan</strong> for many “non-factorizable” models (i.e., observations not conditionally independent). <strong>brms</strong> is also now officially supported by the Stan Development Team (welcome Paul!) and there is a new category for it on the Stan Forums.</p>
<p><strong>rstan:</strong> The next release of the <strong>rstan</strong> package (v2.18), is <em>not</em> out yet (we need to get Stan 2.18 out first), but it will include a <code>loo()</code> method for stanfit objects in order to save users a bit of work. Unfortunately, we can’t save you the trouble of having to compute the point-wise log-likelihood in your Stan program though! There will also be some new functions that make it a bit easier to extract HMC/NUTS diagnostics.</p>
<p><strong>Visualization</strong></p>
<p><strong>bayesplot:</strong> A few weeks ago we released version 1.5.0 of the <strong>bayesplot </strong>package (<a rel="nofollow" href="http://mc-stan.org/bayesplot" target="_blank">mc-stan.org/bayesplot</a>), which also integrates nicely with <strong>loo </strong>2.0.0. In particular, the diagnostic plots using the leave-one-out cross-validated probability integral transform (LOO-PIT) from our paper <em>Visualization in Bayesian Workflow</em> (<a rel="nofollow" href="https://arxiv.org/abs/1709.01449" target="_blank">preprint</a> on arXiv, <a rel="nofollow" href="https://github.com/jgabry/bayes-vis-paper" target="_blank">code</a> on GitHub) are easier to make with the latest <strong>bayesplot</strong> release. Also, TJ Mahr continues to improve the <strong>bayesplot</strong> experience for <strong>ggplot2</strong> users by adding (among other things) more functions that return the data used for plotting in a tidy data frame.</p>
<p><strong>shinystan: </strong>Unfortunately,<strong> </strong>there hasn’t been a <strong>shinystan</strong> release in a while because I’ve been busy with all of these other packages, papers, and various other Stan-related things. We’ll try to get out a release with a few bug fixes soon. (If you’re annoyed by the lack of new <em>features</em> in <strong>shinystan</strong> recently let me know and I will try to convince you to help me solve that problem!)</p>
<p><strong>Other tools</strong></p>
<p><strong>projpred:</strong>Version 0.8.0 of the <strong>projpred</strong> package (I still need to make its website) for projection predictive variable selection for GLMs was also released shortly after the <strong>loo</strong> update in order to take advantage of the improvements to the Pareto smoothed importance sampling algorithm. <strong>projpred</strong> can already be <a rel="nofollow" href="https://cran.r-project.org/web/packages/projpred/vignettes/quickstart.html" target="_blank">used quite easily</a> with <strong>rstanarm</strong> models and we are working on improving its compatibility with other packages for fitting Stan models.</p>
<p><strong>rstantools: </strong>Unrelated to the <strong>loo</strong> update, we also released version 1.5.0 of the <strong>rstantools</strong> package (<a rel="nofollow" href="http://mc-stan.org/rstantools" target="_blank">mc-stan.org/rstantools</a>), which provides functions for setting up R packages interfacing with Stan. The major changes in this release are that <code>usethis::create_package()</code> is now called to set up the package (instead of <code>utils::package.skeleton</code>), fewer manual changes to files are required by users after calling <code>rstan_package_skeleton()</code>, and we have a <a rel="nofollow" href="http://mc-stan.org/rstantools/articles/" target="_blank">new vignette</a> walking through the process of setting up a package (thanks Stefan Siegert!). Work is being done to keep improving this process, so be on the lookout for more updates soonish.</p>
<p><strong>Stan related R packages from other developers</strong></p>
<p>There are now well over fifty packages on CRAN that depend in some way on one of our R packages mentioned above!  You can find most of them by looking at the “Reverse dependencies” section on the <a rel="nofollow" href="https://cran.r-project.org/package=rstan" target="_blank">CRAN page for <strong>rstan</strong></a>, but that doesn’t count the ones that depend on <strong>bayesplot</strong>, <strong>shinystan</strong>, <strong>loo</strong>, etc., but not <strong>rstan</strong>.</p>
<p>Unfortunately, given the growing number of these packages, we haven’t been able to look at each one of them in detail. For obvious reasons we prioritize giving feedback to developers who reach out to us directly to ask for comments and to those developers who make an effort to our <a rel="nofollow" href="http://mc-stan.org/rstantools/articles/developer-guidelines.html" target="_blank">recommendations for developers</a> of R packages interfacing with Stan (included with the <strong>rstantools</strong> package since its initial release in 2016). If you are developing one of these packages and would like feedback please let us know on the <a rel="nofollow" href="http://discourse.mc-stan.org/" target="_blank">Stan Forums</a>. Our time is limited but we really do make a serious effort to answer every single question asked on the forums.</p>
<p>My primary feelings about this trend of developing Stan-based R packages are ones of excitement and gratification. It’s really such an honor to have so many people developing these packages based on all the work we’ve done! There are also a few things I’ve noticed that I hope will change going forward. I’ll wrap up this post by highlighting two of these issues that I hope developers will take seriously:</p>
<p>(1) Unit testing</p>
<p>(2) Naming user-facing functions</p>
<p>The number of these packages that have no unit tests (or very scant testing) is a bit scary. Unit tests won’t catch every possible bug (we have lots of tests for our packages and people still find bugs all the time), but there is really no excuse for not unit testing a package that you want other people to use. If you care enough to do everything required to create your package and get it on CRAN, and if you care about your users, then I think it’s fair to say that you should care enough to write tests for your package. And there’s really no excuse these days with the availability of packages like <a rel="nofollow" href="https://github.com/r-lib/testthat" target="_blank"><strong>testthat</strong></a>to make this process easier than it used to be! Can anyone think of a reasonable excuse for not unit testing a package before releasing it to CRAN and expecting people to use it? (Not a rhetorical question. I really am curious given that it seems to be relatively common or at least not uncommon.) I don’t mean to be too negative here. There are also many packages that seem to have strong testing in place! My motivation for bringing up this issue is that it is in the best interest of our users.</p>
<p>Regarding function naming: this isn’t nearly as big of a deal as unit testing, it’s just something I think developers (including myself) of packages in the Stan R ecosystem can do to make the experience better for our users. <strong>rstanarm</strong> and <strong>brms</strong> both import the generic functions included with <strong>rstantools</strong> in order to be able to define methods with consistent names. For example, whether you fit a model with <strong>rstanarm</strong> or with <strong>brms</strong>, you can call <code>log_lik()</code> on the fitted model object to get the <em>pointwise</em> log-likelihood (it’s true that we still have a bit left to do to get the names across <strong>rstanarm</strong> and <strong>brms</strong> more standardized, but we’re actively working on it). If you are developing a package that fits models using Stan, we hope you will join us in trying to make it as easy as possible for users to navigate the Stan ecosystem in R.</p>
<p>The post <a rel="nofollow" href="http://andrewgelman.com/2018/04/24/current-state-stan-ecosystem-r/" target="_blank">The current state of the Stan ecosystem in R</a> appeared first on <a rel="nofollow" href="http://andrewgelman.com/" target="_blank">Statistical Modeling, Causal Inference, and Social Science</a>.</p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://andrewgelman.com/2018/04/24/current-state-stan-ecosystem-r/"> R – Statistical Modeling, Causal Inference, and Social Science</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/opASmmHXYOU" height="1"></a></div>