How to set starting values

Based on the docs for sample, it seems like it might be possible via the argument “state”.

At the moment, we haven’t implemented a way to set the initial sampling values. We would very much welcome a PR on this


I’ve been looking into this and see that the chain is initialized in utils.initialize_sampling_state [here] and from this the mcmc starting values in the variable init are set at sampling.build_logp_and_deterministic_functions.

Unfortunately (from the standpoint of untransformed starting values) all initialization occurs in the transformed parameter space. It is straightforward to conditionally initialize parameters in the transformed space, but since users will most likely want to pass unconstrained start values, it isn’t clear how we can initialize in untransformed parameter space and and “transform forward” to initialize the unobserved parameters we are sampling.

I noticed that in line 27 of utils.initialize_sampling_state the full unconstrained and constrained state is generated and placed in state. My thought was to conditionally alter the unconstrained ones based on the supplied starting values (if any) and then apply the transformations for each distribution if necessary for the start values (this is what I am calling transform forward). Then I would pass the unconstrained and transformed state back to sampling to initialize the chain.

Nice idea @Rob_Hicks. You could also try and test what happens with the values that her set in the state when you pass a values dictionary to evaluate_model_transformed. Maybe it will already transforms backwards to the unconstrained space.