Dear @clausherther,
Just some brief notes:
if sd_alpha and sd_beta are hyper-priors, their shape should probably be set to 1
. Unless: you intend to create [2 x 2] structures here, but maybe the following is better:
Indexing should work, but why don’t you separate the priors? That should make the model much clearer. I fear with the current construct, although shapes might match, the consecutive model operations leave some of these distributions without observation, thus they sample data-less.
I tend to use vector notation, and pm.math.dot
, because what you are doing here is vector/matrix algebra.
For example, if X_shared
is [100 x 2], then r
should be the following with shape=(1, n)
:
r = pm.Beta("r", alpha=alpha[0], beta=beta[0], shape=(1, n), testval=r_obs)
Then the dot product should be of correct shape. Also, sampling is much faster. This has to do with the fact that patsy/numpy matrices are very efficient and increas sampling speed drastically.
You can check this notebook, from a previous thread in this forum, and convert the patsy design matrices to theano.shared
. If I do have more time tomorrow, I’ll try to apply it to your example.
Cheers,
Falk