Thank you all for developing this amazing package! I’m having a hard time selecting levels of a factorial variable to plot. For example, instead of 8 schools, we assume there are 48 schools in total.
%matplotlib inline
import pymc3 as pm
import numpy as np
import matplotlib.pyplot as plt
plt.style.use('seaborn-darkgrid')
J = 48
y = np.array([ 28, 8, -3, 7, -1, 1, 18, 12,
-2, 15, 12, 5, 9, 1, 34, 6,
4, 23, -6, -3, 19, 2, 8, 10,
17, -2, 4, 1, 13, 21, 3, 2,
3, -10, 1, 7, 27, -1, 6, 9,
-4, 5, 13, 25, -12, 7, 2, 19])
sigma = np.array([15, 10, 16, 11, 9, 11, 10, 18,
13, 20, 7, 11, 12, 9, 16, 10,
16, 8, 20, 17, 19, 11, 15, 12,
10, 19, 20, 13, 12, 18, 16, 18,
9, 14, 11, 10, 18, 20, 7, 14,
7, 11, 22, 19, 20, 18, 11, 10])
with pm.Model() as hierarchical:
eta = pm.Normal('eta', 0, 1, shape=J)
mu = pm.Normal('mu', 0, sd=1e6)
tau = pm.HalfCauchy('tau', 5)
theta = pm.Deterministic('theta', mu + tau*eta)
obs = pm.Normal('obs', theta, sd=sigma, observed=y)
trace_h = pm.sample(1000)
pm.forestplot(trace_h, varnames=['theta']);
pm.plot_posterior(trace_h, varnames=['theta'], color='#87ceeb');
My questions are as follows:
- How do I select only
theta
s with level 10-20 and plot the trace (forestplot
, parallel coordinate plot,plot_posterior
)? - How do I tune the size of the
forestplot
? - I have tried
arviz
for this as well. Is there also a solution currently to tune the plot size ofarviz
?
Thanks again!