The sum of is_best is 1 as expected (of the n_players there should be one the best. ).
However, this is not the case for is_2nd_best and is_3rd_best
I don’t understand why the above works for is_best but not for the other two variables?
I also tried to define the variables as a a simplex, but then the script crashes (again at is_2nd_best and is_3rd_best)
Are you running the generated quantities separately after sampling? It’s a known issue that Stan writes to csv with 6 digit accuracy, but the simplex sum to 1 is making the check with 8 digit accuracy. You can increase the number of digits saved, but to give specific instructions it would help to know which interface you are using.
Regardless of whether the upstream parts of the model are doing what you want, is_best, is_2nd_best, etc can only contain the integers 0 and 1. Thus, it is impossible that the sum of is_2nd_best could ever be 0.7. Perhaps there is an error in how you take the sum?
What do you mean exactly? There are 7 players, so we see the correct shape of the output? fit.posterior.is_best.mean(dim=('chain', 'draw'))) is the correct syntax as I specify both chain and draw.
Its basically the equivalent of np.mean(a, axis=0 & 1)
It doesn’t make sense that the second player has a zero probability of being 2nd or 3rd. I think this is also causing the simplex to fail?