I have hit a wall trying to construct a particular model, and I wanted to ask for some help troubleshooting this. I am making a model which calculates probabilities from a normal CDF with mean/sd that are PyMC3 distributions. I transform those probabilities and try to use those as the parameters for an output distribution. Whenever I try to sample from that distribution I quickly receive the “ValueError: Mass matrix contains zeros on the diagonal.” error.

I simplified the model down as far as I could while still getting this error. I can sample through my function and generate what looks to be perfectly fine samples of the u/“spprop2” variable, but as soon as I try to use that as a parameter for a subsequent distribution this error occurs. Most of the hits for this error seem to be about overflows resulting from extreme priors. I don’t have any observedRVs in my model at this point, and everything up to the K distribution behaves like I would expect and the samples of u look perfectly fine and don’t seem like they would cause any overflows.

I would appreciate any feedback on this and ideas about how to resolve this error.