MCMCChains.jl icon indicating copy to clipboard operation
MCMCChains.jl copied to clipboard

Support for short chains?

Open mmattocks opened this issue 4 years ago • 2 comments

Hello! I am attempting to use MCMCChains to help with chains of HMMs optimized by EM. Performing the heideldiag tests on the autotransition probabilities is a reasonable way to assess stationarity, so I have been using that programmatically in my training of HMM "zoos" using my package BioBackgroundModels. Simple HMMs (one state) have very short chains (simply solving for the proportion of symbols in the observations), but are nonetheless of practical and theoretical interest. Howevre, the heideldiag function fails for chains under 10 steps for two reasons; the while loop delta for these short chains is calculated as zero: delta = trunc(Int, 0.10 * n)

Additionally, I have found that the msce() call fails for very short chains (4 steps), as m = div(n - lag, 2) can evaluate to zero and a negative value can be passed to sqrt(). This second problem seems more significant, as I don't know whether it is possible or desireable to evaluate an eg. imse score for a chain this short. I open this issue anyway in case supporting short chains is possible. For now I will avoid testing these chains.

mmattocks avatar Jun 26 '20 19:06 mmattocks

Hello! I am attempting to use MCMCChains to help with chains of HMMs optimized by EM. Performing the heideldiag tests on the autotransition probabilities is a reasonable way to assess stationarity, so I have been using that programmatically in my training of HMM "zoos" using my package BioBackgroundModels. Simple HMMs (one state) have very short chains (simply solving for the proportion of symbols in the observations), but are nonetheless of practical and theoretical interest. Howevre, the heideldiag function fails for chains under 10 steps for two reasons; the while loop delta for these short chains is calculated as zero: delta = trunc(Int, 0.10 * n)

I'm not very knowledgeable in the use of EM, but I also don't see how you would want to run diagnostics on a chain this short or even how the method applies to MCMC. Heidelberger-Welch is for assessing the stationarity of a Markov chain, not a finite set of draws of parameter values.

Additionally, I have found that the msce() call fails for very short chains (4 steps), as m = div(n - lag, 2) can evaluate to zero and a negative value can be passed to sqrt(). This second problem seems more significant, as I don't know whether it is possible or desireable to evaluate an eg. imse score for a chain this short. I open this issue anyway in case supporting short chains is possible. For now I will avoid testing these chains.

I don't think this can or should be fixed, since this is a mathematical limitation and not a programmatic one.

cpfiffer avatar Jun 28 '20 14:06 cpfiffer

Yes, this makes sense. It may be of some value to include an assertion regarding the chain length in that case, it wasn't immediately clear why the while loop hang was happening in big batches of chains. Thanks for looking at this!

mmattocks avatar Jun 28 '20 19:06 mmattocks