Updating Stan from R

Despite using Stan for a few years, I’ve never actually had to update Stan. I’ve always had a new computer or some other strange reason to need a full reinstall of R, Rcpp, etc. I now want to identify the minimal process for getting the latest version of Stan.

I tried updating using update.packages for both StanHeaders and rstan. Then I tried to do a clean uninstall + reinstall using remove.packages and following the full set of installation instructions again. However, rstan::stan_version() still gives me 2.17.0 when I think it should be 2.17.2 based on the version number for StanHeaders given on CRAN.

For an rstan user, what are the best practices for updating Stan from R and/or Rstudio? Where should I look for version numbers to check if I am up to date?

You want to start with a clean R session that does not autoload any old stanfit objects. Then do remove.packages("rstan"). Then verify that rstan is really gone via

system.file("libs", package = "rstan")

If that returns something other than "", then you have to delete the rstan directory manually.

Finally, do `install.packages(“rstan”). But all this is usually only necessary for Windows.

1 Like

Stan_version gives the version of Stan (not any R packages)

As noted, rstan::stan_version() retrieves the version of the Stan library that rstan installed, which is indeed currently 2.17.0. I believe the next version of rstan will be coming soon, which will bring Stan version 2.17.2.

stan_version() refers to the upstream, so it will keep saying 2.17.0 until it says 2.18.0. The more relevant function is packageVersion("rstan").

Okay, now I have more questions. My understanding was that the rstan version was distinct from the version of Stan as a language, even though the two are often close together and have the same major/minor version numbering. Right now, rstan on CRAN is on 2.17.3 and the language of Stan itself has only released 2.17.2.

My main reason for wanting to update was to make sure I did not have the performance slowdown from 2.17.0. I am about to start a big simulation study and would obviously prefer an easy speed boost. What’s the right way to know that the Stan language versions on my machine and server are 2.17.1+? Is it enough to know the version of rstan that’s loaded, or is there more to it?

It is fine. The packageVersion("rstan") should always greater than packageVersion("StanHeaders") so that the functions in rstan can throw errors when someone upgrades their StanHeaders without upgrading their rstan. The slowdown was fixed with 2.17.1.