November 2016
Beginner to intermediate
282 pages
6h 58m
English
In the previous chapter, we learned the rudiments of hierarchical models. We can apply these concepts to linear regression and model several groups at the same time including estimations at the group level and estimations above the group level. As we saw, this is done by including hyperpriors.
We are going to create eight related data groups, including one with just one data point:
N = 20 M = 8 idx = np.repeat(range(M-1), N) idx = np.append(idx, 7) alpha_real = np.random.normal(2.5, 0.5, size=M) beta_real = np.random.beta(60, 10, size=M) eps_real = np.random.normal(0, 0.5, size=len(idx)) y_m = np.zeros(len(idx)) x_m = np.random.normal(10, 1, len(idx)) y_m = alpha_real[idx] + beta_real[idx] * x_m + eps_real
Our data ...
Read now
Unlock full access