I am trying to model the problem below, which is very similar to the example posted here. The sampling runs fine but the traceplot fails with error: ValueError: cannot convert float NaN to integer
. The only thing I can think of is that in the trace summary az.summary(trace, var_names=["~L"],hdi_prob=0.95,round_to=2)
the r_hat
for the first entry of the correlation matrix is NaN. Is there any way to get traceplot to ignore this? or is there something else going wrong here?
Many thanks
import numpy as np
import pymc3 as pm
import arviz as az
#generate synthetic data set
n = 500
mu = np.array([0,0])
sigma1 = 2
sigma2 = 1.5
r = -0.7
Sigma = np.reshape([sigma1**2,r*sigma1*sigma2,r*sigma1*sigma2, sigma2**2],(2,2))
D = np.random.multivariate_normal(mu,Sigma,size=n)
#model with pymc3
with pm.Model() as model:
L,R,sigma = pm.LKJCholeskyCov('L', n=2,
eta=1., sd_dist=pm.HalfCauchy.dist(1),compute_corr=True)
mu = pm.Normal('$\mu$',0,1.5,shape=2,testval=0)
cov = pm.Deterministic('$\Sigma$', L.dot(L.T))
likelihood = pm.MvNormal('obs', mu=mu, chol=L, observed=D)
warnings.filterwarnings("ignore")
trace = pm.sample(1000,chains=4,cores=2,progressbar=True,random_seed=1,\
init="adapt_diag")#, return_inferencedata=True)
az.plot_trace(
trace,
var_names=["~L"],
compact=True,
);