hi everyone
I’m starting to model some basic examples in pymc, but after adding the observed
parameter to one of the distributions, it changes the outcome similar to the question here my example is the following one:
with pm.Model() as model:
u1 = pm.Uniform("U_1", 0, 4) # prior 1
u2 = pm.Uniform("U_2", 0, 4)
det_1 = pm.Deterministic("delta", u1 -u2)
idata = pm.sample(1000, tune=1000, cores=1)
az.summary(idata)
outputs
mean sd hdi_3% hdi_97% mcse_mean mcse_sd ess_bulk ess_tail r_hat
U_1 2.012 1.138 0.203 3.929 0.028 0.021 1617.0 1049.0 1.0
U_2 2.030 1.181 0.216 3.990 0.030 0.022 1573.0 1158.0 1.0
delta -0.018 1.638 -3.104 2.947 0.041 0.036 1632.0 1398.0 1.0
which makes sense, I calculate the difference, a “deterministic” variable, based on the samples in both uniforms. Now I want to add some observations to the model for one of the uniforms
observed = [1,2,1,1,1,1,2,2,3,1,1,2,2,3]
with pm.Model() as model:
u1 = pm.Uniform("U_1", 0, 4) # prior 1
u2 = pm.Uniform("U_2", 0, 4, observed=observed)
det_1 = pm.Deterministic("delta", u1 -u2)
idata = pm.sample(1000, tune=1000, cores=1)
az.summary(idata)
now it outpts
mean sd hdi_3% hdi_97% mcse_mean mcse_sd ess_bulk ess_tail r_hat
U_1 2.007 1.131 0.154 3.856 0.039 0.027 822.0 888.0 1.0
delta[0] 1.007 1.131 -0.846 2.856 0.039 0.027 822.0 888.0 1.0
delta[1] 0.007 1.131 -1.846 1.856 0.039 0.027 822.0 888.0 1.0
delta[2] 1.007 1.131 -0.846 2.856 0.039 0.027 822.0 888.0 1.0
delta[3] 1.007 1.131 -0.846 2.856 0.039 0.027 822.0 888.0 1.0
delta[4] 1.007 1.131 -0.846 2.856 0.039 0.027 822.0 888.0 1.0
delta[5] 1.007 1.131 -0.846 2.856 0.039 0.027 822.0 888.0 1.0
delta[6] 0.007 1.131 -1.846 1.856 0.039 0.027 822.0 888.0 1.0
delta[7] 0.007 1.131 -1.846 1.856 0.039 0.027 822.0 888.0 1.0
delta[8] -0.993 1.131 -2.846 0.856 0.039 0.028 822.0 888.0 1.0
delta[9] 1.007 1.131 -0.846 2.856 0.039 0.027 822.0 888.0 1.0
delta[10] 1.007 1.131 -0.846 2.856 0.039 0.027 822.0 888.0 1.0
delta[11] 0.007 1.131 -1.846 1.856 0.039 0.027 822.0 888.0 1.0
delta[12] 0.007 1.131 -1.846 1.856 0.039 0.027 822.0 888.0 1.0
delta[13] -0.993 1.131 -2.846 0.856 0.039 0.028 822.0 888.0 1.0
which I think is some kind of “delta posterior for each sample”(?). I don’t really understand why it is giving n_observed
results, each delta[i]
represents an i
iteration after adding that observation to the posterior ? and how to compact the result in order to understand how the delta indicator will distribute after the observed data? why it gives you n_observed
results?
Also, after adding the observed
parameter into the U2
dist why does it disappear from the az.summary(idata)
? how can I see what the posterior would look like for U2
? doesn’t it just add more info to the model?
thanks