I’m busy preparing a poster about Stan.jl for JuliaCon 2018. Getting set up is pretty simple, although there are some minor details that I thought I’d document.
The Stan.jl uses the CmdStan command line client for interacting with Stan. This is what I did to install CmdStan on my Ubuntu 18.04 system.
Download the source distribution.
$ wget -P /tmp/ https://github.com/stan-dev/cmdstan/releases/download/v2.17.1/cmdstan-2.17.1.tar.gz
Unpack it under
$ cd /opt $ sudo tar -zxvf /tmp/cmdstan-2.17.1.tar.gz $ cd cmdstan-2.17.1
$ sudo make build
Since the distribution was unpacked under
/opt/ it was read only for non-root users. As a result I had a minor issue actually running my first Stan model because in the process Stan tried to create the precompiled header
/opt/ which, of course, resulted in a permission denied error. Quick fix for this: apply the changes from this pull request and rebuild. Sorted!
Upon success you can clean up the download.
$ rm /tmp/cmdstan-2.17.1.tar.gz
There are a couple of ways to tell Julia where to find
stanc. You can either set an environment variable (this should ideally be appended to the end of
~/.bashrc so that it is applied to each session).
Alternatively, if you don’t want to clutter up your shell namespace you can define it in your personal Julia initialisation file,
const CmdStanDir = "/opt/cmdstan-2.17.1/";
I prefer the second approach.
Install the Package
Now fire up Julia then install and load the
julia> Pkg.add("Stan") julia> using Stan
Find links to pertinent documentation in the package repository.