I want to check the initial value used during the iteration from a stanfit. I could get an iteration value list using get_inits(Myfit, iter=N). However, if I don’t specify the iteration number, the function get_inits(Myf it, iter=NULL) returns an empty list.
I have tried two stanfit, but both of them show the same problem.
For the first fit, I didn't specify the init and here is my code:
first_round <- stan_code$sample(cor_dat,seed = 1234,
chains = 2,
iter_warmup = warmup,
iter_sampling = sampling,
save_warmup=T,
parallel_chains = 2,
threads_per_chain = 4,
show_messages = F,
sig_figs=18,
refresh = 0,
output_dir="test_round")).
For the second one, I'm using a function from this post: https://discourse.mc-stan.org/t/saving-reusing-adaptation-in-cmdstanr/19166/51 and restart from what stopped for the first round. Here is the code for my second round:
second_round <- stan_code$sample(cor_dat,seed = 1234,
chains = 2,
iter_warmup = warmup,
iter_sampling = sampling,
save_warmup=T,
adapt_engaged = F,
inv_metric=first_round$inv_metric(matrix=F),
step_size=first_round$metadata()$step_size_adaptation,
init=createStanInitsPreviousRun(first_round),
parallel_chains = 2,
threads_per_chain = 4,
show_messages = F,
sig_figs=18,
refresh = 0,
output_dir="test_round"))
As I mentioned eariler, both of these stanfits return empty list for get_inits(stanfit, iter=NULL) but works for get_inits(stanfit, iter=N). N is number for nth iteration.
Doess anyone know why this happens?
Thanks!