GithubHelp home page GithubHelp logo

seir's Introduction

seir

This package demonstrates use of the odin, dust and mcstate R packages for running stochastic SIR and SEIR models and fitting them to simulated data [1]. See also the SIR model odin.dust vignette and mcstate vignette.

Requirements

The package requires the following versions of the eigen1, odin, dust, odin.dust and mcstate packages to be installed:

eigen1 0.1.3
odin 1.5.10
dust 0.15.1
odin.dust 0.3.10 
mcstate 0.9.20

These can be installed in R with:

remotes::install_github(c(
  "mrc-ide/[email protected]",
  "mrc-ide/[email protected]",
  "mrc-ide/[email protected]",
  "mrc-ide/[email protected]",
  "mrc-ide/[email protected]"))

The vignettes use the coda package, which can be installed from CRAN with:

install.packages("coda")

Installation

Install the package with:

remotes::install_github("LloydChapman/seir", upgrade = FALSE, build_vignettes = TRUE)

References

  1. FitzJohn RG, Knock ES, Whittles LK, Perez-Guzman PN, Bhatia S, Guntoro F, Watson OJ, Whittaker C, Ferguson NM, Cori A, Baguelin M, and Lees JA. Reproducible parallel inference and simulation of stochastic state space models using odin, dust, and mcstate. Wellcome Open Research, 5:288, 12 2021. doi:10.12688/wellcomeopenres.16466.2

seir's People

Contributors

adamkucharski avatar lloydchapman avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

seir's Issues

Particle filter trajectories all the same

In fit_seirdage.Rmd, the particle filter seems to generate identical trajectories for all particles in this line of code.

This lack of stochastic variation between particle trajectories is also apparent in the pMCMC, which seems to only capture parameter uncertainty, rather than the reconstructed trajectory from the filter:
Screenshot
I wondered if it might be something to do with seed=1 defined in the earlier model, but the later filter and pMCMC uses underlying seirdage, so this shouldn't be the problem?

The original odin model has random draws between transitions, so not clear to me why the simulations aren't different โ€“ but I'm probably missing something obvious!

Improving data/variable object readability

There are a few places in where could make data objects more user friendly, e.g. with the iterative simulation below. Maybe the array could have named dimensions to avoid having to rely on numeric indexing later on? Could also explore use of Map or similar to streamline these loops (e.g. as in {finalsize} vignettes).

# Create an array to contain outputs after looping the model.
# Array contains XX rows = Total S, E, I, R (4), and
# in each age compartment (XX) as well as the cumulative incidence (XX)
x <- array(NA, dim = c(seird_age_model$info()$len, 1, n_steps+1))

# For loop to run the model iteratively
x[ , ,1] <- seird_age_model$state()
for (t in seq_len(n_steps)) {
    x[ , ,t+1] <- seird_age_model$run(t)
}

It may depend a bit on how odin.dust is structured, but also wondered if it was possible to reduce reliance on numeric indexing in the state variables, e.g. in this line of code?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.