# NOT RUN {
## Example 1: spatial SI model
# generate 100 individuals
set.seed(59991)
x <- runif(100, 0, 10)
y <- runif(100, 0, 10)
covariate <- cbind(runif(100, 0, 2), rbinom(100, 1, 0.5))
out <- epidata(type = "SI",n = 100, Sformula = ~covariate, tmax = 15,
sus.par = c(0.1, 0.3, 0.01), beta = 5.0, x = x, y = y)
alphapar2 <- matrix(c(1, 1, 1, 1, 1, 1), ncol = 2, nrow = 3)
betapar2 <- c(1, 1)
epi<-epimcmc(object = out, tmin = 1, tmax = 15,
niter = 500, sus.par.ini = c(1, 1, 1), beta.ini = 1,
Sformula = ~covariate,
pro.sus.var = c(0.5, 0.3, 0.2), pro.beta.var = 0.1,
prior.sus.dist = c("gamma", "gamma", "gamma"),
prior.beta.dist = "gamma",
prior.sus.par = alphapar2, prior.beta.par = betapar2,
adapt = TRUE, acc.rate = 0.5)
epipred1 <- pred.epi (object = out, xx = epi,
criterion = "newly infectious",
n.samples = 100, burnin = 200, tmin = 1,
Sformula = ~covariate)
plot(epipred1, col = "red", type = "b", lwd = 2)
epipred2 <- pred.epi (object = out, xx = epi,
criterion = "peak time",
n.samples = 100, burnin = 200, tmin = 1,
Sformula = ~covariate)
plot(epipred2, col = "dark gray")
# }
Run the code above in your browser using DataLab