kidusasfaw / spatPomp

R package for statistical inference of spatiotemporal partially observed Markov processes
GNU General Public License v3.0
11 stars 9 forks source link

Possible improvements to example usage #26

Closed johnlees closed 1 month ago

johnlees commented 1 month ago

Current usage examples are detailed statistical PDFs, or source code. An improvement to users would be to consider adding one of these as a formal R package vignettes, at least for one of the listed resources. I think a simple example running the iterated block particle filter would be nice.

I was able to follow through the existing PDF (which has a lot of troubleshooting and plotting which is great), but some commands didn't work 'out of the box' e.g.:

Warning message:
In seq.default(from = 0.2, to = 0.8, length = 4) :
  partial argument match of 'length' to 'length.out'
Error: object 'U' not found

And the doParallel setup was not explicit

ionides commented 1 month ago

Thanks for the suggestions, @johnlees. I have added the package tutorial and the iterated block particle filter tutorial as formal R package vignettes. These are now in the GitHub version of spatPomp and will be pushed to CRAN in the next upload.

I have simply included the pdf tutorials as vignettes, to make sure they are found by people who look for help via vignettes on CRAN or through the package itself. There could be some advantage to putting the vignette source code into the package, but examples sufficient to demonstrate and validate the code are too computationally intensive for inclusion in the package. So, it seems appropriate to keep the source code for these vignettes in their own GitHub repos.

You noted that some of the code for the tutorial is hidden. I have added links to the full R script, extracted from the Rnw source using knitr::purl. This will be easier for readers than looking for code chunks in the source Rnw file. I have edited to make the code presented in the pdf slightly more self-sufficient. I have not made all the code explicit in the pdf, to balance the tradeoff between readability and inclusion of details. Readers who want to run the full code will find the R script more convenient than the pdf.

In spatPomp, the R documentation examples are mostly not run, and the reader is referred to the tests for complete tested example code. This is done to save time, since it takes a nontrivial time to compile the spatPomp model objects. For examples, one would have to re-build the model objects many times. For the tests, many functions can be tested on each model object.

Looking at your comments, I notice that ibpf did not have the usual spatPomp documentation examples (some un-run code, and a suggestion to look at the tests for more). ibpf was developed after most of spatPomp was already written, but it has recently been one of the most used functions. I have added documentation examples for it.

johnlees commented 1 month ago

Excellent, thank you for these comprehensive changes! I will update the JOSS review