Tuning proposal in Metropolis


#1

How can I provide a certain proposal width to my sampler and not let it change during the entire sampling?

I see that PyMC3 executes the following code to scale the proposal width. I don’t want this to happen and I would like to provide my own standard deviation for the normal distribution proposal. Is this possible?

if acc_rate < 0.001:
    # reduce by 90 percent
    scale *= 0.1
elif acc_rate < 0.05:
    # reduce by 50 percent
    scale *= 0.5
elif acc_rate < 0.2:
    # reduce by ten percent
    scale *= 0.9
elif acc_rate > 0.95:
    # increase by factor of ten
    scale *= 10.0
elif acc_rate > 0.75:
    # increase by double
    scale *= 2.0
elif acc_rate > 0.5:
    # increase by ten percent
    scale *= 1.1

In addition, I believe that the PyMC3 executes the above code only during the burn-in period. If yes, then after burn-in period what scaling factor does the sampler use? Is it the scaling value used in the last step of the burn-in period?


#2

Yes, you can do the following:

In [6]: S = np.asarray([2.5]) # <-- custom proposal sd
   ...: with pm.Model():
   ...:     ... # your model
   ...:     step = pm.Metropolis(S=S, tune=False)
   ...:     trace = pm.sample(1000, tune=0, step=step)

Yes


#3

Thank you for the reply.

If I let pymc3 auto chose my proposal standard deviation for metropolis stepping. How can I know the value of the standard deviation used by pymc3? Is there any attribute to access this information?


#4

Currently this diagnostic is not exposed - feel free to send a pull request to add it :wink: