rstan-to-pystan
Installation
SKILL.md
RStan to PyStan Conversion
This skill provides guidance for converting RStan (R interface to Stan) code to PyStan (Python interface to Stan), focusing on the significant API differences between the two libraries.
Key Insight: Stan Model Code is Language-Agnostic
The Stan modeling language itself is identical between RStan and PyStan. The Stan model code (data blocks, parameters, model, generated quantities) can typically be copied directly. The conversion challenge lies in the wrapper code that:
- Prepares data for the model
- Calls the sampler with correct parameters
- Extracts and processes posterior samples
Pre-Conversion Checklist
Before writing any conversion code:
- Verify system dependencies for PyStan
- PyStan 3.x requires a C++ compiler (g++ on Linux, clang on macOS)
- Install with:
apt-get install g++or equivalent - Missing compiler causes cryptic compilation errors at runtime