tests/testthat/stochastic/sir_discrete_stochastic.R

update(S) <- S - n_SI
update(I) <- I + n_SI - n_IR
update(R) <- R + n_IR

initial(S) <- S0
initial(I) <- 10
initial(R) <- 0

p_SI <- 1 - exp(-beta * I / N)
p_IR <- 1 - exp(-gamma)

n_SI <- rbinom(S, p_SI)
n_IR <- rbinom(I, p_IR)

## If order of operations matter
## > S1 <- S + ....
## > update(S) <- S1

S0 <- user(100)
beta <- user(0.1)
gamma <- user(0.1)

N <- S + I + R

Try the odin package in your browser

Any scripts or data that you put into this service are public.

odin documentation built on April 28, 2022, 9:05 a.m.