seabbs / idmodelr

Infectious disease model library and utilities
http://samabbott.co.uk/idmodelr
GNU General Public License v3.0
15 stars 6 forks source link

PMCMC case study #34

Open seabbs opened 5 years ago

seabbs commented 5 years ago

Background

Vignette walking through the use of PMCMC modelling using a base R model but any other tools required.

Aim

Explain the basics of PMCMC and give directions to more resources. Based on the draft vignette package functionality will be expanded so that everything (excepting the actual PMCMC) can be reproduced using package code.

Method

Explain some of the workings of PMCMC, highlight tools that are available and point towards other tools (such as LibBi and POMP) that may be more appropriate for use in actual research. Link to recent paper that provides a more complete walkthrough.

Based on the draft vignette package functionality will be expanded and the vignette will then be updated to reflect this.

Links

What do you think @akira-endo?

seabbs commented 4 years ago

Just pinging you @akira-endo to see if you are still interested in this?

akira-endo commented 4 years ago

Just pinging you @akira-endo to see if you are still interested in this?

Yes, did you see the Twitter DM? Will try to draft contents soon.

seabbs commented 4 years ago

Awesome :smile: - sorry for the ping I'd missed the DM!

Just about to gear up for some more development work so sounds like good timing.

akira-endo commented 4 years ago

Hi, now an early draft is there for you to check: https://github.com/akira-endo/idmodelr/blob/master/vignettes/pmcmc.Rmd Mostly bullet points, but I wrote a full section (though still a rough draft) for the deterministic SIR model. This section is for intro/comparison to the stochastic SIR where PMCMC comes in. Regarding the functionality: if you are going to follow the epirecipe implementation of continuous-time stochastic SIR, I think no extra functionality is necessary to allow the use of PMCMC (because stochastic SIR has the memoryless property, continuing an ongoing simulation run is no different from starting a new one). DM me if you have questions/comments.

seabbs commented 4 years ago

First of all thanks for doing this! Secondly, in general all looking very good. Some more detailed comments below.

Introduction

Deterministic SIR

Stochastic model

Side note: I'm going to be starting a postdoc at LSHTM working with Seb Funk at the beginning of January so potentially we can discuss this in person. Planning to go for a JOSS review at the end of January so should be doing more work on this asap.

akira-endo commented 4 years ago

S(t) notation This is just to be consistent with S(t_n) used in the later part (usually I also use the simpler format). Could remove (t) in this equation, but I rather prefer keeping a consistent style throughout.

HMP I will spell it out in the introduction.

MCMC alg We could do either: there are only two params so will be easy to write from scratch -- or I would consider {LaplacesDemon} if introducing an external package is preferable.

Stochastic model Not sure if I get what you say right, but yes I think combining the Gillespie alg with transition matrix sounds a good approach to handle stochastic time evolution while keeping it general. Maybe a function that takes (transistion matrix, initial states, parameters, time range to simulate) and returns (trajectory, final state, (+likelihood of the trajectory?)) will be good enough?

PMCMC alg MCMC part might again be passed on to an external package, but I think SMC part would be easier to read without a package that could hide the most important part of the alg behind.

Side note That's great! See you then, or, if you're also coming to Charleston next week we could also have a chat.

seabbs commented 4 years ago
  1. S(t) notation - okay fair enough.

  2. HMP - thanks

  3. MCMC alg - So I am a little torn on this. On one hand making things as simple as possible is attractive - so going with writing from scratch. On the other hand if people are going to do this in practice they probably want to use a package. Perhaps writing from scratch to demonstrate and show the equivalent approach using an MCMC package?

  4. Stochastic model - yes you've got it. Agree on the functional setup.

  5. PMCMC alg - Agreed on SMC point. As above perhaps offering both might be a nice solution.

  6. Side note - Not going unfortunately 😢

akira-endo commented 4 years ago

Hi, just committed the main text draft (without codes). https://akira-endo.github.io/idmodelr/vignettes/pmcmc.html

Let me know if you have comments/suggestions. And now we can focus on the scripts: I'll first try to write the code leaving the {idmodelr} component blank (I'm not yet much used to the API so just to start off with). Then maybe we could discuss stochastic SIR implementation?

Thank you.

seabbs commented 4 years ago

Happy new year!

Sorry for the delay getting back to you on this - took a tech break over Christmas.

This is very good - great job. In general I would say this is some of the clearest writing on model fitting in R I have seen.

Comments:

I think that there could be a little more detail in the final PMCMC section (though obviously the code is missing). Potentially pulling out the steps into bullets might help a little?

Across the board figures could do with being larger + higher def.

I think you could more vigorously promote your own work beyond just a single mention of the paper in the intro :)

Optionally the text could have a slightly more relaxed style (as not a paper) but this is very much not a required change.

I guess the blocker now is stochastic model support for idmodelr. I’d be happy to see any suggested implementations from you or I can hopefully get around to this starting next week (when the tech break ends!). As I think we discussed I think it makes sense to use a two part structure - transition matrix + solving alg.

Looking forward to merging this into the package and getting on with submitting to JOSS in the next month or so. Very happy for any additional suggests for package features etc or just straight up implemented features. If your interested in doing any package work but feel blocked by wondering how the hell packages work let me know and I can hopefully enlighten.

Sam

-- sam abbott

On 23 December 2019 at 20:28:28, akira-endo (notifications@github.com) wrote:

Hi, just committed the main text draft (without codes). https://akira-endo.github.io/idmodelr/vignettes/pmcmc.html

Let me know if you have comments/suggestions. And now we can focus on the scripts: I'll first try to write the code leaving the {idmodelr} component blank (I'm not yet much used to the API so just to start off with). Then maybe we could discuss stochastic SIR implementation?

Thank you.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/seabbs/idmodelr/issues/34?email_source=notifications&email_token=AE3ALUN2XHMJYQEFLFGWVJDQ2ENOZA5CNFSM4JF2YDIKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHR4BDQ#issuecomment-568574094, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE3ALUJG4P5ZPFRKDWKNG3DQ2ENOZANCNFSM4JF2YDIA .

seabbs commented 4 years ago

Morning Akira,

What do you think about (a slightly cleaner) version of this approach for stochastic models?

https://cran.r-project.org/web/packages/adaptivetau/vignettes/adaptivetau.pdf