I’m making my first attempt of Stochastic Differential Equations using a SIR model, and follow the stochastic formulation described in Keeling and Rohani (2008): Modeling Infectious Diseases in Humans and Animals, Princeton University Press.
My questions (at the bottom!) relates to the description of the noise + the choice of solver. First, the deterministic model (extensive variables, with immigration and emigration – sorry for my partially “private” notation):
When neglecting immigration and emigration and using data from Martcheva’s 2015 Springer book (An Introduction to Mathematical Epidemiology), the deterministic model gives:
Assuming Poisson distribution for the events leading to infection and recovery, Keeling and Rohani’s description gives the Stochastic Differential Equation:
Here, f() is the drift/“deterministic” term while G() is the diffusion/“stochastic” term, while dw holds two independent Wiener processes:
# Drift function for SIR model function sir_drift!(f,x,p,t) S,I,R = x tau_i,tau_r,N = p # f = -I*S/tau_i/N f = I*S/tau_i/N - I/tau_r f = I/tau_r end # Diffusion model for SIR model function sir_diffuse!(G,x,p,t) S,I,R = x tau_i,tau_r,N = p # G[1,1] = -sqrt(I*S/tau_i/N) G[1,2] = 0. G[2,1] = sqrt(I*S/tau_i/N) G[2,2] = - sqrt(I/tau_r) G[3,1] = 0. G[3,2] = sqrt(I/tau_r) end
Next, I define the problem; elements of the description:
# prob = SDEProblem(sir_drift!,sir_diffuse!,x3,tspan,p,noise_rate_prototype=zeros(3,2)) ensembleprob = EnsembleProblem(prob) sol = solve(ensembleprob,EnsembleThreads(),trajectories=100)
I can compute some statistics, and find:
Question 1: I have specified the noise as
noise_rate_prototype=zeros(3,2). Is this correct for saying that there are two independent Wiener processes for the 3 states? Does it matter whether I use
ones(3,2) or something else, or is the important thing that the matrix has correct dimension? [And why not just say that I have a vector of Wiener processes with 2 elements??]
Question 2: I have not specified the solver. I tried to specify solver
SRWI1, but that gave an error message.