Considering switch to Julia -- modelling examples linked to R / comparison to Stan / production environment

I maintain R software for hierarchical sde / state space modelling, oriented to social science contexts, and am also in the process of constructing something for large scale item response models. At present I have models coded in Stan (for fast gradients) and interface via R. Stan does some nice things but is a pretty inflexible from a dev point of view and too connected to it’s HMC approach, requiring a bunch of hacks for parallelism / optimization etc. Updating of the R connection also seems largely stopped. Julia looks like a fantastic way of unifying things for me, but at least for some time I would be interested in trying it just as a replacement for the computational side of things, and still use the current R front ends I have. I’m also interested in the prospect of using models coded in Julia as a replacement for c++ in some online software, where small jobs would be called from other software with fairly high frequency. Some queries:
Does this (or some of this) seem sensible? Is the R link mature / stable enough for this kind of thing? How does Julia compare to Stan in terms of computational performance (i.e. compute time / accuracy of an autodiff’d log gradient) for fairly complex models? Any recent comparisons available? Any examples available that roughly match what I want to do? Is anyone bored / enthusiastic enough to hold my hand with random question answering if I dive in to this, or does someone capable want a few hours consulting / tutoring work? Thanks for any guidance!

1 Like

If you haven’t seen it, I’d recomend taking a look at GPU-Accelerated ODE Solving in R with Julia, the Language of Libraries, which gives an example of calling Julia from R (also bringing up the objective to make it as ergonomic as Rcpp).

This paper has some benchmarks comparing Turing to Stan for HMC sampling.

Julia will be more flexible / allow you to tune things more easily when performance is a concern, e.g. defining custom adjoints.
There are a lot of AD options, but ForwardDiff and Zygote are the most mature for forward and reverse mode, respectively.
Diffractor is a promising library on the horizon that will offer mixed mode as well as efficient high order AD (which Zygote fails at, for example).