I want to construct a correlation matrix explicitly from using the pymc.LKJCorr distribution class, but I don't trust my understanding of the pymc.expand_packed_triangular. Here is a minimal working example.
import arviz as az
import matplotlib.pyplot as plt
import numpy as np
import pymc as pm
with pm.Model() as model:
R_upper = pm.LKJCorr('LKJCorr', n=2, eta=2)
R = pm.expand_packed_triangular(n=2, packed=R_upper, lower=False)
corr = pm.Deterministic('RCorr', var=R + np.eye(2))
with model:
idata = pm.sample()
az.plot_trace(idata, combined=True)
plt.tight_layout()
plt.show()
Here is an example plot:
What doesn't make sense to me is the fact that I am seeing one of the RCorr parameters centered around one. That shouldn't be the case, and looks like it is just a translation of "LKJCorr" by unity. I am concerned that pm.expand_packed_triangular is assuming there is a diagonal when there isn't, or something like that.
How can I reconstruct the correlation matrix from using an instance of pymc.LKJCorr in this toy example?
