Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commonly used adaptation methods #20

Merged
merged 2 commits into from Aug 7, 2017

Conversation

@LeahPrice
Copy link
Collaborator

@LeahPrice LeahPrice commented Aug 7, 2017

Adding a class containing commonly used parameters and methods to adapt them (for static Bayesian models).

Adding a class containing commonly used parameters and methods to adapt them (for static Bayesian models).
Copy link
Collaborator

@eddelbuettel eddelbuettel left a comment

Nice -- you are clearly getting the drift of incremental value-added PRs. We're in a good spot now.

I'll wait for Adam to peek at this tomorrow though before I merge.

Copy link
Collaborator

@adamjohansen adamjohansen left a comment

This looks good to me.

There are a few small things it might make sense to tweak, particularly in the acceptProb comparisons (not that I'd expect these to have any significant impact).

/// \param desiredCESS The target conditional ESS for the next temperature (generally fixed).
void staticModelAdapt::ChooseTemp(const arma::vec & logweight, const arma::vec & loglike, double desiredCESS) {
double temp_curr = temp.back();
if (CESSdiff(logweight,loglike,1-temp_curr,desiredCESS)>=0){

This comment has been minimized.

@adamjohansen

adamjohansen Aug 7, 2017
Collaborator

Might it make sense for the comparison to be with -0.01 (or the tolerance) to be consistent with the inner workings of the bisection function?

m = (a+b)/2.0;
f_m = CESSdiff(logweight,loglike,m-curr,desiredCESS);
err = 10;
while (err > 0.01){

This comment has been minimized.

@adamjohansen

adamjohansen Aug 7, 2017
Collaborator

It might be good if it were possible to choose this tolerance without changing a hard-coded constant. In some applications the desired CESS might be larger than 0.99 and a tolerance of 0.01 would be problematic in those settings.

This comment has been minimized.

@LeahPrice

LeahPrice Aug 7, 2017
Author Collaborator

Thanks Adam for this and for all of your other good points. I should have picked up on at least some of these myself -- sorry about that. I've changed this and a couple of other minor things (like writing 1.0 instead of 1 if it's a double) and will do another commit when the check finishes.

/// \param desiredAcceptProb The desired probability of a successful move for each particle.
/// \param initialN The initial number of MCMC repeats.
/// \param maxReps The maximum number of MCMC repeats.
int staticModelAdapt::calcMcmcRepeats(double acceptProb, double desiredAcceptProb, int initialN, int maxReps){

This comment has been minimized.

@adamjohansen

adamjohansen Aug 7, 2017
Collaborator

It's a bad idea to compare doubles with integers using ==, usually (the finite precision issue), might it make sense to replace these comparisons with
abs(acceptProb - 1) <= 10**-9
or similar?

@adamjohansen
Copy link
Collaborator

@adamjohansen adamjohansen commented Aug 7, 2017

Great, thanks.

@eddelbuettel eddelbuettel merged commit 6ff9b33 into rcppsmc:master Aug 7, 2017
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@LeahPrice LeahPrice deleted the LeahPrice:StaticModelAdaptation branch Aug 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.