Skip to content

Using the Stan statistical modelling language from Clojure using the CmdStan CLI

License

Notifications You must be signed in to change notification settings

scicloj/cmdstan-clj

Repository files navigation

cmdstan-clj

cmdstan-clj is a Clojure wrapper of Stan probabilistic programming language that uses the CmdStan CLI.

Clojars Project

If you wish to help in testing and extending this library, we would be glad to chat. It can be a nice opportunity to practice Bayesian Statistics, even if you are not experienced with it yet.

Status

Currently, this is an evolving proof-of-concept, still a bit fragile with respect to edge cases and setup.

Usage

You will need CmdStan installed in your system, and the environment variable STAN_HOME pointing to its location.

Them you can follow the 👣 walkthrough and 🎥 video.

Why

Stan is a programming language for Bayesian statistical modelling with wonderful community and ecosystem.

Clojure has a few actively developed probabilistic programming options such as Inferme and Gen.clj. Still, at some use casese, Stan is more efficient and certainly has a more complete ecosystem around it. While the pure-Clojure options keep evolving, it would be good to have Stan as well in our toolset. It may also help us in benchmarking and testing the other options.

One way to interoperate with Stan is through the command line CmdStan. It is a common way, used in other languages. Ideally, it should allow choosing a version of CmdStan, as well as compiling it for using the GPU.

clj-stan is great, but only supports an old version of CmdStan.

In the current project, we explore the current version of CmdStan. Possibly, when the details clarify, we may propose merging the new implementation into the existing clj-stan.

Implementation details

Currently, cmdstan-clj runs CmdStan through the makefile as advised by the manual. In the future, we may consider a more direct apporach as clj-stan seems to do. At the moment, the practical difference are not clear to us.

Related projects

We are also looking to create Clojure bindings for BridgeStan.

BridgeStan is a library (with bindings available in Python, Julia, R, and Rust) that grants access to the methods of a Stan model, including log densities, gradients, Hessians, and constraining and unconstraining transforms.

License

Copyright © 2024 Scicloj

EPLv1.0 is just the default for projects generated by clj-new: you are not required to open source this project, nor are you required to use EPLv1.0! Feel free to remove or change the LICENSE file and remove or update this section of the README.md file!

Distributed under the Eclipse Public License version 1.0.

About

Using the Stan statistical modelling language from Clojure using the CmdStan CLI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published