# Modeling pandemics (2)

When introducing the SIR mannequin, in our preliminary put up, we bought an extraordinary differential equation, however we didn’t actually talk about stability, and periodicity. It has to do with the Jacobian matrix of the system. However to begin with, we had three equations for 3 perform, however truly$$displaystyle{{frac{dS}{dt}}+{frac {dI}{dt}}+{frac {dR}{dt}}=0}$$so it signifies that our downside is right here merely in dimension 2. Thereforedisplaystyle {start{aligned}&X={frac {dS}{dt}}=mu(N-S)-{frac {beta IS}{N}},[6pt]&Y={frac {dI}{dt}}={frac {beta IS}{N}}-(mu+gamma)Iend{aligned}}and subsequently, the Jacobian of the system is$$start{pmatrix}displaystyle{frac{partial X}{partial S}}&displaystyle{frac{partial X}{partial I}}[9pt]displaystyle{frac{partial Y}{partial S}}&displaystyle{frac{partial Y}{partial I}}finish{pmatrix}=start{pmatrix}displaystyle{-mu-betafrac{I}{N}}&displaystyle{-betafrac{S}{N}}[9pt]displaystyle{betafrac{I}{N}}&displaystyle{betafrac{S}{N}-(mu+gamma)}finish{pmatrix}$$We should always consider the Jacobian on the equilibrium, i.e. $$S^star=frac{gamma+mu}{beta}=frac{1}{R_0}$$and$$I^star=frac{mu(R_0-1)}{beta}$$We should always then take a look at eigenvalues of the matrix.

Our final instance was

 1 2 3 4 5  occasions = seq(0, 100, by=.1) p = c(mu = 1/100, N = 1, beta = 50, gamma = 10) start_SIR = c(S=0.19, I=0.01, R = 0.8) resol = ode(y=start_SIR, t=occasions, func=SIR, p=p) plot(resol[,"time"],resol[,"I"],kind="l",xlab="time",ylab="")  We will compute values on the equilibrium

 1 2 3 4  mu=p["mu"]; beta=p["beta"]; gamma=p["gamma"] N=1 S = (gamma + mu)/beta I = mu * (beta/(gamma + mu) - 1)/beta 

and the Jacobian matrix

 1 2  J=matrix(c(-(mu + beta * I/N),-(beta * S/N), beta * I/N,beta * S/N - (mu + gamma)),2,2,byrow = TRUE) 

Now, if we take a look at the eigenvalues,

 1 2  eigen(J)$values  -0.024975+0.6318831i -0.024975-0.6318831i  or extra exactly $2pi/b$ the place $apm ib$ are the conjuguate eigenvalues  1 2  2 * pi/(Im(eigen(J)$values))  9.943588 

we now have a damping interval of 10 time lengths (10 days, or 10 weeks), which is kind of what we’ve seen above,  The graph above was obtained utilizing

 1 2 3 4 5 6 7 8 9  p = c(mu = 1/100, N = 1, beta = 50, gamma = 10) start_SIR = c(S=0.19, I=0.01, R = 0.8) resol = ode(y=start_SIR, t=occasions, func=SIR, p=p) plot(resol[1:1e5,"time"],resol[1:1e5,"I"],kind="l",xlab="time",ylab="",lwd=3,col="purple") yi=resol[,"I"] dyi=diff(yi) i=which((dyi[2:length(dyi)]*dyi[1:(length(dyi)-1)])<0) t=resol[i,"time"] arrows(t,.008,t,.008,size=.1,code=3) 

If we glance rigorously. on the begining, the length is (a lot) longer than 10 (about 13)… but it surely does converge in the direction of 9.94

 1 2  plot(diff(t[seq(2,40,by=2)]),kind="b") abline(h=2 * pi/(Im(eigen(J)\$values))  So right here, theoretically, each 10 weeks (assuming that our time size is every week), we must always observe an outbreak, smaller than the earlier one. In observe, initially it’s each 13 or 12 weeks, however the time to attend between outbreaks decreases (till it reaches 10 weeks).