Description Usage Arguments Value Examples
An R function to perform an Agent Based Monte Carlo simulation of a Susceptible, Infected, Recovered (SIR) disease model with homogeneous mixing of the population. The function keeps track of who infected whom, and calculates the average number of descendant infections (ANDI) for the individuals infected in the outbreak
1 |
N |
The population size |
I_0 |
The initial number infected |
S_0 |
The initial number suscetible |
gamma |
The recovery rate |
R0 |
The reproduction number |
delta_t |
time step to solve model (if 0 then dynamically calculated time step used) |
list list of model compartment values vs time, and ANDI
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ## Not run:
require("ANDI")
require("deSolve")
N = 1000
I0 = 1
S0 = N-I0
gamma = 1
R0 = 1.5
set.seed(78998026)
a = SIR_agent(N,I0,S0,gamma,R0)
b = SIR_solve_model(N,R0,S0/N,0.1)
par(mfrow=c(1,1))
plot(a$time,a$I,xlab="Time",ylab="Prevalence",main=paste("R0=",R0," and N=",N,sep=""))
lines(b$results$time,b$results$I,col=2,lwd=4)
legend("topright",legend=c("ABMC","deterministic"),col=c(1,2),bty="n",lwd=4,cex=0.8)
cat("Est ANDI, ABMC and deterministic: ",round(mean(a$ANDI),1)," ",round(b$ANDI,1),"\n",sep="")
cat("Est final size, ABMC and deterministic: ",a$final_size," ",b$final_size,"\n",sep="")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.