Dear All,
Thanks to Kit Baum, a new Stata package, stanrun, is available via the SSC archive:
:
stanrun provides a contemporary CmdStan interface for running Bayesian models in Stata. It supports full MCMC via Hamiltonian Monte Carlo (HMC) with the No-U-Turn Sampler (NUTS), as well as fast approximate inference via Automatic Differentiation Variational Inference (ADVI). The package handles model compilation, data export in R/S dump format, sequential chain execution, automatic posterior import into Stata, and basic convergence diagnostics (divergent transitions, R-hat, ESS).
stanrun is an enhanced successor to StataStan (Robert Grant & Mustafa Ascha), with key improvements including synchronous shell execution compatible with StataNow 19.5, automatic RTools detection for Windows compilation, CmdStan CSV import with automatic variable renaming, and variational inference support.
The package includes three programs:
- stanrun.ado: Main CmdStan interface
- stanrun_extract.ado: Posterior summary extraction (mean, SD, quantiles, R-hat, ESS)
- stanrun_diagnostics.ado: Convergence diagnostic flagging
Requirements: Stata 14+, CmdStan 2.26+, RTools (Windows)
Platform: Windows (tested on StataNow 19.5 MP with CmdStan 2.38)
Best regards,
Ben Dwamena
University of Michigan
[email protected]
