Just thought it might interest some here – I’m migrating the ctsem software GitHub - cdriveraus/ctsem: Hierarchical continuous time state space modelling · GitHub (now with GUI for anyone really curious! GitHub - cdriveraus/ctsemGUI: GUI for ctsem package · GitHub ) from the rstan backend to Julia, and made a few comparisons along the way. I was surprised (and a little disappointed!) how well the stan version held up – the ctsem stan model is really pushing the stan code structure further than I think it was intended (particularly to avoid recompiling models except in complex nonlinear cases).
The continuous time extended kalman filter over multiple subjects involves a lot of repeated small - moderate size matrix operations (cholesky, exp, custom solves for the diffusion), and it’s primarily used for evaluating the log prob / gradient (hmc is too slow, though importance sampling from the mode works well in low to moderate dims) and I really thought a re-write would more dramatically improve things because of this. Both Julia and native cpp achieve ~3x the stan performance for gradient calculation on 20 dimensional nonlinear systems, which is very nice, but required custom adjoint gradient functions – none of the autodiff packages could handle a reverse mode pass on it. The julia backend anyway buys a lot more flexibility going forwards, avoids very long model recompiles when a user specifies anything complicated, and means I can retire the rstan dependency at some point, so I’m not unhappy with the change, to be clear ;) Mostly just impressed at the speed of the stan code, which wouldn’t have surprised me for simpler models, but did surprise me for my fairly horrendous model code ( ctsem/inst/stan/ctsm.stan at master · cdriveraus/ctsem · GitHub for those that like horror films) – but maybe it doesn’t surprise others?