Dear Pymc3 experts,
I am trying a very simple three-level hierarchical model, I try to model the lowest level’s value, however, I got the following problem.
##simulate data
sim_mu_mu = 0.3
sim_mu_sigma = 0.5
sim_sigma_mu = 1
sim_sigma_sigma = 0.05
sim_indiv_mu=np.random.normal(sim_mu_mu,sim_sigma_sigma,10)
sim_indiv_sigma = np.random.normal(sim_sigma_mu,sim_sigma_sigma,10)
sim_data = np.zeros([10,80])
for n in range(10):
sim_data[n,:] = np.random.normal(sim_indiv_mu[n],sim_indiv_sigma[n],80)
with pm.Model() as m:
m_mu = pm.Normal('m_mu',0,1,testval=0)
m_sd = pm.math.exp(pm.HalfCauchy('m_sd',5,testval=0.1))
m_raw = pm.Normal('m_raw',0,1,shape = 10)
theta = t.tile(pm.Deterministic('theta',m_mu + m_sd * m_raw),80).reshape(shape=(80,10),ndim=2)
s_mu = pm.Normal('s_mu',0,1,testval=0)
s_sd = pm.math.exp(pm.HalfCauchy('s_sd',3,testval=0.1))
s_raw = pm.Normal('s_raw',0,1,shape = 10)
sigma = t.tile(pm.Deterministic('eta',s_mu + s_sd * s_raw),80).reshape(shape=(80,10),ndim=2)
y = pm.Normal('y',mu = theta, sigma = sigma, observed = sim_data.T)
with m:
trace = pm.sample()
And the error is:
SamplingError: Initial evaluation of model at starting point failed!
Starting values:
{'mu': array(0.), 'sd_log__': array(-2.30258509), 'raw': array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]), 's_mu': array(0.), 's_sd_log__': array(-2.30258509), 's_raw': array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])}
Initial evaluation results:
mu -0.92
sd_log__ -4.36
raw -9.19
s_mu -0.92
s_sd_log__ -3.85
s_raw -9.19
y -inf
Name: Log-probability of test_point, dtype: float64
So, How to solve this problem? Thank you very much.
Best,
Mq Guo