Skip to content

Instantly share code, notes, and snippets.

Created March 8, 2013 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/5119516 to your computer and use it in GitHub Desktop.
Save anonymous/5119516 to your computer and use it in GitHub Desktop.
Pasted from IPython
{
"metadata": {
"name": "2013_03_08_stan"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
"collapsed": false,
"input": [
"!date"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Fri Mar 8 12:13:38 PST 2013\r\n"
]
}
],
"prompt_number": 1
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The plan with this notebook is to work through the [RStan Getting Started Guide](https://code.google.com/p/stan/wiki/RStanGettingStarted) to see what Python wrappers would be necessary for equivalent functionality."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# [Example 1: Eight Schools](https://code.google.com/p/stan/wiki/RStanGettingStarted#Example_1:_Eight_Schools)\n",
"\n",
"This is an example in Section 5.5 of Gelman et al (2003), which studied coaching effects from eight schools. For simplicity, we call this example \"eight schools.\"\n",
"\n",
"Translating it to Python is a matter of converting single quotes to triple quotes, and a handful of other, similarly simple substitutions."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"def stan(model_code, data, iter, chains):\n",
" return # TODO: plumbing"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 2
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"schools_code = \"\"\"\n",
" data {\n",
" int<lower=0> J; // number of schools \n",
" real y[J]; // estimated treatment effects\n",
" real<lower=0> sigma[J]; // s.e. of effect estimates \n",
" }\n",
" parameters {\n",
" real mu; \n",
" real<lower=0> tau;\n",
" real eta[J];\n",
" }\n",
" transformed parameters {\n",
" real theta[J];\n",
" for (j in 1:J)\n",
" theta[j] <- mu + tau * eta[j];\n",
" }\n",
" model {\n",
" eta ~ normal(0, 1);\n",
" y ~ normal(theta, sigma);\n",
" }\n",
"\"\"\"\n",
"\n",
"schools_dat = dict(J = 8, \n",
" y = (28, 8, -3, 7, -1, 1, 18, 12),\n",
" sigma = (15, 10, 16, 11, 9, 11, 10, 18))\n",
"\n",
"fit = stan(model_code = schools_code, data = schools_dat, \n",
" iter = 1000, chains = 4)\n"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 3
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Of course, there is some plumbing necessary to make that do anything..."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"tmp_dir = '/tmp/'\n",
"def save_temp(txt, fname):\n",
" fname = tmp_dir + fname # TODO: avoid collisions, plan for cleanup\n",
" with file(fname, 'w') as f:\n",
" f.write(txt)\n",
" \n",
" return fname\n",
"\n",
"def rdump(params):\n",
" # If a full implementation of this does not yet exist,\n",
" # I suggest implementing json on the C++ side of Stan\n",
" txt = ''\n",
" \n",
" for key, val in params.items():\n",
" if type(val) == int:\n",
" txt += '%s <- %d\\n' % (key, val)\n",
" elif type(val) == tuple:\n",
" txt += '%s <- c%s\\n' % (key, val)\n",
" return txt"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 4
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import pandas as pd, StringIO"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 5
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"def load_samples(sample_path):\n",
" comments = ''\n",
" samples = ''\n",
" \n",
" with file(sample_path) as f:\n",
" for line in f:\n",
" if line[0] == '#':\n",
" comments += line\n",
" else:\n",
" samples += line\n",
" \n",
" df = pd.read_csv(StringIO.StringIO(samples))\n",
" df.comments = comments\n",
" \n",
" return df\n"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 6
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"def stan(model_code, data, iter, chains):\n",
" code_path = save_temp(model_code, 'model.stan')\n",
" data_path = save_temp(rdump(data), 'model.Rdata')\n",
" model_path = code_path.replace('.stan', '')\n",
" \n",
" %cd ~/notebook/stan-src-1.1.1/\n",
" !time make $model_path\n",
" \n",
" %cd $tmp_dir\n",
" !time $model_path --data=$data_path\n",
" \n",
" sample_path = code_path.replace('model.stan', 'samples.csv')\n",
" return load_samples(sample_path)\n",
"\n",
"fit = stan(model_code = schools_code, data = schools_dat, \n",
" iter = 1000, chains = 4)\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"/snfs2/HOME/abie/new_dm/stan-src-1.1.1\n"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"\r\n",
"--- Translating Stan graphical model to C++ code ---\r\n",
"bin/stanc /tmp/model.stan --o=/tmp/model.cpp\r\n",
"Model name=model_model\r\n",
"Input file=/tmp/model.stan\r\n",
"Output file=/tmp/model.cpp\r\n"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"g++ -I src -I lib/eigen_3.1.2 -I lib/boost_1.52.0 -Wall -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -c -O3 -o /tmp/model.o /tmp/model.cpp\r\n"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"src/stan/agrad/agrad.hpp:2191: warning: \u2018void stan::agrad::free_memory()\u2019 defined but not used\r\n"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"g++ -I src -I lib/eigen_3.1.2 -I lib/boost_1.52.0 -Wall -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -lpthread -O3 -o /tmp/model /tmp/model.o -Lbin -lstan\r\n"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"\r\n",
"real\t0m16.502s\r\n",
"user\t0m14.355s\r\n",
"sys\t0m0.711s\r\n"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"/tmp\n",
"STAN SAMPLING COMMAND\r\n",
"data = /tmp/model.Rdata\r\n",
"init = random initialization\r\n",
"init tries = 1\r\n",
"samples = samples.csv\r\n",
"append_samples = 0\r\n",
"save_warmup = 0\r\n",
"seed = 1389169387 (randomly generated)\r\n",
"chain_id = 1 (default)\r\n",
"iter = 2000\r\n",
"warmup = 1000\r\n",
"thin = 1 (default)\r\n",
"equal_step_sizes = 0\r\n",
"leapfrog_steps = -1\r\n",
"max_treedepth = 10\r\n",
"epsilon = -1\r\n",
"epsilon_pm = 0\r\n",
"delta = 0.5\r\n",
"gamma = 0.05\r\n",
"\r\n",
"Iteration: 1 / 2000 [ 0%] (Adapting)\r\n",
"Iteration: 10 / 2000 [ 0%] (Adapting)\r\n",
"Iteration: 20 / 2000 [ 1%] (Adapting)\r\n",
"Iteration: 30 / 2000 [ 1%] (Adapting)\r\n",
"Iteration: 40 / 2000 [ 2%] (Adapting)\r\n",
"Iteration: 50 / 2000 [ 2%] (Adapting)\r\n",
"Iteration: 60 / 2000 [ 3%] (Adapting)\r\n",
"Iteration: 70 / 2000 [ 3%] (Adapting)\r\n",
"Iteration: 80 / 2000 [ 4%] (Adapting)\r\n",
"Iteration: 90 / 2000 [ 4%] (Adapting)\r\n",
"Iteration: 100 / 2000 [ 5%] (Adapting)\r\n",
"Iteration: 110 / 2000 [ 5%] (Adapting)\r\n",
"Iteration: 120 / 2000 [ 6%] (Adapting)\r\n",
"Iteration: 130 / 2000 [ 6%] (Adapting)\r\n",
"Iteration: 140 / 2000 [ 7%] (Adapting)\r\n",
"Iteration: 150 / 2000 [ 7%] (Adapting)\r\n",
"Iteration: 160 / 2000 [ 8%] (Adapting)\r\n",
"Iteration: 170 / 2000 [ 8%] (Adapting)\r\n",
"Iteration: 180 / 2000 [ 9%] (Adapting)\r\n",
"Iteration: 190 / 2000 [ 9%] (Adapting)\r\n",
"Iteration: 200 / 2000 [ 10%] (Adapting)\r\n",
"Iteration: 210 / 2000 [ 10%] (Adapting)\r\n",
"Iteration: 220 / 2000 [ 11%] (Adapting)\r\n",
"Iteration: 230 / 2000 [ 11%] (Adapting)\r\n",
"Iteration: 240 / 2000 [ 12%] (Adapting)\r\n",
"Iteration: 250 / 2000 [ 12%] (Adapting)\r\n",
"Iteration: 260 / 2000 [ 13%] (Adapting)\r\n",
"Iteration: 270 / 2000 [ 13%] (Adapting)\r\n",
"Iteration: 280 / 2000 [ 14%] (Adapting)\r\n",
"Iteration: 290 / 2000 [ 14%] (Adapting)\r\n",
"Iteration: 300 / 2000 [ 15%] (Adapting)\r\n",
"Iteration: 310 / 2000 [ 15%] (Adapting)\r\n",
"Iteration: 320 / 2000 [ 16%] (Adapting)\r\n",
"Iteration: 330 / 2000 [ 16%] (Adapting)\r\n",
"Iteration: 340 / 2000 [ 17%] (Adapting)\r\n",
"Iteration: 350 / 2000 [ 17%] (Adapting)\r\n",
"Iteration: 360 / 2000 [ 18%] (Adapting)\r\n",
"Iteration: 370 / 2000 [ 18%] (Adapting)\r\n",
"Iteration: 380 / 2000 [ 19%] (Adapting)\r\n",
"Iteration: 390 / 2000 [ 19%] (Adapting)\r\n",
"Iteration: 400 / 2000 [ 20%] (Adapting)\r\n",
"Iteration: 410 / 2000 [ 20%] (Adapting)\r\n",
"Iteration: 420 / 2000 [ 21%] (Adapting)\r\n",
"Iteration: 430 / 2000 [ 21%] (Adapting)\r\n",
"Iteration: 440 / 2000 [ 22%] (Adapting)\r\n",
"Iteration: 450 / 2000 [ 22%] (Adapting)\r\n",
"Iteration: 460 / 2000 [ 23%] (Adapting)\r\n",
"Iteration: 470 / 2000 [ 23%] (Adapting)\r\n",
"Iteration: 480 / 2000 [ 24%] (Adapting)\r\n",
"Iteration: 490 / 2000 [ 24%] (Adapting)\r\n",
"Iteration: 500 / 2000 [ 25%] (Adapting)\r\n",
"Iteration: 510 / 2000 [ 25%] (Adapting)\r\n",
"Iteration: 520 / 2000 [ 26%] (Adapting)\r\n",
"Iteration: 530 / 2000 [ 26%] (Adapting)\r\n",
"Iteration: 540 / 2000 [ 27%] (Adapting)\r\n",
"Iteration: 550 / 2000 [ 27%] (Adapting)\r\n",
"Iteration: 560 / 2000 [ 28%] (Adapting)\r\n",
"Iteration: 570 / 2000 [ 28%] (Adapting)\r\n",
"Iteration: 580 / 2000 [ 29%] (Adapting)\r\n",
"Iteration: 590 / 2000 [ 29%] (Adapting)\r\n",
"Iteration: 600 / 2000 [ 30%] (Adapting)\r\n",
"Iteration: 610 / 2000 [ 30%] (Adapting)\r\n",
"Iteration: 620 / 2000 [ 31%] (Adapting)\r\n",
"Iteration: 630 / 2000 [ 31%] (Adapting)\r\n",
"Iteration: 640 / 2000 [ 32%] (Adapting)\r\n",
"Iteration: 650 / 2000 [ 32%] (Adapting)\r\n",
"Iteration: 660 / 2000 [ 33%] (Adapting)\r\n",
"Iteration: 670 / 2000 [ 33%] (Adapting)\r\n",
"Iteration: 680 / 2000 [ 34%] (Adapting)\r\n",
"Iteration: 690 / 2000 [ 34%] (Adapting)\r\n",
"Iteration: 700 / 2000 [ 35%] (Adapting)\r\n",
"Iteration: 710 / 2000 [ 35%] (Adapting)\r\n",
"Iteration: 720 / 2000 [ 36%] (Adapting)\r\n",
"Iteration: 730 / 2000 [ 36%] (Adapting)\r\n",
"Iteration: 740 / 2000 [ 37%] (Adapting)\r\n",
"Iteration: 750 / 2000 [ 37%] (Adapting)\r\n",
"Iteration: 760 / 2000 [ 38%] (Adapting)\r\n",
"Iteration: 770 / 2000 [ 38%] (Adapting)\r\n",
"Iteration: 780 / 2000 [ 39%] (Adapting)\r\n",
"Iteration: 790 / 2000 [ 39%] (Adapting)\r\n",
"Iteration: 800 / 2000 [ 40%] (Adapting)\r\n",
"Iteration: 810 / 2000 [ 40%] (Adapting)\r\n",
"Iteration: 820 / 2000 [ 41%] (Adapting)\r\n",
"Iteration: 830 / 2000 [ 41%] (Adapting)\r\n",
"Iteration: 840 / 2000 [ 42%] (Adapting)\r\n",
"Iteration: 850 / 2000 [ 42%] (Adapting)\r\n",
"Iteration: 860 / 2000 [ 43%] (Adapting)\r\n",
"Iteration: 870 / 2000 [ 43%] (Adapting)\r\n",
"Iteration: 880 / 2000 [ 44%] (Adapting)\r\n",
"Iteration: 890 / 2000 [ 44%] (Adapting)\r\n",
"Iteration: 900 / 2000 [ 45%] (Adapting)\r\n",
"Iteration: 910 / 2000 [ 45%] (Adapting)\r\n",
"Iteration: 920 / 2000 [ 46%] (Adapting)\r\n",
"Iteration: 930 / 2000 [ 46%] (Adapting)\r\n",
"Iteration: 940 / 2000 [ 47%] (Adapting)\r\n",
"Iteration: 950 / 2000 [ 47%] (Adapting)\r\n",
"Iteration: 960 / 2000 [ 48%] (Adapting)\r\n",
"Iteration: 970 / 2000 [ 48%] (Adapting)\r\n",
"Iteration: 980 / 2000 [ 49%] (Adapting)\r\n",
"Iteration: 990 / 2000 [ 49%] (Adapting)\r\n",
"Iteration: 1000 / 2000 [ 50%] (Adapting)\r\n",
"Iteration: 1010 / 2000 [ 50%] (Sampling)\r\n",
"Iteration: 1020 / 2000 [ 51%] (Sampling)\r\n",
"Iteration: 1030 / 2000 [ 51%] (Sampling)\r\n",
"Iteration: 1040 / 2000 [ 52%] (Sampling)\r\n",
"Iteration: 1050 / 2000 [ 52%] (Sampling)\r\n",
"Iteration: 1060 / 2000 [ 53%] (Sampling)\r\n",
"Iteration: 1070 / 2000 [ 53%] (Sampling)\r\n",
"Iteration: 1080 / 2000 [ 54%] (Sampling)\r\n",
"Iteration: 1090 / 2000 [ 54%] (Sampling)\r\n",
"Iteration: 1100 / 2000 [ 55%] (Sampling)\r\n",
"Iteration: 1110 / 2000 [ 55%] (Sampling)\r\n",
"Iteration: 1120 / 2000 [ 56%] (Sampling)\r\n",
"Iteration: 1130 / 2000 [ 56%] (Sampling)\r\n",
"Iteration: 1140 / 2000 [ 57%] (Sampling)\r\n",
"Iteration: 1150 / 2000 [ 57%] (Sampling)\r\n",
"Iteration: 1160 / 2000 [ 58%] (Sampling)\r\n",
"Iteration: 1170 / 2000 [ 58%] (Sampling)\r\n",
"Iteration: 1180 / 2000 [ 59%] (Sampling)\r\n",
"Iteration: 1190 / 2000 [ 59%] (Sampling)\r\n",
"Iteration: 1200 / 2000 [ 60%] (Sampling)\r\n",
"Iteration: 1210 / 2000 [ 60%] (Sampling)\r\n",
"Iteration: 1220 / 2000 [ 61%] (Sampling)\r\n",
"Iteration: 1230 / 2000 [ 61%] (Sampling)\r\n",
"Iteration: 1240 / 2000 [ 62%] (Sampling)\r\n",
"Iteration: 1250 / 2000 [ 62%] (Sampling)\r\n",
"Iteration: 1260 / 2000 [ 63%] (Sampling)\r\n",
"Iteration: 1270 / 2000 [ 63%] (Sampling)\r\n",
"Iteration: 1280 / 2000 [ 64%] (Sampling)\r\n",
"Iteration: 1290 / 2000 [ 64%] (Sampling)\r\n",
"Iteration: 1300 / 2000 [ 65%] (Sampling)\r\n",
"Iteration: 1310 / 2000 [ 65%] (Sampling)\r\n",
"Iteration: 1320 / 2000 [ 66%] (Sampling)\r\n",
"Iteration: 1330 / 2000 [ 66%] (Sampling)\r\n",
"Iteration: 1340 / 2000 [ 67%] (Sampling)\r\n",
"Iteration: 1350 / 2000 [ 67%] (Sampling)\r\n",
"Iteration: 1360 / 2000 [ 68%] (Sampling)\r\n",
"Iteration: 1370 / 2000 [ 68%] (Sampling)\r\n",
"Iteration: 1380 / 2000 [ 69%] (Sampling)\r\n",
"Iteration: 1390 / 2000 [ 69%] (Sampling)\r\n",
"Iteration: 1400 / 2000 [ 70%] (Sampling)\r\n",
"Iteration: 1410 / 2000 [ 70%] (Sampling)\r\n",
"Iteration: 1420 / 2000 [ 71%] (Sampling)\r\n",
"Iteration: 1430 / 2000 [ 71%] (Sampling)\r\n",
"Iteration: 1440 / 2000 [ 72%] (Sampling)\r\n",
"Iteration: 1450 / 2000 [ 72%] (Sampling)\r\n",
"Iteration: 1460 / 2000 [ 73%] (Sampling)\r\n",
"Iteration: 1470 / 2000 [ 73%] (Sampling)\r\n",
"Iteration: 1480 / 2000 [ 74%] (Sampling)\r\n",
"Iteration: 1490 / 2000 [ 74%] (Sampling)\r\n",
"Iteration: 1500 / 2000 [ 75%] (Sampling)\r\n",
"Iteration: 1510 / 2000 [ 75%] (Sampling)\r\n",
"Iteration: 1520 / 2000 [ 76%] (Sampling)\r\n",
"Iteration: 1530 / 2000 [ 76%] (Sampling)\r\n",
"Iteration: 1540 / 2000 [ 77%] (Sampling)\r\n",
"Iteration: 1550 / 2000 [ 77%] (Sampling)\r\n",
"Iteration: 1560 / 2000 [ 78%] (Sampling)\r\n",
"Iteration: 1570 / 2000 [ 78%] (Sampling)\r\n",
"Iteration: 1580 / 2000 [ 79%] (Sampling)\r\n",
"Iteration: 1590 / 2000 [ 79%] (Sampling)\r\n",
"Iteration: 1600 / 2000 [ 80%] (Sampling)\r\n",
"Iteration: 1610 / 2000 [ 80%] (Sampling)\r\n",
"Iteration: 1620 / 2000 [ 81%] (Sampling)\r\n",
"Iteration: 1630 / 2000 [ 81%] (Sampling)\r\n",
"Iteration: 1640 / 2000 [ 82%] (Sampling)\r\n",
"Iteration: 1650 / 2000 [ 82%] (Sampling)\r\n",
"Iteration: 1660 / 2000 [ 83%] (Sampling)\r\n",
"Iteration: 1670 / 2000 [ 83%] (Sampling)\r\n",
"Iteration: 1680 / 2000 [ 84%] (Sampling)\r\n",
"Iteration: 1690 / 2000 [ 84%] (Sampling)\r\n",
"Iteration: 1700 / 2000 [ 85%] (Sampling)\r\n",
"Iteration: 1710 / 2000 [ 85%] (Sampling)\r\n",
"Iteration: 1720 / 2000 [ 86%] (Sampling)\r\n",
"Iteration: 1730 / 2000 [ 86%] (Sampling)\r\n",
"Iteration: 1740 / 2000 [ 87%] (Sampling)\r\n",
"Iteration: 1750 / 2000 [ 87%] (Sampling)\r\n",
"Iteration: 1760 / 2000 [ 88%] (Sampling)\r\n",
"Iteration: 1770 / 2000 [ 88%] (Sampling)\r\n",
"Iteration: 1780 / 2000 [ 89%] (Sampling)\r\n",
"Iteration: 1790 / 2000 [ 89%] (Sampling)\r\n",
"Iteration: 1800 / 2000 [ 90%] (Sampling)\r\n",
"Iteration: 1810 / 2000 [ 90%] (Sampling)\r\n",
"Iteration: 1820 / 2000 [ 91%] (Sampling)\r\n",
"Iteration: 1830 / 2000 [ 91%] (Sampling)\r\n",
"Iteration: 1840 / 2000 [ 92%] (Sampling)\r\n",
"Iteration: 1850 / 2000 [ 92%] (Sampling)\r\n",
"Iteration: 1860 / 2000 [ 93%] (Sampling)\r\n",
"Iteration: 1870 / 2000 [ 93%] (Sampling)\r\n",
"Iteration: 1880 / 2000 [ 94%] (Sampling)\r\n",
"Iteration: 1890 / 2000 [ 94%] (Sampling)\r\n",
"Iteration: 1900 / 2000 [ 95%] (Sampling)\r\n",
"Iteration: 1910 / 2000 [ 95%] (Sampling)\r\n",
"Iteration: 1920 / 2000 [ 96%] (Sampling)\r\n",
"Iteration: 1930 / 2000 [ 96%] (Sampling)\r\n",
"Iteration: 1940 / 2000 [ 97%] (Sampling)\r\n"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Iteration: 1950 / 2000 [ 97%] (Sampling)\r\n",
"Iteration: 1960 / 2000 [ 98%] (Sampling)\r\n",
"Iteration: 1970 / 2000 [ 98%] (Sampling)\r\n",
"Iteration: 1980 / 2000 [ 99%] (Sampling)\r\n",
"Iteration: 1990 / 2000 [ 99%] (Sampling)\r\n",
"Iteration: 2000 / 2000 [100%] (Sampling)\r\n",
"\r\n",
"\r\n",
"\r\n",
"real\t0m0.048s\r\n",
"user\t0m0.040s\r\n",
"sys\t0m0.002s\r\n"
]
}
],
"prompt_number": 7
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"print round_(fit.describe(95).T, 1)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
" count mean std min 2.5% 50% 97.5% max\n",
"lp__ 1000 -5.2 2.7 -15.8 -11.5 -4.9 -0.5 0.1\n",
"treedepth__ 1000 2.4 0.8 0.0 1.0 3.0 3.0 5.0\n",
"stepsize__ 1000 1.1 0.0 1.1 1.1 1.1 1.1 1.1\n",
"mu 1000 8.0 6.5 -8.0 -4.7 7.6 24.8 28.8\n",
"tau 1000 6.6 5.9 0.0 0.1 5.2 24.0 26.7\n",
"eta.1 1000 0.4 1.0 -2.5 -1.5 0.4 2.3 3.2\n",
"eta.2 1000 -0.1 0.9 -2.8 -2.0 -0.0 1.7 3.7\n",
"eta.3 1000 -0.2 0.9 -2.8 -1.8 -0.3 1.7 2.8\n",
"eta.4 1000 -0.1 1.0 -3.3 -1.9 -0.1 1.7 2.9\n",
"eta.5 1000 -0.3 0.9 -3.5 -2.0 -0.3 1.5 3.6\n",
"eta.6 1000 -0.2 0.9 -3.5 -1.8 -0.2 1.6 2.7\n",
"eta.7 1000 0.3 0.9 -3.1 -1.5 0.4 1.9 3.2\n",
"eta.8 1000 0.0 0.9 -3.2 -1.7 -0.0 1.7 2.9\n",
"theta.1 1000 11.6 8.2 -8.5 -1.7 10.2 32.1 51.8\n",
"theta.2 1000 7.8 6.7 -16.9 -4.1 7.5 23.3 31.2\n",
"theta.3 1000 5.8 8.5 -20.7 -20.7 6.5 19.6 27.1\n",
"theta.4 1000 7.8 7.0 -15.8 -6.3 7.7 24.6 34.5\n",
"theta.5 1000 5.2 6.2 -16.1 -8.1 5.9 15.5 22.0\n",
"theta.6 1000 6.3 6.5 -13.3 -6.6 6.2 19.5 30.3\n",
"theta.7 1000 10.5 6.7 -10.5 -1.5 9.7 24.3 36.7\n",
"theta.8 1000 8.6 8.1 -13.3 -7.0 7.8 27.0 50.0\n"
]
}
],
"prompt_number": 8
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"print fit.comments"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"# Samples Generated by Stan\n",
"#\n",
"# stan_version_major=1\n",
"# stan_version_minor=1\n",
"# stan_version_patch=1\n",
"# data=/tmp/model.Rdata\n",
"# init=random initialization\n",
"# append_samples=0\n",
"# save_warmup=0\n",
"# seed=1389169387\n",
"# chain_id=1\n",
"# iter=2000\n",
"# warmup=1000\n",
"# thin=1\n",
"# equal_step_sizes=0\n",
"# leapfrog_steps=-1\n",
"# max_treedepth=10\n",
"# epsilon=-1\n",
"# epsilon_pm=0\n",
"# delta=0.5\n",
"# gamma=0.05\n",
"#\n",
"# (mcmc::nuts_diag) adaptation finished\n",
"# step size=1.06744\n",
"# parameter step size multipliers:\n",
"# 2.62742,0.67717,0.596109,0.522487,0.608809,0.576615,0.557494,0.561288,0.561017,0.60503\n",
"\n"
]
}
],
"prompt_number": 9
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"!date"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Fri Mar 8 12:13:58 PST 2013\r\n"
]
}
],
"prompt_number": 10
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Still to do:\n",
"\n",
"* Use the iter and chains options\n",
"* Call the C++ code directly, instead of using temp files and commandline interface\n",
"* Reproduce the rest of the getting started\n",
"\n",
"Patches welcome!"
]
}
],
"metadata": {}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment