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

Particle marginal Metropolis Hastings Example #13

Merged
merged 4 commits into from Aug 3, 2017

Conversation

Projects
None yet
3 participants
@LeahPrice
Collaborator

LeahPrice commented Aug 3, 2017

Adding an example using particle marginal Metropolis Hastings. This example is based on a very similar model to pfNonlinBS. So that a single function can be used to simulate data from these models, the simNonlin function has been generalized and documentation updated accordingly.

LeahPrice added some commits Aug 2, 2017

Initialising logNC = 0
The log normalising constant estimate was not initialised to 0 (which causes problems when doing multiple SMC runs by calling Initialise() and Iterate() functions multiple times)
Adding PMMH example
Adding an example using particle marginal Metropolis Hastings. This example is based on a very similar model to pfNonlinBS. So that a single function can be used to simulate data from these models, the simNonlin function has been generalised and documentation updated accordingly.
@adamjohansen

This comment has been minimized.

Show comment
Hide comment
@adamjohansen

adamjohansen Aug 3, 2017

Collaborator

Hi Leah, thanks for this. This is a trivial thing, but it's likely to recur so I'll mention it...

There are a few more minor things popping up in the travis checks; nothing major, but it's a good idea to take notice of notes and warnings as they appear. Check out lines 900-905 in particular and see Dirk's commit bdc201c for a prototypical solution to this type of NOTE.

Collaborator

adamjohansen commented Aug 3, 2017

Hi Leah, thanks for this. This is a trivial thing, but it's likely to recur so I'll mention it...

There are a few more minor things popping up in the travis checks; nothing major, but it's a good idea to take notice of notes and warnings as they appear. Check out lines 900-905 in particular and see Dirk's commit bdc201c for a prototypical solution to this type of NOTE.

@adamjohansen

Good catch on the initialisation, this could have caused some subtle problems later on if you hadn't noticed this.

@LeahPrice

This comment has been minimized.

Show comment
Hide comment
@LeahPrice

LeahPrice Aug 3, 2017

Collaborator

Thanks Adam. I ran R CMD check on my computer and saw I didn't get any warnings so I'll have to make sure I look more closely at the Travis checks next time. Are lines 907-912 an issue too? I haven't touched the linear regression examples in this pull request so I'm not sure where that's coming from. I'm using Lazydata: TRUE so I might need to look into what else could be causing the warning. Are Travis checks only done for pull requests? I tried to find the checks from Dirk's most recent commit but I couldn't.

By the way, I wrote a message on the PMMH issue ticket this morning thanking you for your comments and saying I'd followed your advice with the cosine sequence offset. It seems it's been sitting on my computer all day, but I guess there's no point hitting send now.

Collaborator

LeahPrice commented Aug 3, 2017

Thanks Adam. I ran R CMD check on my computer and saw I didn't get any warnings so I'll have to make sure I look more closely at the Travis checks next time. Are lines 907-912 an issue too? I haven't touched the linear regression examples in this pull request so I'm not sure where that's coming from. I'm using Lazydata: TRUE so I might need to look into what else could be causing the warning. Are Travis checks only done for pull requests? I tried to find the checks from Dirk's most recent commit but I couldn't.

By the way, I wrote a message on the PMMH issue ticket this morning thanking you for your comments and saying I'd followed your advice with the cosine sequence offset. It seems it's been sitting on my computer all day, but I guess there's no point hitting send now.

@LeahPrice

This comment has been minimized.

Show comment
Hide comment
@LeahPrice

LeahPrice Aug 3, 2017

Collaborator

I realized I can just do --as-cran in my CMD check, so feel free to disregard my question about whether Travis checks are only done for pull requests.

Collaborator

LeahPrice commented Aug 3, 2017

I realized I can just do --as-cran in my CMD check, so feel free to disregard my question about whether Travis checks are only done for pull requests.

@adamjohansen

This is essentially there, but it would be good if you could resolve the NAMESPACE issue identified by travis, tweak any of the code that you want to in response to any of these rather trivial comments, and see if there's anything you can do about the identation/whitespace in your editor.

If it's too much of a pain to force your editor to indent consistently then it can be fixed later, it would just be nice to be as efficient as possible.

Show outdated Hide outdated man/pfNonlinBS.Rd
#include "nonLinPMMH.h"
namespace nonLinPMMH {
const double a_prior = 0.01;

This comment has been minimized.

@adamjohansen

adamjohansen Aug 3, 2017

Collaborator

Indentation seems a bit variable (cf. 27, 42 amongst others). This is easily fixable, but can your editor be persuaded to "do the right thing"?

@adamjohansen

adamjohansen Aug 3, 2017

Collaborator

Indentation seems a bit variable (cf. 27, 42 amongst others). This is easily fixable, but can your editor be persuaded to "do the right thing"?

This comment has been minimized.

@LeahPrice

LeahPrice Aug 3, 2017

Collaborator

I think I have fixed this now.

@LeahPrice

LeahPrice Aug 3, 2017

Collaborator

I think I have fixed this now.

This comment has been minimized.

@adamjohansen

adamjohansen Aug 3, 2017

Collaborator

Thanks. It looks much more consistent now. BTW I hope you didn't spend too much time on this as it can be done quite automatically (even if you don't like emacs, you can always use it occasionally for things like auto-indent, for example).

(I know things like this seem trivial but it's amazing how much more readable code is if it's indented in a consistent way and when you're working with a big code base it /really/ helps.)

@adamjohansen

adamjohansen Aug 3, 2017

Collaborator

Thanks. It looks much more consistent now. BTW I hope you didn't spend too much time on this as it can be done quite automatically (even if you don't like emacs, you can always use it occasionally for things like auto-indent, for example).

(I know things like this seem trivial but it's amazing how much more readable code is if it's indented in a consistent way and when you're working with a big code base it /really/ helps.)

Show outdated Hide outdated src/nonLinPMMH.cpp
Show outdated Hide outdated src/nonLinPMMH.cpp
Show outdated Hide outdated src/nonLinPMMH.cpp
@adamjohansen

This comment has been minimized.

Show comment
Hide comment
@adamjohansen

adamjohansen Aug 3, 2017

Collaborator

The data() NOTE is another small thing. I didn't mention it because, as you observe, it's unrelated to this pull request. It's nice if individual commits / pulls are coherent change sets.

It would, in the fullness of time, be worth cleaning this up in that it currently dumps the data into the global workspace which is bad practice because (a) the name might collide with something which is already there and (b) it will persist there until it's deleted. Using the "envir=environment()" parameter in the call to data might be sufficient to avoid this.

Dirk might have stronger views about data in R packages, but I'm largely agnostic as long as we don't do anything too antisocial (and putting stuff in a global workspace when it doesn't really need to be there might qualify as mildly antisocial).

Another think @eddelbuettel is better placed to answer, is whether we ought to do a bit of work to kill the notes at line 924 of the travis log (cf. RcppCore/Rcpp#636).

Collaborator

adamjohansen commented Aug 3, 2017

The data() NOTE is another small thing. I didn't mention it because, as you observe, it's unrelated to this pull request. It's nice if individual commits / pulls are coherent change sets.

It would, in the fullness of time, be worth cleaning this up in that it currently dumps the data into the global workspace which is bad practice because (a) the name might collide with something which is already there and (b) it will persist there until it's deleted. Using the "envir=environment()" parameter in the call to data might be sufficient to avoid this.

Dirk might have stronger views about data in R packages, but I'm largely agnostic as long as we don't do anything too antisocial (and putting stuff in a global workspace when it doesn't really need to be there might qualify as mildly antisocial).

Another think @eddelbuettel is better placed to answer, is whether we ought to do a bit of work to kill the notes at line 924 of the travis log (cf. RcppCore/Rcpp#636).

Minor changes
Correcting indentation in nonLinPMMH.h and nonLinPMMH.cpp, storing vectors for random component of RW and correcting authors in simNonlin and nonLinPMMH.
@LeahPrice

This comment has been minimized.

Show comment
Hide comment
@LeahPrice

LeahPrice Aug 3, 2017

Collaborator

I tried using envir=environment() and the NOTE doesn't appear anymore. Thanks for this fix. If @eddelbuettel is also happy with this, then I'll update it in a separate pull request. I have the news file updated too and ready for a future pull request.

Collaborator

LeahPrice commented Aug 3, 2017

I tried using envir=environment() and the NOTE doesn't appear anymore. Thanks for this fix. If @eddelbuettel is also happy with this, then I'll update it in a separate pull request. I have the news file updated too and ready for a future pull request.

@eddelbuettel

This comment has been minimized.

Show comment
Hide comment
@eddelbuettel

eddelbuettel Aug 3, 2017

Collaborator

Yes, it is good practice to run R CMD check --as-cran. You can also tell you system to do it (ie if you use RSrudio) and/or just do it by hand. "Real submissions" also have to do it via the R-devel version which is often pickier still (and you get access to that for free via win-builder and/or R-hub if you don't have R-devel built locally).

I'll merge this now and take a look later.

Collaborator

eddelbuettel commented Aug 3, 2017

Yes, it is good practice to run R CMD check --as-cran. You can also tell you system to do it (ie if you use RSrudio) and/or just do it by hand. "Real submissions" also have to do it via the R-devel version which is often pickier still (and you get access to that for free via win-builder and/or R-hub if you don't have R-devel built locally).

I'll merge this now and take a look later.

@eddelbuettel eddelbuettel merged commit fe4ea98 into rcppsmc:master Aug 3, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@LeahPrice LeahPrice deleted the LeahPrice:examplePMMH branch Aug 4, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment