I am trying to create an observed variable in PyMC3 which has a multivariate normal distribution. I want the covariance matrix whose elements are other random variables. As an example, consider the following code:
import pymc3 as pm
with pm.Model() as model:
a = pm.Normal('a', mu=0, sigma=10)
b = pm.Normal('a', mu=0, sigma=10)
c = pm.Normal('a', mu=0, sigma=10)
# I recognize that the matrix is not positive definite
# with this parameterization. This is just a toy example.
# The main point is that I want the elements of the matrix
# to be random variables.
cov = [[a, b]
[b, c]]
data = pm.MvNormal('data', mu=[0, 0],
cov=cov, observed=obs)
This does not work. Neither does using np.array(cov)
. I imagine the solution is to use Theano tensors somehow. I am unable to figure out how to use them.
I'd appreciate any help with this. Thanks.