stan icon indicating copy to clipboard operation
stan copied to clipboard

"term_buffer = 0" leads to "# Step size = 1" in output csv

Open funko-unko opened this issue 4 years ago • 3 comments

Summary:

See title. A dense metric was used.

CSV header:

# stan_version_major = 2
# stan_version_minor = 26
# stan_version_patch = 1
# model = log_discourse_comp_model
# method = sample (Default)
#   sample
#     num_samples = 0
#     num_warmup = 150
#     save_warmup = 1
#     thin = 1 (Default)
#     adapt
#       engaged = 1 (Default)
#       gamma = 0.050000000000000003 (Default)
#       delta = 0.80000000000000004 (Default)
#       kappa = 0.75 (Default)
#       t0 = 10 (Default)
#       init_buffer = 50
#       term_buffer = 0
#       window = 100
#     algorithm = hmc (Default)
#       hmc
#         engine = nuts (Default)
#           nuts
#             max_depth = 10 (Default)
#         metric = dense_e
#         metric_file = /tmp/tmp_4y6duce/6sl8gfq4.json
#         stepsize = 1 (Default)
#         stepsize_jitter = 0 (Default)
# id = 6
# data
#   file = /tmp/tmp_4y6duce/32j_gv89.json
# init = /tmp/tmp_4y6duce/l2cfqou8.json
# random
#   seed = 123456
# output
#   file = /tmp/tmp_4y6duce/log_discourse_comp-202103181646-6-7quzdwmv.csv
#   diagnostic_file =  (Default)
#   refresh = 100 (Default)
#   sig_figs = -1 (Default)
#   profile_file = profile.csv (Default)
# stanc_version = stanc3 ea3a31b
# stancflags = 

CSV End

[...]
38.156,0.979962,0.381802,[...]
# Adaptation terminated
# Step size = 1
# Elements of inverse mass matrix:

Expected Output:

The step size should probably be different, something in the order of 0.381802.

See also this https://discourse.mc-stan.org/t/fitting-ode-models-best-efficient-practices/21018/80 Sorry for being terse.

Current Version:

v2.26.1

funko-unko avatar Mar 18 '21 15:03 funko-unko

warmup windows described here: https://mc-stan.org/docs/2_26/reference-manual/hmc-algorithm-parameters.html

Lastly, the fast parameters are allowed to adapt to the final update of the slow parameters.

if this update doesn't happen, then stepsize would remain at ??? iteration 50 (+- 1)

mitzimorris avatar Mar 18 '21 16:03 mitzimorris

All but the first few are generally in the same order.

For a different run (same configuration, this csv is gone) we have for 48-52

0.00409287
0.00555496
0.000998799
0.00161527
0.00242704

and for the last one 0.0035995, but again

# Step size = 1

funko-unko avatar Mar 18 '21 16:03 funko-unko

I suspect the term_buffer = 0 thing is doing it.

Like the stepsize is being reset at the end of a window with the assumption that there will be another window following.

Here is where the stepsize gets reset at the end of each warmup window: https://github.com/stan-dev/stan/blob/develop/src/stan/mcmc/hmc/nuts/adapt_diag_e_nuts.hpp#L35

A lot of the adaptation logic is here https://github.com/stan-dev/stan/tree/develop/src/stan/mcmc

bbbales2 avatar Mar 18 '21 17:03 bbbales2