Coder Social home page Coder Social logo

sir's Introduction

sir - package for running stochastic SIR models

Project Status: Concept โ€“ Minimal or no implementation has been done yet, or the repository is only intended to be a limited example, demo, or proof-of-concept.

About

The models in this package are generated by odin. I hope this isn't cheating, considering they're lifted straight out of the examples there!

Installation

Install from GitHub with devtools::install_github("hillalex/sir") or clone this repo and run R CMD INSTALL .

Quick start

To run 100 simulations of a discrete time step stochastic SIR model with infection rate 0.2, recovery rate 0.1, 1000 susceptible individuals and 1 infectious individual at time 0:

sir::run_model(1:100, nsim = 100, beta = 0.2, sigma = 0.1, S_ini = 1000, I_ini = 1)

To automatically plot the results include plot = TRUE. See the man directory for complete function documentation.

Testing

Broadly speaking I can think of 3 approaches to testing:

  • unit tests - Test any deterministic logic; mock stochastic elements or use set seeds where needed. Include regression tests against known working versions of a model.
  • statistical tests - Use what's known about the expected distribution of results to write probabilistic tests. In this example we know a lot about the dynamics of the model already but in general this is presumably not the case, e.g. there won't usually be a nice analytical solution to compare to.
  • manual tests - Build tooling that facilitates manual review of model outputs (e.g. can CI auto-generate reference plots for visual inspection)

The test directory here includes some simple smoke tests and unit tests (trivial since there is very little internal logic here), and then some more speculative attempts at validating the model dynamics in test-stochastic.R. A domain scientist who understood the model dynamics better than me could likely generate some better ideas for the latter.

To run tests locally from this directory:

testthat::test_local(".")

Further development ideas

  • Fleshing out the testing, including CI, ideas for tooling around manual tests
  • Extending the interface, e.g. with a GUI
  • Expanding the documentation

sir's People

Contributors

hillalex avatar

Watchers

 avatar

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.