It’s an out-of-bounds indexing error. Somewhere in your code there is vec[i] such that i is zero or greater than the size of vector vec. Double-check all the vector indexes in your model and remember that while Python indexes start from 0 Stan indexing starts from 1 so they differ by one.
It looks like this is a failure with CmdStan’s diagnose method; not necessarily a problem with anything in your model.
did the call model.sample succeed or were there errors thrown by the sampler?
what is the result of adding print(fit) to the above code, before calling fit.diagnose?
which version of CmdStanPy?
does fit.summary return a similar error?
how about trying this:
sampler = fit.draws(). # if this fails, the output CSV are corrupt
sampler_diagnostics = fit.method_variables().
divergences = sampler_diagnostics['divergent__']
I somehow made the error go away and I can’t bring it back. I even tried to restore an old snapshot of my system from Friday, which was when I posted my first message above, but the error didn’t come back. I don’t even know how that’s possible.
For the record, I’m running Fedora 34, the output file was the CSV file produced by the sampler, I was running only one chain, so there was only one CSV file, and my favorite color is blue.