MCMC with pauses


#1

I tried sampling a model that is already been sampled. However, when I plot the traceplot it shows the traces resulting from both samplings.

with model:
    trace = pm.sample(1000)
    trace = pm.sample(1000, trace = trace)

Is the resulting trace of above sampling equivalent to this,

 with model:
        trace = pm.sample(2000)

If I want to pause MCMC sampling and perform some other operations (such as PPC and calculate the WAIC) to the intermediate model, and then to resume the sampling again, can I use the above method? or what is the correct way of doing it?

Thanks


#2

It seems we can index the trace from 2nd method (trace[:1000]) instead of using the first method.

Using such traces we can obtain the statistics of the intermediate states of the model.


#3

Yes - the first method can be useful if you need to, for example, turn off a machine for whatever reason.

I actually use the slicing in imcmc to recover the (correlated) path that the Metropolis sampler uses when sampling (specific code is around here, where vals is a list of traces).