Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eight schools noncentered model in PyMC #264

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"model_code": "models/stan/eight_schools_noncentered.stan",
"stan_version": ">=2.26.0"
},
"pymc3": {
"model_code": "models/pymc3/eight_schools_noncentered.py"
"pymc": {
"model_code": "models/pymc/eight_schools_noncentered.py"
}
},
"added_by": "Mans Magnusson",
Expand Down
18 changes: 18 additions & 0 deletions posterior_database/models/pymc/eight_schools_noncentered.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import numpy as np
import pymc as pm


def model(data):
y_obs = np.array(data["y"]) # estimated treatment
sigma = np.array(data["sigma"]) # std of estimated effect
coords = {"school": np.arange(data["J"])}
with pm.Model(coords=coords) as pymc_model:

mu = pm.Normal(
"mu", mu=0, sigma=5
) # hyper-parameter of mean, non-informative prior
tau = pm.Cauchy("tau", alpha=0, beta=5) # hyper-parameter of sigma
theta_trans = pm.Normal("theta_trans", mu=0, sigma=1, dims="school")
theta = mu + tau * theta_trans
y = pm.Normal("y", mu=theta, sigma=sigma, observed=y_obs)
return pymc_model
18 changes: 0 additions & 18 deletions posterior_database/models/pymc3/eight_schools_noncentered.py

This file was deleted.

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name": "eight_schools-eight_schools_noncentered", "inference": {"method": "pymc_sampling", "method_arguments": {"chains": 10, "iter": 3000, "warmup": 1000, "thin": 1, "seed": 4711, "control": {"adapt_delta": 0.95}}}, "diagnostics": {"diagnostic_information": {"names": ["mu", "tau", "theta[0]", "theta[1]", "theta[2]", "theta[3]", "theta[4]", "theta[5]", "theta[6]", "theta[7]"]}, "ndraws": 20000, "nchains": 10, "effective_sample_size_bulk": [19657.0, 11821.0, 17136.0, 19976.0, 18096.0, 19727.0, 19315.0, 19180.0, 18853.0, 18420.0], "effective_sample_size_tail": [14859.0, 10546.0, 14445.0, 17196.0, 15365.0, 16743.0, 16464.0, 16186.0, 16037.0, 15791.0], "r_hat": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], "divergent_transitions": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], "expected_fraction_of_missing_information": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}, "checks_made": {"ndraws_is_10k": true, "nchains_is_gte_4": true, "ess_within_bounds": true, "r_hat_below_1_01": true, "efmi_above_0_2": false}, "comments": "", "added_by": "Chris Fonnesbeck", "added_date": "2024-08-12", "versions": {"pymc_version": "5.16.2+11.gb407c01ac.dirty", "python_version": "3.11.9 | packaged by conda-forge | (main, Apr 19 2024, 18:36:13) [GCC 12.3.0]", "python_environment": "['Babel==2.14.0', 'Brotli==1.1.0', 'MarkupSafe==2.1.5', 'PySocks==1.7.1', 'PyYAML==6.0.1', 'SQLAlchemy==2.0.31', 'absl-py==2.1.0', 'accessible-pygments==0.0.5', 'alabaster==0.7.16', 'arviz==0.18.0', 'asttokens==2.4.1', 'attrs==23.2.0', 'beautifulsoup4==4.12.3', 'betterproto==2.0.0b6', 'blackjax==0.0.0', 'bleach==6.1.0', 'cached-property==1.5.2', 'cachetools==5.3.3', 'certifi==2024.7.4', 'cffi==1.16.0', 'cfgv==3.3.1', 'charset-normalizer==3.3.2', 'chex==0.1.86', 'click==8.1.7', 'cloudpickle==3.0.0', 'colorama==0.4.6', 'comm==0.2.2', 'cons==0.4.6', 'contourpy==1.2.1', 'coverage==7.5.4', 'cycler==0.12.1', 'debugpy==1.8.2', 'decorator==5.1.1', 'defusedxml==0.7.1', 'distlib==0.3.8', 'dm-tree==0.1.8', 'docutils==0.21.2', 'entrypoints==0.4', 'etils==1.9.2', 'etuples==0.3.9', 'exceptiongroup==1.2.0', 'executing==2.0.1', 'fastjsonschema==2.20.0', 'fastprogress==1.0.3', 'filelock==3.15.4', 'fonttools==4.53.0', 'graphviz==0.20.3', 'greenlet==3.0.3', 'grpclib==0.4.7', 'h2==4.1.0', 'h5netcdf==1.3.0', 'h5py==3.11.0', 'hagelkorn==1.2.3', 'hpack==4.0.0', 'hyperframe==6.0.1', 'identify==2.5.36', 'idna==3.7', 'imagesize==1.4.1', 'importlib-metadata==8.0.0', 'importlib-resources==6.4.0', 'iniconfig==2.0.0', 'ipykernel==6.29.4', 'ipython==8.25.0', 'ipywidgets==8.1.3', 'jax==0.4.28', 'jaxlib==0.4.28.dev20240710', 'jaxopt==0.8.3', 'jedi==0.19.1', 'jinja2==3.1.4', 'joblib==1.4.2', 'jsonschema==4.22.0', 'jsonschema-specifications==2023.12.1', 'jupyter-cache==1.0.0', 'jupyter-client==8.6.2', 'jupyter-core==5.7.2', 'jupyter-sphinx==0.5.3', 'jupyterlab-pygments==0.3.0', 'jupyterlab-widgets==3.0.11', 'kiwisolver==1.4.5', 'logical-unification==0.4.6', 'markdown-it-py==3.0.0', 'matplotlib==3.8.4', 'matplotlib-inline==0.1.7', 'mcbackend==0.5.2', 'mdit-py-plugins==0.4.1', 'mdurl==0.1.2', 'miniKanren==1.0.3', 'mistune==3.0.2', 'mkl-service==2.4.1', 'ml-dtypes==0.4.0', 'multidict==6.0.5', 'multipledispatch==0.6.0', 'munkres==1.1.4', 'mypy==1.5.1', 'mypy-extensions==1.0.0', 'myst-nb==1.1.0', 'myst-parser==3.0.1', 'nbclient==0.10.0', 'nbconvert==7.16.4', 'nbformat==5.10.4', 'nest-asyncio==1.6.0', 'networkx==3.3', 'nodeenv==1.9.1', 'numdifftools==0.9.41', 'numpy==1.26.4', 'numpydoc==1.7.0', 'numpyro==0.15.1', 'opt-einsum==3.3.0', 'optax==0.2.2', 'packaging==24.1', 'pandas==2.2.2', 'pandocfilters==1.5.0', 'parso==0.8.4', 'pexpect==4.9.0', 'pickleshare==0.7.5', 'pillow==10.3.0', 'pip==24.0', 'pkgutil-resolve-name==1.3.10', 'platformdirs==4.2.2', 'pluggy==1.5.0', 'polyagamma==1.3.6', 'pre-commit==3.7.1', 'prompt-toolkit==3.0.47', 'psutil==6.0.0', 'ptyprocess==0.7.0', 'pure-eval==0.2.2', 'pycparser==2.22', 'pydata-sphinx-theme==0.14.4', 'pygments==2.18.0', 'pymc==5.16.2+11.gb407c01ac.dirty', 'pymc-experimental==0.1.1', 'pymc-sphinx-theme==0.14.0', 'pyparsing==3.1.2', 'pytensor==2.25.2', 'pytest==8.2.2', 'pytest-cov==5.0.0', 'python-dateutil==2.9.0', 'pytz==2024.1', 'pyzmq==26.0.3', 'referencing==0.35.1', 'requests==2.32.3', 'rich==13.7.1', 'rpds-py==0.18.1', 'scikit-learn==1.5.1', 'scipy==1.13.1', 'setuptools==70.1.1', 'six==1.16.0', 'snowballstemmer==2.2.0', 'soupsieve==2.5', 'sphinx==7.3.7', 'sphinx-copybutton==0.5.2', 'sphinx-design==0.6.0', 'sphinx-notfound-page==1.0.2', 'sphinx-remove-toctrees==1.0.0.post1', 'sphinxcontrib-applehelp==1.0.8', 'sphinxcontrib-devhelp==1.0.6', 'sphinxcontrib-htmlhelp==2.0.5', 'sphinxcontrib-jsmath==1.0.1', 'sphinxcontrib-qthelp==1.0.7', 'sphinxcontrib-serializinghtml==1.1.10', 'sphinxext-rediraffe==0.2.7', 'stack-data==0.6.2', 'tabulate==0.9.0', 'threadpoolctl==3.5.0', 'tinycss2==1.3.0', 'toml==0.10.2', 'tomli==2.0.1', 'toolz==0.12.1', 'tornado==6.4.1', 'tqdm==4.66.4', 'traitlets==5.14.3', 'types-cachetools==5.3.0.7', 'typing-extensions==4.12.2', 'tzdata==2024.1', 'ukkonen==1.0.1', 'urllib3==2.2.2', 'virtualenv==20.26.3', 'watermark==2.4.3', 'wcwidth==0.2.13', 'webencodings==0.5.1', 'wheel==0.43.0', 'widgetsnbextension==4.0.11', 'xarray==2024.6.0', 'xarray-einstats==0.7.0', 'zipp==3.19.2', 'zstandard==0.22.0']"}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"names": ["mu", "tau", "theta[0]", "theta[1]", "theta[2]", "theta[3]", "theta[4]", "theta[5]", "theta[6]", "theta[7]"], "mean": [4.417, 0.124, 6.252, 4.96, 3.953, 4.714, 3.607, 4.073, 6.287, 4.897], "sd": [3.327, 4.806, 5.729, 4.701, 5.252, 4.789, 4.671, 4.902, 5.14, 5.301], "mcse_mean": [0.024, 0.046, 0.045, 0.033, 0.04, 0.034, 0.034, 0.036, 0.038, 0.04]}