Rstan and Stan 2.20.0

When will we have Stan 2.20.0 features in Rstan?

Stan 2.20 has been out since July 2019
(Stan 2.20.0 released!)

BR
Anders MM

You can get 2.21 from GitHub. CRAN is another matter.

1 Like

Why is CRAN difficult?
I have been trying to install it from source, however that is not very easy.

  • Why do I have to install V8 ? a full javascript engine seems a little overkill for rstan.
  • I am currently stuck at installing StanHeaders using the install_StanHeaders() function in the “install-github.R” file. I get:

Error: package or namespace load failed for ‘StanHeaders’:
.onAttach failed in attachNamespace() for ‘StanHeaders’, details:
call: system.file(“include”, “stan”, “math”, “prim”, “mat”, “fun”,
error: no file found

Can someone help point me in the right direction, please?

You need to install the StanHeaders 2.21.0-1 (that was subsequently reverted on CRAN) via

install.packages(
"https://cran.r-project.org/src/contrib/Archive/StanHeaders/StanHeaders_2.21.0-1.tar.gz",
repos = NULL)

and then install the rstan that was intended to go with it (but not accepted by CRAN) from GitHub via

remotes::install_github("stan-dev/rstan", ref = "develop", subdir = "rstan/rstan")

And you have to use the v8 package because the stanc3 parser is written in OCaml rather than C++ and it is easier (particularly on Windows) to convert the parser to Javascript than to get CRAN (or anyone who wants to install from source) to put all the OCaml libraries and optional modules onto all of its servers for Linux, Mac, Windows, and Solaris.

2 Likes

Wait, so the stanc3 parser (written in OCaml) also has a javascript version?

Edit:
Oh wow, didn’t see this before: A javascript stanc3

Interesting. So for future rstan releases, the ocaml parser is compiled from OCaml to javascript, and then the js parser is used by rstan to create the C++? That’s crazy, in the best way. I understand the reason (OCaml dependencies are certainly harder to manage than a single js engine), I’m just surprised it works at all.

It works, thanks to @seantalts. I think Google also prefers the javascript version. It is still missing the functionality for expose_stan_functions and quotation marks on included Stan files, so we will have to use both the old stanc and the new stanc if we can ever get a rstan 2.21 onto CRAN without segfaulting many of the other packages due to the TBB / CRTP thing.

2 Likes

is it possible to get this on the wiki on github for rstan? I’m having to update some models from what I’ve written to work with cmdstanr and rstan so decided to get the develop version (some stan functions didn’t exist prior). Anyway, I had to search here to get the answer, maybe nicer to have on the readme for users who wish to install the “bleeding” edge.

1 Like

At least on linux, I just needed to install v8 via my package manager (in arch linux: v8-r from the AUR); then I followed what @bgoodri said above about installing the 2.21 headers and the develop branch of rstan. Worked fine, no tweaking needed. Hardest part was getting v8 installed, and only because their git repo wasn’t responding for some reason.

1 Like

I meant more that there could be a line on github that rstan users can use the 2.2* versions by installing the dev branch. I understand it’s not too hard to do this, just that it wasn’t easily found for me what version the dev branch is on and if it can be used (ie no big bugs, issues with R, etc.).

2 Likes