## true epidemic parameters, initial values, and
## vaccination costs
truth <- list(b=0.00218, k=10, nu=0.4, mu=0)
init <- list(S0=762, I0=1, R0=0, D0=0)
costs <- list(vac=2, death=4, infect=1)
## trivial vaccination strategy -- dont vaccinate
vac <- list(frac=0, stop=0)
## simulate the resulting trajectories
init.MCepi <- MCepi(init, truth, vac, costs)
## plot the distribution of trajectories and costs
## under no vaccination
plot(init.MCepi, main="no vaccination")
plot(init.MCepi, type="costs")
## Now try the optimal strategy.
## See the optvac function for more info
vac.opt <- list(frac=0.7, stop=502)
opt.MCepi <- MCepi(init, truth, vac.opt, costs)
## plot the distribution of trajectories and costs
## under the optimal (static) vaccination
plot(opt.MCepi, main="optimal static vaccination")
plot(opt.MCepi, type="costs")
## show the total number of vaccinations
## median and quantiles
getvac(opt.MCepi)
## compare the median costs of the the initial
## (no vaccination) strategy versus the optimal
## (static) policy
T <- length(opt.MCepi$Median$C)
optC <- getcost(opt.MCepi)
initC <- getcost(init.MCepi)
rbind(initC,optC)
Run the code above in your browser using DataLab