"ValueError: Mass matrix contains zeros on the diagonal" and "pymc3 the derivative of rv is zero"

with pm.Model() as model_groups:

μ = pm.Normal('μ', mu = 0 , sd = 10 , shape = groups)

σ = pm.HalfNormal('σ', sd = 10 , shape = groups)

y = pm.Normal('y' , mu = μ[idx] , sd = σ[idx] , observed = price)

trace_model_groups = pm.sample(2000, cores = 4, tune = 1000 , chains = 2)

Welcome @Jon! You can use “```python” at the start of your code block to format it nicely.

Without seeing your data it is hard say, but this can occur when the priors are too broad or a bad match with the data. A good practice is to do a prior predictive check before sampling, to see if your priors roughly encapsulate the domain of your data. A good explanation is here.