Load the ilmtools package...
In [1]:
include("ilmtools.jl")
Out[1]:
Generate a population from a bi-variate uniform distribution...
In [2]:
pop_db1 = create_pop_db_univariates(100, Uniform(0,10), Uniform(0,10))
Out[2]:
Generate the initial infection and propagate infection through population (SI model) in continuous time with parameters $\alpha=2, \beta=6$
In [3]:
evdb = infect_recover_loop(pop_db1, "continuous", "SI", 2, 6)
Out[3]:
Create loglikelihood function
In [4]:
ll = create_loglikelihood(pop_db1, evdb)
Out[4]:
Time the loglikelihood function
In [5]:
ll((2,6))
@time ll((2,6))
Out[5]:
Run MCMC
In [6]:
n = 20000
burnin = 10000
sim = Chains(n, 2, names = ["alpha", "beta"])
theta = AMMVariate([2.0, 6.0])
SigmaF = cholfact(eye(2))
@time for i in 1:n
amm!(theta, SigmaF, ll, adapt = (i <= burnin))
sim[i,:,1] = [theta[1:2]]
end
Mamba.describe(sim)
Produce trace plots for $\alpha$, and $\beta$
In [7]:
plot(x=burnin:n, y=sim.value[burnin:n, 1, 1], Geom.line)
Out[7]:
In [8]:
plot(x=burnin:n, y=sim.value[burnin:n, 2, 1], Geom.line)
Out[8]: