Closed sammosummo closed 8 years ago
Which back end are you using? The DIC calculation uses the model's db.trace()
, so you could go in and truncate the chains manually, via something like:
model._trace[chain] = model._trace[chain][burn:]
I'm using the pickle backend.
This seems to work (at least, it produces slightly different DIC values after removing some of the leading samples). For the record, I used something like this:
stochastics = m.get_stochastics()
for node in stochastics.node:
node.trace._trace[0] = node.trace._trace[0][burn:]
Where m
is my model and burn
is the number of leading samples removed. Does this match up with what you were suggesting?
Yup. Glad it worked. Doing this sort of thing will be much easier in PyMC3.
The _trace member is for ram and pickle databases, right? How would you do this with an hdf5 database? Also, if my model has deterministics, can I truncate them the with the same method?
Deterministics work the same way; traces are the same regardless of node type.
The HDF5 backend is a little more complicated, so you don't have direct access to the trace values as you do with other backends. Have a peek at the pymc/database/hdf5.py
source to see how PyMC interacts with HDF5.
I recently ran some models and found my burn-in to be insufficient. Is it possible to remove samples from my chains and then re-calculate DIC? The models took about a week, so it's not convenient to re-run them.