MyNixOS website logo
Description

Toolkits to Develop Individual-Based Models in Infectious Disease.

It provides a generic set of tools for initializing a synthetic population with each individual in specific disease states, and making transitions between those disease states according to the rates calculated on each timestep. The new version 1.0.0 has C++ code integration to make the functions run faster. It has also a higher level function to actually run the transitions for the number of timesteps that users specify. Additional functions will follow for changing attributes on demographic, health belief and movement.

README.Rmd

Tools for Individual-Based Models in Infectious Disease

I have been developing an individual-based model to derive the cost-effective strategies to target malaria hotspots and eliminate malaria in Myanmar. In order to explore as many model structures as possible, I'm developing this tools which are generic enough to be used in any individual-based model for any infectious disease. At this moment, the package has 2 generic functions.

  1. Create a synthetic population having several states.

This function populates a matrix in which columns represent the states of the individuals and rows represent the individuals. Making it a generic function will let you explore as many disease state as you want. This is expecially useful when you're comparing your IBM with your ODE model.

library(ibmcraftr)
syn_pop(c(3,2,1)) # will populate 3 individuals in state 1, 2 in state 2 and 1 in state 3.
#>      [,1] [,2] [,3]
#> [1,]    1    0    0
#> [2,]    1    0    0
#> [3,]    1    0    0
#> [4,]    0    1    0
#> [5,]    0    1    0
#> [6,]    0    0    1
  1. Make state transitions.

Using the state matrix of a population created previously, calculate the transitions from one state to other state(s) using the transition rate(s). This version has stRCPP function which is based on the codes in C++ to make it run faster.

pop <- syn_pop(c(19,1,0,0))
state_trans(1,2,.1,pop) #state transition from 1 to 2, at rate .1
#>       [,1] [,2] [,3] [,4]
#>  [1,]    0    0    0    0
#>  [2,]    0    0    0    0
#>  [3,]    0    0    0    0
#>  [4,]    0    0    0    0
#>  [5,]    0    0    0    0
#>  [6,]   -1    1    0    0
#>  [7,]    0    0    0    0
#>  [8,]    0    0    0    0
#>  [9,]    0    0    0    0
#> [10,]    0    0    0    0
#> [11,]    0    0    0    0
#> [12,]    0    0    0    0
#> [13,]    0    0    0    0
#> [14,]    0    0    0    0
#> [15,]    0    0    0    0
#> [16,]    0    0    0    0
#> [17,]    0    0    0    0
#> [18,]   -1    1    0    0
#> [19,]    0    0    0    0
#> [20,]    0    0    0    0
stRCPP(1,4,100,pop) #state transition from 1 to 4, at rate 100
#>       [,1] [,2] [,3] [,4]
#>  [1,]    0    0    0    0
#>  [2,]   -1    0    0    1
#>  [3,]   -1    0    0    1
#>  [4,]   -1    0    0    1
#>  [5,]   -1    0    0    1
#>  [6,]   -1    0    0    1
#>  [7,]    0    0    0    0
#>  [8,]    0    0    0    0
#>  [9,]   -1    0    0    1
#> [10,]    0    0    0    0
#> [11,]   -1    0    0    1
#> [12,]    0    0    0    0
#> [13,]   -1    0    0    1
#> [14,]   -1    0    0    1
#> [15,]   -1    0    0    1
#> [16,]    0    0    0    0
#> [17,]   -1    0    0    1
#> [18,]    0    0    0    0
#> [19,]   -1    0    0    1
#> [20,]    0    0    0    0
  1. Make state transitions for 'n' number of timesteps.

run_state_trans function organizes how the transitions are calculated for the specified number of timesteps.

 pop <- syn_pop(c(19,1,0,0,0)) #synthesizing population
 b <- 2 #effective contact rate
 param <- list(
 list(1,c(2,5),c(NA,.1)), #transition from state 1 to 2 using FOI lambda
 list(2,3,100), #transition from state 2 to 3,
 list(3,4,100)  #the 3rd term ensures the transition to the next stage
 )

 timesteps <- 10
 transient <- c("param[[1]][[3]][1] <- rate2prob(b*sum(pop[,2],pop[,3])/sum(pop))")
 eval(parse(text=transient))

 run_state_trans(timesteps, param, pop, transient)
#>       [,1] [,2] [,3] [,4] [,5]
#>  [1,]   18    1    1    0    0
#>  [2,]   13    2    1    0    4
#>  [3,]   10    4    1    0    5
#>  [4,]    6    5    4    0    5
#>  [5,]    4    4    4    2    6
#>  [6,]    3    2    4    5    6
#>  [7,]    1    2    5    6    6
#>  [8,]    0    3    1   10    6
#>  [9,]    0    2    1   11    6
#> [10,]    0    2    0   12    6
 run_state_trans(timesteps, param, pop, transient, useC = FALSE)
#>       [,1] [,2] [,3] [,4] [,5]
#>  [1,]   16    1    1    0    2
#>  [2,]   10    3    1    1    5
#>  [3,]    5    6    2    2    5
#>  [4,]    2    5    5    3    5
#>  [5,]    0    2    8    5    5
#>  [6,]    0    0    6    9    5
#>  [7,]    0    0    2   13    5
#>  [8,]    0    0    2   13    5
#>  [9,]    0    0    1   14    5
#> [10,]    0    0    0   15    5
Metadata

Version

1.0.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows