fix bugs in iubf when faced unintended input #28
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi Developers,
Recently I have been using iubf for optimising parameters in a spatPomp model. I find some codes in the
iubf
function did not behave as expected with some particular input. Here I propose changes in a few lines in theR/iubf.R
to fix potential bugs.log_cond_densities[neighbor_u, ]
on this line will cause "out of bounds" error whenNrep_per_param = 1
. So I added a check for this, otherwise we may consider forcingNrep_per_param
to be greater than 1.The$t_0$ , when all observations are at the initial condition and adjusting parameters does have effect on the dmeasure results. A
def_resample
on this line can result in a NULL vector (vector of length 0), if allparam_resamp_log_weights
are the same. This can happen e.g. fordef_resample
of length 0 will cause error when sampling it on this line. To fix this, I added a check testing the length ofdef_resample
.Still for the same code chunk as mention in the previous point, there is a special case need to be addressed when$3$ , rather than resampling ${1, 2, 3}$ , for multiple times. To fix this, I added a special case for
length(def_resample) = 1
. Thesample
function will behave differently if the input is an integer of length 1, comparing to when usually we expect the inputdef_resample
is a vector of length > 1. For example whendef_resample
equals to an index3
, we want resamplinglength(def_resample) = 1
here.Please review if this can be helpful. Thank you so much again for this package.
Best,
Haogao