[R-sig-dyn-mod] dede solve issue

Emily Vachon vachone at kenyon.edu
Thu Apr 27 16:44:04 CEST 2017


Hi Everyone,
I am trying to run an SIR disease model with a time lag. The time lag is
represented by tau. I am using Dede solve within DeSolve, but something is
happening where the tau is not changing the output. It has absolutely no
bearing on the graph I get. Clearly there's an issue somewhere in my code.
This is the code:

library(deSolve)
SIRlag<-function(t,y,p,tau){
  S<-y[1]; I<-y[2]
  B<-p[1]
  g<-p[2]
  a1<-p[3]
  a2<-p[4]
  mm<-p[5]
  b<-p[6]

  tlag <- t - tau
  if (tlag <= 0)
    ylag <- 0.5
  else
    ylag <- lagvalue(tlag)


  dS.dt <- (1-min((a1+a2*ylag[1]), mm))*b*(S+I)-((B*S*I)/(S+I))-b*S
  dI.dt <- ((B*S*I)/(S+I)) - (g*I) - (b*I)

  return(list(c(dS.dt, dI.dt)))
}

times<-seq(0,100, by=1)
outSIR<-dede(y=c(5000,1),times=times, func=SIRlag,
parms=c(1.2,0.07,0.1,0.018,0.4,0.00004), tau=200)
matplot(outSIR[,1],outSIR[,2:3], type="l", xlab="time", ylab="populations")




Does anyone see any obvious issues?
Thank you,

	[[alternative HTML version deleted]]



More information about the R-sig-dynamic-models mailing list