if (FALSE) {
# Build a simulator for an SIR model
reactions <- c('S [beta * S * I] -> I',
'I [gamma * I] -> R')
sir.simu <- build_simulator(reactions = reactions)
# Run a simulation of a trajectory
sir_traj <- sir.simu(paramValues = c(gamma = 1, beta = 2e-4),
initialStates = c(I = 1, S = 9999, R = 0),
times = c(0, 20), ,
method = "exact",
seed = 166)
# The output is a named list containing the trajectory, the algorithm used,
# the parameter values and the reactions of the model.
names(sir_traj)
# Print head of the simulated trajectory
head(sir_traj$traj)
# Plot the trajectory
plot(sir_traj)
}
Run the code above in your browser using DataLab