Hello all,
I am not sure if it’s a bug or no, but when I used pathfinder to set initial conditions as it is described in the manual of cmdstan, one of my variables was the weight for the mixture model, given by a simplex. However, I got the following error after setting my initial values:
Error evaluating the log probability at the initial value or it could be the rounding error when I used cmdstan.write_to_json command.
Exception: stan::math::simplex_free:
Simplex variable is not a valid simplex.
sum(Simplex variable) = 0.9999997, but should be 1
So it looks like pathfinder does not sum the simplex to one or it could the rounding error when I used the cmdstan.write_to_json command
This is a more general issue with the numerics. simplex_free
says the errors in the initialization transform, which is going to check you have given it a simplex to about single precision. So you need to provide more digits of precision in the input (at least 8, but it may take a bit more). How this all gets configured is going to depend on the interface you’re using.
1 Like
Thanks also for reporting. I should have also added that the current (edit: default) configuration is probably too strict for this kind of user input.
We could change the behavior so that on user inputs it uses less precision in its checks on validity and the renormalizes by dividing by sum to get a double-precision simplex for internal use.
1 Like
I had used the option in CmdStanR before, but it still took my more than five minutes to find the correct option name to be added to Pathfinder call sig_figs=14
, so it’s not a well documented feature.
I made an issue about improving doc Add to Stan CSV format doc that the number of digits can be changed · Issue #783 · stan-dev/docs · GitHub
2 Likes
Many thanks for your reply and even filling the request!
pathfinder_fit = model.pathfinder(data=stan_data_file, seed=100, sig_figs=14)
definitely works - thanks!