Understanding multilevel model coefficients

Hi Matsuo,

I think they are two different means. They should usually be close but you shouldn’t expect them to always match.

The az_res.loc[“p[0]”, “mean”] is the mean of the mcmc samples. As the model samples parameters, it pushes those samples through the link function to get samples of p. Then we can just summarize the distribution of those samples with a mean (or an HDI, if you like).

For p0_res, you averaged the samples for each parameter and then pushed those averages through to get the answer. So p0_res shouldn’t have an HDI because it’s not a distribution.

One way the averages can come apart is if there are a few extreme or unusual samples sitting around in the posterior distribution for a or b or g. in the az_res.loc[“p[0]”, “mean”] case, those extreme values get pushed through to make more extreme values in p. But when you average earlier on in the process with p0_res, odd features of the posterior distribution can disappear. Anyway, I think it’s better to push the whole distribution of a, b, & g through to find out about the behavior of p.

2 Likes