Skip to content

Commit

Permalink
Merge e447419 into d6a0325
Browse files Browse the repository at this point in the history
  • Loading branch information
ColCarroll committed May 25, 2018
2 parents d6a0325 + e447419 commit 9f9b9df
Show file tree
Hide file tree
Showing 9 changed files with 150 additions and 12 deletions.
2 changes: 1 addition & 1 deletion arviz/plots/forestplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def forestplot(trace, models=None, varnames=None, alpha=0.05, quartiles=True, rh
all_quants = []
bands = [(0.05, 0)[i % 2] for i in range(len(varnames))]
var_old = 0.5
for v_idx, varname in enumerate(varnames):
for v_idx, varname in enumerate(sorted(varnames)):
for h_idx, tr in enumerate(traces):
if plot_rhat[h_idx]:
gr_stat = gelman_rubin(tr)
Expand Down
26 changes: 15 additions & 11 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,32 @@ Contributions and issue reports are very welcome at `the github repository
</div>
<div class="col-md-6">
<div class="container-fluid hidden-xs hidden-sm">
<a href="examples/energyplot.html">
<div class="col-md-3 thumbnail">
<img src="_static/energyplot_thumb.png">
<a href="examples/parallelplot.html">
<div class="col-md-4 thumbnail">
<img src="_static/parallelplot_thumb.png">
</div>
</a>
<a href="examples/traceplot.html">
<div class="col-md-3 thumbnail">
<div class="col-md-4 thumbnail">
<img src="_static/traceplot_thumb.png">
</div>
</a>
<a href="examples/densityplot.html">
<div class="col-md-3 thumbnail">
<img src="_static/densityplot_thumb.png">
<a href="examples/energyplot.html">
<div class="col-md-4 thumbnail">
<img src="_static/energyplot_thumb.png">
</div>
<a href="examples/jointplot.html">
<div class="col-md-4 thumbnail">
<img src="_static/jointplot_thumb.png">
</div>
</a>
<a href="examples/compareplot.html">
<div class="col-md-3 thumbnail">
<img src="_static/compareplot_thumb.png">
<a href="examples/ppcplot.html">
<div class="col-md-4 thumbnail">
<img src="_static/ppcplot_thumb.png">
</div>
</a>
<a href="examples/autocorrplot.html">
<div class="col-md-3 thumbnail">
<div class="col-md-4 thumbnail">
<img src="_static/autocorrplot_thumb.png">
</div>
</a>
Expand Down
12 changes: 12 additions & 0 deletions examples/forestplot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""
Forest Plot
===========
_thumb: .5, .8
"""
import arviz as az

az.style.use('arviz-darkgrid')

trace = az.load_trace('data/centered_eight_trace.gzip')
az.forestplot(trace, varnames=('theta__0', 'theta__1', 'theta__2'))
12 changes: 12 additions & 0 deletions examples/jointplot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""
Joint Plot
==========
_thumb: .5, .8
"""
import arviz as az

az.style.use('arviz-darkgrid')

trace = az.load_trace('data/non_centered_eight_trace.gzip')
az.jointplot(trace, kind='hexbin', varnames=('tau', 'mu'))
15 changes: 15 additions & 0 deletions examples/kdeplot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""
KDE Plot
========
_thumb: .2, .8
"""
import arviz as az
import matplotlib.pyplot as plt

az.style.use('arviz-darkgrid')

trace = az.load_trace('data/non_centered_eight_trace.gzip')

fig, ax = plt.subplots(figsize=(12, 8))
az.kdeplot(trace.tau, fill_alpha=0.1, ax=ax)
28 changes: 28 additions & 0 deletions examples/pairplot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""
Pair Plot
=========
_thumb: .2, .5
"""
import arviz as az
import numpy as np
import pymc3 as pm

az.style.use('arviz-darkgrid')

# Data of the Eight Schools Model
J = 8
y = np.array([28., 8., -3., 7., -1., 1., 18., 12.])
sigma = np.array([15., 10., 16., 11., 9., 11., 10., 18.])


with pm.Model() as centered_eight:
mu = pm.Normal('mu', mu=0, sd=5)
tau = pm.HalfCauchy('tau', beta=5)
theta = pm.Normal('theta', mu=mu, sd=tau, shape=J)
obs = pm.Normal('obs', mu=theta, sd=sigma, observed=y)
centered_eight_trace = pm.sample()

az.pairplot(centered_eight_trace,
varnames=['theta__0', 'theta__1', 'tau', 'mu'],
divergences=True)
26 changes: 26 additions & 0 deletions examples/parallelplot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""
Parallel Plot
=============
_thumb: .2, .5
"""
import arviz as az
import numpy as np
import pymc3 as pm

az.style.use('arviz-darkgrid')

# Data of the Eight Schools Model
J = 8
y = np.array([28., 8., -3., 7., -1., 1., 18., 12.])
sigma = np.array([15., 10., 16., 11., 9., 11., 10., 18.])


with pm.Model() as centered_eight:
mu = pm.Normal('mu', mu=0, sd=5)
tau = pm.HalfCauchy('tau', beta=5)
theta = pm.Normal('theta', mu=mu, sd=tau, shape=J)
obs = pm.Normal('obs', mu=theta, sd=sigma, observed=y)
centered_eight_trace = pm.sample()

az.parallelplot(centered_eight_trace, varnames=['theta', 'tau', 'mu'])
12 changes: 12 additions & 0 deletions examples/posteriorplot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""
Posterior Plot
==============
_thumb: .5, .8
"""
import arviz as az

az.style.use('arviz-darkgrid')

trace = az.load_trace('data/non_centered_eight_trace.gzip')
az.posteriorplot(trace, varnames=['theta__0', 'theta__1', 'tau', 'mu'])
29 changes: 29 additions & 0 deletions examples/ppcplot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""
Posterior Predictive Check Plot
===============================
_thumb: .6, .5
"""
import arviz as az
import numpy as np
import pymc3 as pm

az.style.use('arviz-darkgrid')

# Data of the Eight Schools Model
J = 8
y = np.array([28., 8., -3., 7., -1., 1., 18., 12.])
sigma = np.array([15., 10., 16., 11., 9., 11., 10., 18.])


with pm.Model() as centered_eight:
mu = pm.Normal('mu', mu=0, sd=5)
tau = pm.HalfCauchy('tau', beta=5)
theta = pm.Normal('theta', mu=mu, sd=tau, shape=J)
obs = pm.Normal('obs', mu=theta, sd=sigma, observed=y)
centered_eight_trace = pm.sample()

with centered_eight:
ppc_samples = pm.sample_ppc(centered_eight_trace)

az.ppcplot(y, ppc_samples)

0 comments on commit 9f9b9df

Please sign in to comment.