Access dust's built-in examples. These are compiled into the
package so that examples and tests can be run more quickly without
having to compile code directly via
dust(). These examples are
all "toy" examples, being small and fast to run.
The name of the example to use. There are five
sir: a basic SIR (Susceptible, Infected, Resistant)
epidemiological model. Draws from the binomial distribution to
update the population between each time step.
sirs: an SIRS model, the SIR model with an added R->S transition.
This has a non-zero steady state, so can be run indefinitely for testing.
volatility: A volatility model that might be applied to
currency fluctuations etc.
walk: A 1D random walk, following a Gaussian distribution each
logistic: Logistic growth in continuous time
dust_generator object that can be used to create a
model. See examples for usage.
# A SIR (Susceptible, Infected, Resistant) epidemiological model sir <- dust::dust_example("sir") sir # Initialise the model at time step 0 with 50 independent trajectories mod <- sir$new(list(), 0, 50) # Run the model for 400 steps, collecting "infected" every 4th time step times <- seq(0, 400, by = 4) mod$set_index(2L) y <- mod$simulate(times) # A plot of our epidemic matplot(times, t(drop(y)), type = "l", lty = 1, col = "#00000044", las = 1, xlab = "Time", ylab = "Number infected")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.