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

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Great, thanks.

@eddelbuettel eddelbuettel merged commit 6ff9b33 into rcppsmc:master Aug 7, 2017
@LeahPrice LeahPrice deleted the StaticModelAdaptation branch August 7, 2017 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants