How can we access/plot the warm up samples?

I would like to see what we’re the warm-up samples of the HMC algorithm to make sure it is starting in the right prior and see if converging to the posterior. How can I access the warm-up samples?

See my code attached.
fit_replays_1subj_simple.stan (1.8 KB)
sweep_fit_replays.py (14.4 KB)

Let me know if more information is needed.

you can do this with CmdStanPy:

  • run the sampler with argument save_warmup=True
  • once the sampler has completed the run, the accessor methods need argument inc_warmup=True

by default, the warmup draws are not saved.

CmdStanPy uses file-based output - it’s also possible to monitor the draws as they are produced by putting some kind of reader on the output CSV files - the joint log probability lp__ is the first column of the CSV file.

Thank you. I will look into that. Is there a way to do the same with pystan?

If you add save_warmup=True to your sample call, then the first num_warmup//num_thin values are warmup.

1 Like