The recursive summation here causes the number of dependent paths to explode and quickly hit the maximum integer when considering the number of dependent paths for each p[i] (starting with p[91] the number grows very quickly).
I think the best solution is:
Add a max arg to nimbleGraph::getDependencyPathCountOneNode so that it bails when it gets to that value, returning that value.
This is only used in conjugacy checking. I think we can save a bit of computation by having max be set equal to sum(deps) since that is what the result of the path counting is going to be compared against. As soon as we know that any of the values of numPaths is that big, we know what to do in terms of what approach to conjugacy checking to use.
In fact, if we wanted to use a for loop instead of sapply, we could bail out of the loop rather than running getDependencyPathCountOneNode for all the input nodes. Given the comment below and that we can cut things off when we get to sum(deps), which generally won't be that large, in most cases we won't save time, but it's probably worth doing for cases where we run nimbleGraph::getDependencyPathCountOneNode many times.
Interestingly even when the count gets as high as the max integer, it only takes 30 microseconds to run the recursion in getDependencyPathCountOneNode so efficiency is not much concern here if the function is only run a limited number of times.
I'm surprise we haven't run into this before given this occurred with only 90 elements.
@danielturek @perrydv I welcome any comments here.
A user reported this error (from
configurMCMC
incheckConjugacy_new
):The key part of the model structure causing this is
where
I_nDays=91
.The recursive summation here causes the number of dependent paths to explode and quickly hit the maximum integer when considering the number of dependent paths for each
p[i]
(starting withp[91]
the number grows very quickly).I think the best solution is:
max
arg tonimbleGraph::getDependencyPathCountOneNode
so that it bails when it gets to that value, returning that value.max
be set equal tosum(deps)
since that is what the result of the path counting is going to be compared against. As soon as we know that any of the values ofnumPaths
is that big, we know what to do in terms of what approach to conjugacy checking to use.sapply
, we could bail out of the loop rather than runninggetDependencyPathCountOneNode
for all the input nodes. Given the comment below and that we can cut things off when we get tosum(deps)
, which generally won't be that large, in most cases we won't save time, but it's probably worth doing for cases where we runnimbleGraph::getDependencyPathCountOneNode
many times.Interestingly even when the count gets as high as the max integer, it only takes 30 microseconds to run the recursion in
getDependencyPathCountOneNode
so efficiency is not much concern here if the function is only run a limited number of times.I'm surprise we haven't run into this before given this occurred with only 90 elements.
@danielturek @perrydv I welcome any comments here.