tpapp / StanRun.jl

Run Stan samples from Julia.
Other
3 stars 1 forks source link

StanRun.jl

lifecycle build codecov.io

A collection of routines for running CmdStan.

Installation

This package is registered. Install with

pkg> add StanRun

You need a working CmdStan installation, the path of which you should specify in JULIA_CMDSTAN_HOME, eg in your ~/.julia/config/startup.jl have a line like

# CmdStan setup
ENV["JULIA_CMDSTAN_HOME"] = expanduser("~/src/cmdstan-2.19.1/") # replace with your path

Usage

It is recommended that you start your Julia process with multiple worker processes to take advantage of parallel sampling, eg

julia -p auto

Otherwise, stan_sample will use a single process.

Use this package like this:

using StanRun
model = StanModel("/path/to/model.stan") # directory should be writable, for compilation
data = (N = 100, x = randn(N, 1000))     # in a format supported by stan_dump
chains = stan_sample(model, data, 5)     # 5 chain paths and log files

See the docstrings (in particular ?StanRun) for more.