Ask
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News Sign UpSign In

PyStan in CoCalc

Project: Testing 18.04
Views: 486
Embed | Download | Raw |
Kernel: Python 3 (Ubuntu Linux)

PyStan in CoCalc – Python 3 (Ubuntu Linux) Kernel

https://pystan.readthedocs.io/en/latest/index.html

ATTN: compiling uses ~2.5 gb of RAM

import pystan
pystan.__version__
schools_code = """ data { int<lower=0> J; // number of schools vector[J] y; // estimated treatment effects vector<lower=0>[J] sigma; // s.e. of effect estimates } parameters { real mu; real<lower=0> tau; vector[J] eta; } transformed parameters { vector[J] theta; theta = mu + tau * eta; } model { eta ~ normal(0, 1); y ~ normal(theta, sigma); } """ schools_dat = { 'J': 8, 'y': [28, 8, -3, 7, -1, 1, 18, 12], 'sigma': [15, 10, 16, 11, 9, 11, 10, 18] }
sm = pystan.StanModel(model_code=schools_code) sm
fit = sm.sampling(data=schools_dat, iter=1000, chains=1, n_jobs=1) fit