I don’t quite know, how pymc calculates the logp(), but is it possible that a chain runs into a region where (simulation - data)^2 becomes too large and causes and overflow so that logp() becomes NaN?
I tried running part of the code only and replaced all exp(x) with exp(x)/(1 + exp(x) so that it results in 0, if the exponential overflows. Now I get this error:
RuntimeWarning: invalid value encountered in scalar divide
(between_chain_variance / within_chain_variance + num_samples - 1) / (num_samples)
For some reason within_chain_variance seems to be zero now for at least one of the chains.